def test_prefetch_github_actual_prefetch(pypi2nix_list_remote): seq = [ ( nix_prefetch_github.GetListRemote(owner="seppeljordan", repo="pypi2nix"), lambda i: pypi2nix_list_remote, ), ( nix_prefetch_github.CalculateSha256Sum( owner="seppeljordan", repo="pypi2nix", revision=pypi2nix_list_remote.branch("master"), ), lambda i: "TEST_ACTUALHASH", ), ( nix_prefetch_github.TryPrefetch( owner="seppeljordan", repo="pypi2nix", rev=pypi2nix_list_remote.branch("master"), sha256="TEST_ACTUALHASH", ), lambda i: None, ), ] eff = nix_prefetch_github.prefetch_github( owner="seppeljordan", repo="pypi2nix", prefetch=True ) prefetch_result = perform_sequence(seq, eff) assert prefetch_result["rev"] == pypi2nix_list_remote.branch("master") assert prefetch_result["sha256"] == "TEST_ACTUALHASH"
def test_prefetch_github_rev_given(): commit_hash = "50553a665d2700c353ac41ab28c23b1027b7c1f0" seq = [ ( nix_prefetch_github.CalculateSha256Sum( owner="seppeljordan", repo="pypi2nix", revision=commit_hash ), lambda i: "TEST_ACTUALHASH", ) ] eff = nix_prefetch_github.prefetch_github( owner="seppeljordan", repo="pypi2nix", prefetch=False, rev=commit_hash ) prefetch_result = perform_sequence(seq, eff) assert prefetch_result["rev"] == commit_hash assert prefetch_result["sha256"] == "TEST_ACTUALHASH"
def test_prefetch_aborts_when_rev_is_not_found(pypi2nix_list_remote): sequence = [ ( nix_prefetch_github.GetListRemote(owner="seppeljordan", repo="pypi2nix"), lambda _: pypi2nix_list_remote, ), ( AbortWithErrorMessage( revision_not_found_errormessage( owner="seppeljordan", repo="pypi2nix", revision="does-not-exist" ) ), lambda _: None, ), ] effect = nix_prefetch_github.prefetch_github( owner="seppeljordan", repo="pypi2nix", rev="does-not-exist" ) prefetch_result = perform_sequence(sequence, effect) assert prefetch_result is None
def test_can_prefetch_from_tag_given_as_rev(pypi2nix_list_remote): seq = [ ( nix_prefetch_github.GetListRemote(owner="seppeljordan", repo="pypi2nix"), lambda i: pypi2nix_list_remote, ), ( nix_prefetch_github.CalculateSha256Sum( owner="seppeljordan", repo="pypi2nix", revision=pypi2nix_list_remote.tag("v1.0"), ), lambda i: "TEST_ACTUALHASH", ), ] eff = nix_prefetch_github.prefetch_github( owner="seppeljordan", repo="pypi2nix", prefetch=False, rev="v1.0" ) prefetch_result = perform_sequence(seq, eff) assert prefetch_result["rev"] == pypi2nix_list_remote.tag("v1.0") assert prefetch_result["sha256"] == "TEST_ACTUALHASH"
def test_that_prefetch_github_understands_full_ref_names(pypi2nix_list_remote): sequence = [ ( nix_prefetch_github.GetListRemote(owner="seppeljordan", repo="pypi2nix"), lambda i: pypi2nix_list_remote, ), ( nix_prefetch_github.CalculateSha256Sum( owner="seppeljordan", repo="pypi2nix", revision=pypi2nix_list_remote.branch("master"), ), lambda i: "TEST_ACTUALHASH", ), ] effect = nix_prefetch_github.prefetch_github( owner="seppeljordan", repo="pypi2nix", prefetch=False, rev="refs/heads/master" ) prefetch_result = perform_sequence(sequence, effect) assert prefetch_result["rev"] == pypi2nix_list_remote.branch("master") assert prefetch_result["sha256"] == "TEST_ACTUALHASH"
def test_prefetch_sensu_go_5_11(nixos_secure_factory_ls_remote_output): sequence = [ ( GetListRemote(owner="jraygauthier", repo="nixos-secure-factory"), lambda _: nixos_secure_factory_ls_remote_output, ), ( CalculateSha256Sum( owner="jraygauthier", repo="nixos-secure-factory", revision="ad1a1d1d25870cc70cd7e708a73c874322064d96", ), lambda _: "TEST_HASH_SUM", ), ] effect = prefetch_github(owner="jraygauthier", repo="nixos-secure-factory", prefetch=False, rev="jrg/mvp") prefetch_result = perform_sequence(sequence, effect) assert prefetch_result["rev"] == "ad1a1d1d25870cc70cd7e708a73c874322064d96" assert prefetch_result["sha256"] == "TEST_HASH_SUM"
def test_prefetch_sensu_go_5_11(sensu_go_ls_remote_output): sequence = [ ( GetListRemote(owner="sensu", repo="sensu-go"), lambda _: sensu_go_ls_remote_output, ), ( CalculateSha256Sum( owner="sensu", repo="sensu-go", revision="dd8f160a9033ecb5ad0384baf6a9965fa7bd3c17", ), lambda _: "TEST_HASH_SUM", ), ] effect = prefetch_github(owner="sensu", repo="sensu-go", prefetch=False, rev="5.11.0") prefetch_result = perform_sequence(sequence, effect) assert prefetch_result["rev"] == "dd8f160a9033ecb5ad0384baf6a9965fa7bd3c17" assert prefetch_result["sha256"] == "TEST_HASH_SUM"