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_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"