| 12 | ) |
| 13 | |
| 14 | func TestReferenceParse(t *testing.T) { |
| 15 | // referenceTestcases is a unified set of testcases for |
| 16 | // testing the parsing of references |
| 17 | referenceTestcases := []struct { |
| 18 | // input is the repository name or name component testcase |
| 19 | input string |
| 20 | // err is the error expected from Parse, or nil |
| 21 | err error |
| 22 | // repository is the string representation for the reference |
| 23 | repository string |
| 24 | // domain is the domain expected in the reference |
| 25 | domain string |
| 26 | // tag is the tag for the reference |
| 27 | tag string |
| 28 | // digest is the digest for the reference (enforces digest reference) |
| 29 | digest string |
| 30 | }{ |
| 31 | { |
| 32 | input: "test_com", |
| 33 | repository: "test_com", |
| 34 | }, |
| 35 | { |
| 36 | input: "test.com:tag", |
| 37 | repository: "test.com", |
| 38 | tag: "tag", |
| 39 | }, |
| 40 | { |
| 41 | input: "test.com:5000", |
| 42 | repository: "test.com", |
| 43 | tag: "5000", |
| 44 | }, |
| 45 | { |
| 46 | input: "test.com/repo:tag", |
| 47 | domain: "test.com", |
| 48 | repository: "test.com/repo", |
| 49 | tag: "tag", |
| 50 | }, |
| 51 | { |
| 52 | input: "test:5000/repo", |
| 53 | domain: "test:5000", |
| 54 | repository: "test:5000/repo", |
| 55 | }, |
| 56 | { |
| 57 | input: "test:5000/repo:tag", |
| 58 | domain: "test:5000", |
| 59 | repository: "test:5000/repo", |
| 60 | tag: "tag", |
| 61 | }, |
| 62 | { |
| 63 | input: "test:5000/repo@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", |
| 64 | domain: "test:5000", |
| 65 | repository: "test:5000/repo", |
| 66 | digest: "sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", |
| 67 | }, |
| 68 | { |
| 69 | input: "test:5000/repo:tag@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", |
| 70 | domain: "test:5000", |
| 71 | repository: "test:5000/repo", |