(t *testing.T)
| 13 | } |
| 14 | |
| 15 | func TestTruncateID(t *testing.T) { |
| 16 | tests := []struct { |
| 17 | doc, id, expected string |
| 18 | }{ |
| 19 | { |
| 20 | doc: "empty ID", |
| 21 | id: "", |
| 22 | expected: "", |
| 23 | }, |
| 24 | { |
| 25 | // IDs are expected to be 12 (short) or 64 characters, and not be numeric only, |
| 26 | // but TruncateID should handle these gracefully. |
| 27 | doc: "invalid ID", |
| 28 | id: "1234", |
| 29 | expected: "1234", |
| 30 | }, |
| 31 | { |
| 32 | doc: "full ID", |
| 33 | id: "90435eec5c4e124e741ef731e118be2fc799a68aba0466ec17717f24ce2ae6a2", |
| 34 | expected: "90435eec5c4e", |
| 35 | }, |
| 36 | { |
| 37 | doc: "digest", |
| 38 | id: "sha256:90435eec5c4e124e741ef731e118be2fc799a68aba0466ec17717f24ce2ae6a2", |
| 39 | expected: "90435eec5c4e", |
| 40 | }, |
| 41 | { |
| 42 | doc: "very long ID", |
| 43 | id: "90435eec5c4e124e741ef731e118be2fc799a68aba0466ec17717f24ce2ae6a290435eec5c4e124e741ef731e118be2fc799a68aba0466ec17717f24ce2ae6a2", |
| 44 | expected: "90435eec5c4e", |
| 45 | }, |
| 46 | } |
| 47 | |
| 48 | for _, tc := range tests { |
| 49 | t.Run(tc.doc, func(t *testing.T) { |
| 50 | actual := TruncateID(tc.id) |
| 51 | if actual != tc.expected { |
| 52 | t.Errorf("expected: %q, got: %q", tc.expected, actual) |
| 53 | } |
| 54 | }) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func TestAllNum(t *testing.T) { |
| 59 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…