Skip to content

Commit

Permalink
test(feedstock tokens): add snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
hulkoba committed Jul 2, 2024
1 parent ada61a3 commit cf883dd
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
49 changes: 49 additions & 0 deletions tests/__snapshots__/test_feedstock_tokens.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# serializer version: 1
# name: test_feedstock_token_raises[$GH_TOKEN-bar-None]
FeedstockTokenError('Testing for the feedstock token for foo/bar on provider failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[$GH_TOKEN-bar-azure]
FeedstockTokenError('Testing for the feedstock token for foo/bar on provider azure failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[$GH_TOKEN-bar-feedstock-None]
FeedstockTokenError('Testing for the feedstock token for foo/bar-feedstock on provider failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[$GH_TOKEN-bar-feedstock-azure]
FeedstockTokenError('Testing for the feedstock token for foo/bar-feedstock on provider azure failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[$GITHUB_TOKEN-bar-None]
FeedstockTokenError('Testing for the feedstock token for foo/bar on provider failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[$GITHUB_TOKEN-bar-azure]
FeedstockTokenError('Testing for the feedstock token for foo/bar on provider azure failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[$GITHUB_TOKEN-bar-feedstock-None]
FeedstockTokenError('Testing for the feedstock token for foo/bar-feedstock on provider failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[$GITHUB_TOKEN-bar-feedstock-azure]
FeedstockTokenError('Testing for the feedstock token for foo/bar-feedstock on provider azure failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[${GH_TOKEN}-bar-None]
FeedstockTokenError('Testing for the feedstock token for foo/bar on provider failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[${GH_TOKEN}-bar-azure]
FeedstockTokenError('Testing for the feedstock token for foo/bar on provider azure failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[${GH_TOKEN}-bar-feedstock-None]
FeedstockTokenError('Testing for the feedstock token for foo/bar-feedstock on provider failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[${GH_TOKEN}-bar-feedstock-azure]
FeedstockTokenError('Testing for the feedstock token for foo/bar-feedstock on provider azure failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[${GITHUB_TOKEN}-bar-None]
FeedstockTokenError('Testing for the feedstock token for foo/bar on provider failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[${GITHUB_TOKEN}-bar-azure]
FeedstockTokenError('Testing for the feedstock token for foo/bar on provider azure failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[${GITHUB_TOKEN}-bar-feedstock-None]
FeedstockTokenError('Testing for the feedstock token for foo/bar-feedstock on provider failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
# name: test_feedstock_token_raises[${GITHUB_TOKEN}-bar-feedstock-azure]
FeedstockTokenError('Testing for the feedstock token for foo/bar-feedstock on provider azure failed! Try the command locally with DEBUG_FEEDSTOCK_TOKENS defined in the environment to investigate!')
# ---
8 changes: 3 additions & 5 deletions tests/test_feedstock_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def test_feedstock_token_exists(
"repo", ["$GITHUB_TOKEN", "${GITHUB_TOKEN}", "$GH_TOKEN", "${GH_TOKEN}"]
)
def test_feedstock_token_raises(
mocker, tmpdir, repo, project, ci
mocker, tmpdir, repo, project, ci, snapshot
):
gh_mock = mocker.patch("conda_smithy.github.gh_token")
tmp_mock = mocker.patch("conda_smithy.feedstock_tokens.tempfile")
Expand All @@ -366,8 +366,7 @@ def test_feedstock_token_raises(

with pytest.raises(FeedstockTokenError) as e:
feedstock_token_exists(user, project, repo, provider=ci)

assert "Testing for the feedstock token for" in str(e.value)
assert e.value == snapshot

git_mock.Repo.clone_from.assert_called_once_with(
"abc123",
Expand All @@ -381,7 +380,7 @@ def test_feedstock_token_raises(
"repo", ["$GITHUB_TOKEN", "${GITHUB_TOKEN}", "$GH_TOKEN", "${GH_TOKEN}"]
)
def test_register_feedstock_token_works(
mocker, tmpdir, repo, ci,
mocker, tmpdir, repo, ci
):
gh_mock = mocker.patch("conda_smithy.github.gh_token")
tmp_mock = mocker.patch("conda_smithy.feedstock_tokens.tempfile")
Expand Down Expand Up @@ -488,7 +487,6 @@ def test_register_feedstock_token_notoken(
repo.remote.return_value.push.assert_not_called()

assert not os.path.exists(token_json_pth)

assert "No token found in" in str(e.value)


Expand Down

0 comments on commit cf883dd

Please sign in to comment.