Skip to content

Commit

Permalink
Mock tests for GitHub releases.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekbanas committed Oct 2, 2024
1 parent bbe8743 commit 9d22d48
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
41 changes: 41 additions & 0 deletions tests/testthat/helper-fixtures.R
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,44 @@ test_fixtures$github_files_tree_response <- list(
)
)
)

test_fixtures$github_releases_from_org <- list(
"data" = list(
"repository" = list(
"name" = "TestProject1",
"url" = "test_url",
"releases" = list(
"nodes" = list(
list(
"name" = "2.1.0",
"tagName" = "v2.1.0",
"publishedAt" = "2024-01-01T00:00:00Z",
"url" = "https://test_url/tag/v2.1.0",
"description" = "Great features come with this release."
),
list(
"name" = "1.1.1",
"tagName" = "v1.1.1",
"publishedAt" = "2023-09-28T00:00:00Z",
"url" = "https://test_url/tag/v1.1.0",
"description" = "Great features come with this release."
),
list(
"name" = "0.1.0",
"tagName" = "v0.1.0",
"publishedAt" = "2023-04-01T00:00:00Z",
"url" = "https://test_url/tag/v0.1.0",
"description" = "Great features come with this release."
),
list(
"name" = "0.1.1",
"tagName" = "v0.1.1",
"publishedAt" = "2023-05-02T00:00:00Z",
"url" = "https://test_url/tag/v0.1.0",
"description" = "Great features come with this release."
)
)
)
)
)
)
9 changes: 7 additions & 2 deletions tests/testthat/test-get_release-GitHub.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ test_that("releases query is built properly", {
})

test_that("`get_releases_from_org()` pulls releases from the repositories", {
mockery::stub(
test_graphql_github$get_release_logs_from_org,
"self$gql_response",
test_fixtures$github_releases_from_org
)
releases_from_repos <- test_graphql_github$get_release_logs_from_org(
repos_names = c("GitStats", "shinyCohortBuilder"),
org = "r-world-devs"
repos_names = c("TestProject1", "TestProject2"),
org = "test_org"
)
expect_github_releases_response(releases_from_repos)
test_mocker$cache(releases_from_repos)
Expand Down

0 comments on commit 9d22d48

Please sign in to comment.