Skip to content

Commit

Permalink
Mock some tests to get them faster.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekbanas committed Sep 27, 2024
1 parent 7f30afb commit 52e926f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/testthat/test-get_commits-GitHub.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ test_that("`get_commits_from_one_repo()` prepares formatted list", {
})

test_that("`get_commits_from_repos()` pulls commits from repos", {
mockery::stub(
test_graphql_github$get_commits_from_repos,
"private$get_commits_from_one_repo",
test_mocker$use("commits_from_repo")
)
commits_from_repos <- test_graphql_github$get_commits_from_repos(
org = "r-world-devs",
repo = "GitStats",
Expand Down
27 changes: 27 additions & 0 deletions tests/testthat/test-get_files_content-GitHub.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,24 @@ test_that("get_repos_data pulls data on repos and branches", {
)
})

test_that("GitHub GraphQL Engine pulls file response", {
github_file_response <- test_graphql_github_priv$get_file_response(
org = "r-world-devs",
repo = "GitStats",
def_branch = "master",
file_path = "LICENSE",
files_query = test_mocker$use("gh_file_blobs_from_repo_query")
)
expect_github_files_response(github_file_response)
test_mocker$cache(github_file_response)
})

test_that("GitHub GraphQL Engine pulls files from organization", {
mockery::stub(
test_graphql_github$get_files_from_org,
"private$get_file_response",
test_mocker$use("github_file_response")
)
github_files_response <- test_graphql_github$get_files_from_org(
org = "r-world-devs",
repos = NULL,
Expand Down Expand Up @@ -53,6 +70,11 @@ test_that("GitHub GraphQL Engine pulls .png files from organization", {
})

test_that("GitHub GraphQL Engine pulls files from defined repositories", {
mockery::stub(
test_graphql_github$get_files_from_org,
"private$get_file_response",
test_mocker$use("github_file_response")
)
github_files_response <- test_graphql_github$get_files_from_org(
org = "openpharma",
repos = c("DataFakeR", "visR"),
Expand All @@ -67,6 +89,11 @@ test_that("GitHub GraphQL Engine pulls files from defined repositories", {
})

test_that("GitHub GraphQL Engine pulls two files from a group", {
mockery::stub(
test_graphql_github$get_files_from_org,
"private$get_file_response",
test_mocker$use("github_file_response")
)
github_files_response <- test_graphql_github$get_files_from_org(
org = "r-world-devs",
repos = NULL,
Expand Down

0 comments on commit 52e926f

Please sign in to comment.