| 126 | } |
| 127 | |
| 128 | func TestImageReferenceString(t *testing.T) { |
| 129 | cases := []struct { |
| 130 | name string |
| 131 | ref ImageReference |
| 132 | expected string |
| 133 | }{ |
| 134 | { |
| 135 | name: "repository only", |
| 136 | ref: ImageReference{ |
| 137 | Repository: "repository.com/repo", |
| 138 | }, |
| 139 | expected: "repository.com/repo", |
| 140 | }, |
| 141 | { |
| 142 | name: "digest only", |
| 143 | ref: ImageReference{ |
| 144 | Repository: "repository.com/repo", |
| 145 | Digest: testHash.String(), |
| 146 | }, |
| 147 | expected: "repository.com/repo@" + testHash.String(), |
| 148 | }, |
| 149 | { |
| 150 | name: "tag only", |
| 151 | ref: ImageReference{ |
| 152 | Repository: "repository.com/repo", |
| 153 | Tag: "1.0", |
| 154 | }, |
| 155 | expected: "repository.com/repo:1.0", |
| 156 | }, |
| 157 | { |
| 158 | name: "both digest and tag", |
| 159 | ref: ImageReference{ |
| 160 | Repository: "repository.com/repo", |
| 161 | Digest: testHash.String(), |
| 162 | Tag: "1.0", |
| 163 | }, |
| 164 | expected: "repository.com/repo:1.0@" + testHash.String(), |
| 165 | }, |
| 166 | } |
| 167 | |
| 168 | for _, c := range cases { |
| 169 | t.Run("", func(t *testing.T) { |
| 170 | assert.Equal(t, c.expected, c.ref.String()) |
| 171 | }) |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | func TestImageReferenceRef(t *testing.T) { |
| 176 | tests := []struct { |