Skip to content

Commit

Permalink
Remove snapshots so tests can pass on CRAN. Tests with snapshots are …
Browse files Browse the repository at this point in the history
…skipped on CRAN which results in case of GitStats for some tests not passing outputs to test_mocker and in result failutre of following up tests.
  • Loading branch information
maciekbanas committed Oct 18, 2024
1 parent f3ee13f commit 01a4842
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 93 deletions.
15 changes: 0 additions & 15 deletions tests/testthat/_snaps/01-get_repos-GitHub.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
Output
[1] "\n query GetReposByOrg($login: String! $repoCursor: String!) {\n repositoryOwner(login: $login) {\n ... on Organization {\n \n repositories(first: 100 after: $repoCursor) {\n totalCount\n pageInfo {\n endCursor\n hasNextPage\n }\n nodes {\n repo_id: id\n repo_name: name\n default_branch: defaultBranchRef {\n name\n }\n stars: stargazerCount\n forks: forkCount\n created_at: createdAt\n last_activity_at: pushedAt\n languages (first: 5) { nodes {name} }\n issues_open: issues (first: 100 states: [OPEN]) {\n totalCount\n }\n issues_closed: issues (first: 100 states: [CLOSED]) {\n totalCount\n }\n organization: owner {\n login\n }\n repo_url: url\n }\n }\n \n }\n }\n }"

# `prepare_repos_table()` prepares repos table

Code
gh_repos_by_code_table <- test_rest_github$prepare_repos_table(repos_list = test_mocker$
use("gh_repos_by_code_tailored"))
Message
i Preparing repositories table...

# `prepare_repos_table()` prepares minimum version of repos table

Code
Expand All @@ -21,13 +13,6 @@
Message
i Preparing repositories table...

# `get_all_repos()` works as expected

Code
gh_repos_table <- github_testhost_priv$get_all_repos()
Message
i [Host:GitHub][Engine:GraphQl][Scope:test-org] Pulling repositories...

# `get_repos_contributors()` works on GitHost level

Code
Expand Down
8 changes: 0 additions & 8 deletions tests/testthat/_snaps/01-get_repos-GitStats.md

This file was deleted.

8 changes: 0 additions & 8 deletions tests/testthat/_snaps/get_commits-GitLab.md

This file was deleted.

10 changes: 0 additions & 10 deletions tests/testthat/_snaps/get_files_content-GitLab.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,3 @@
Output
[1] "\n query GetFilesByRepo($fullPath: ID!, $file_paths: [String!]!) {\n project(fullPath: $fullPath) {\n name\n id\n webUrl\n repository {\n blobs(paths: $file_paths) {\n nodes {\n name\n rawBlob\n size\n }\n }\n }\n }\n }\n "

# Gitlab GraphQL switches to pulling files per repositories when query is too complex

Code
gitlab_files_response_by_repos <- test_graphql_gitlab$get_files_from_org(org = "mbtests",
type = "organization", repos = NULL, file_paths = c("DESCRIPTION",
"project_metadata.yaml", "README.md"), host_files_structure = NULL,
only_text_files = TRUE, verbose = TRUE, progress = FALSE)
Message
i I will switch to pulling files per repository.

9 changes: 0 additions & 9 deletions tests/testthat/_snaps/get_files_structure-GitLab.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
Output
[1] "\n query GetFilesTree ($fullPath: ID!, $file_path: String!) {\n project(fullPath: $fullPath) {\n repository {\n tree(path: $file_path) {\n trees (first: 100) {\n pageInfo{\n endCursor\n hasNextPage\n }\n nodes {\n name\n }\n }\n blobs (first: 100) {\n pageInfo{\n endCursor\n hasNextPage\n }\n nodes {\n name\n }\n }\n }\n }\n }\n }\n "

# get_files_structure_from_orgs pulls files structure for repositories in orgs

Code
gl_files_structure_from_orgs <- gitlab_testhost_priv$
get_files_structure_from_orgs(pattern = "\\.md", depth = 1L, verbose = TRUE,
progress = FALSE)
Message
i [Host:GitLab][Engine:GraphQl][Scope:mbtests] Pulling files structure...[files matching pattern: '\.md']...

# get_files_content makes use of files_structure

Code
Expand Down
6 changes: 0 additions & 6 deletions tests/testthat/_snaps/get_files_structure-GitStats.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,3 @@
! No files structure found for matching pattern \.png in 1 level of dirs.
! Files structure will not be saved in GitStats.

# get_files_structure works as expected

Code
files_structure <- test_gitstats$get_files_structure(pattern = "\\.md", depth = 2L,
verbose = TRUE)

11 changes: 5 additions & 6 deletions tests/testthat/test-01-get_repos-GitHub.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,9 @@ test_that("GitHub tailors `repos_list` to minimal version of table", {
})

test_that("`prepare_repos_table()` prepares repos table", {
expect_snapshot(
gh_repos_by_code_table <- test_rest_github$prepare_repos_table(
repos_list = test_mocker$use("gh_repos_by_code_tailored")
)
gh_repos_by_code_table <- test_rest_github$prepare_repos_table(
repos_list = test_mocker$use("gh_repos_by_code_tailored"),
verbose = FALSE
)
expect_repos_table(
gh_repos_by_code_table
Expand Down Expand Up @@ -399,8 +398,8 @@ test_that("`get_all_repos()` works as expected", {
"graphql_engine$prepare_repos_table",
test_mocker$use("gh_repos_table")
)
expect_snapshot(
gh_repos_table <- github_testhost_priv$get_all_repos()
gh_repos_table <- github_testhost_priv$get_all_repos(
verbose = FALSE
)
expect_repos_table(
gh_repos_table
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-01-get_repos-GitStats.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ test_that("get_repos works properly and for the second time uses cache", {
repos_object = repos_table,
with_cols = c("contributors", "contributors_n")
)
expect_snapshot(
repos_table <- test_gitstats$get_repos()
repos_table <- test_gitstats$get_repos(
verbose = FALSE
)
expect_repos_table_object(
repos_object = repos_table,
Expand Down
8 changes: 3 additions & 5 deletions tests/testthat/test-get_commits-GitLab.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ test_that("`get_commits_authors_handles_and_names()` adds author logis and names
"private$get_authors_dict",
test_mocker$use("authors_dict")
)
expect_snapshot(
gl_commits_table <- test_rest_gitlab$get_commits_authors_handles_and_names(
commits_table = test_mocker$use("gl_commits_table"),
verbose = TRUE
)
gl_commits_table <- test_rest_gitlab$get_commits_authors_handles_and_names(
commits_table = test_mocker$use("gl_commits_table"),
verbose = FALSE
)
expect_commits_table(
gl_commits_table,
Expand Down
20 changes: 9 additions & 11 deletions tests/testthat/test-get_files_content-GitLab.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,15 @@ test_that("Gitlab GraphQL switches to pulling files per repositories when query
"private$is_complexity_error",
TRUE
)
expect_snapshot(
gitlab_files_response_by_repos <- test_graphql_gitlab$get_files_from_org(
org = "mbtests",
type = "organization",
repos = NULL,
file_paths = c("DESCRIPTION", "project_metadata.yaml", "README.md"),
host_files_structure = NULL,
only_text_files = TRUE,
verbose = TRUE,
progress = FALSE
)
gitlab_files_response_by_repos <- test_graphql_gitlab$get_files_from_org(
org = "mbtests",
type = "organization",
repos = NULL,
file_paths = c("DESCRIPTION", "project_metadata.yaml", "README.md"),
host_files_structure = NULL,
only_text_files = TRUE,
verbose = FALSE,
progress = FALSE
)
expect_gitlab_files_from_org_by_repos_response(
response = gitlab_files_response_by_repos,
Expand Down
12 changes: 5 additions & 7 deletions tests/testthat/test-get_files_structure-GitLab.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,11 @@ test_that("get_files_structure_from_orgs pulls files structure for repositories
"graphql_engine$get_files_structure_from_org",
test_mocker$use("gl_files_structure_shallow")
)
expect_snapshot(
gl_files_structure_from_orgs <- gitlab_testhost_priv$get_files_structure_from_orgs(
pattern = "\\.md",
depth = 1L,
verbose = TRUE,
progress = FALSE
)
gl_files_structure_from_orgs <- gitlab_testhost_priv$get_files_structure_from_orgs(
pattern = "\\.md",
depth = 1L,
verbose = FALSE,
progress = FALSE
)
expect_equal(
names(gl_files_structure_from_orgs),
Expand Down
10 changes: 4 additions & 6 deletions tests/testthat/test-get_files_structure-GitStats.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ test_that("get_files_structure works as expected", {
"private$get_files_structure_from_hosts",
test_mocker$use("files_structure_from_hosts")
)
expect_snapshot(
files_structure <- test_gitstats$get_files_structure(
pattern = "\\.md",
depth = 2L,
verbose = TRUE
)
files_structure <- test_gitstats$get_files_structure(
pattern = "\\.md",
depth = 2L,
verbose = FALSE
)
expect_s3_class(files_structure, "files_structure")
test_mocker$cache(files_structure)
Expand Down

0 comments on commit 01a4842

Please sign in to comment.