go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/lucicfg/testdata/cq/refset.star (about) 1 load("@stdlib//internal/luci/lib/cq.star", "cq") 2 3 def test_refset_ok(): 4 def cmp(in_repo, in_refs, in_refs_exclude, out_gob, out_proj, out_refs, out_refs_exclude): 5 refset = cq.refset(repo = in_repo, refs = in_refs, refs_exclude = in_refs_exclude) 6 assert.eq(refset.__gob_host, out_gob) 7 assert.eq(refset.__gob_proj, out_proj) 8 assert.eq(refset.__refs, out_refs) 9 assert.eq(refset.__refs_exclude, out_refs_exclude) 10 11 cmp( 12 "https://example.googlesource.com/repo", 13 [".*"], 14 None, 15 "example", 16 "repo", 17 [".*"], 18 [], 19 ) 20 cmp( 21 "https://example-review.googlesource.com/a/zzz/repo", 22 None, 23 None, 24 "example", 25 "zzz/repo", 26 ["refs/heads/main"], 27 [], 28 ) 29 cmp( 30 "https://example-review.googlesource.com/repo", 31 ["refs/heads/.+"], 32 ["refs/heads/ex*"], 33 "example", 34 "repo", 35 ["refs/heads/.+"], 36 ["refs/heads/ex*"], 37 ) 38 39 def test_refset_fail(): 40 def fail(repo, msg): 41 assert.fails(lambda: cq.refset(repo = repo), msg) 42 43 fail("example.googlesource.com/repo", 'should match "https://') 44 fail("https://github.com/zzz", r"only \*\.googlesource.com repos are supported currently") 45 fail("https://-review.googlesource.com/repo", "not a valid repository URL") 46 fail("https://example.googlesource.com/a/", "not a valid repository URL") 47 48 test_refset_ok() 49 test_refset_fail()