Mohammed Naser | 3b3507d | 2023-11-28 21:13:39 -0500 | [diff] [blame] | 1 | package defaults |
| 2 | |
| 3 | import ( |
| 4 | "regexp" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/stretchr/testify/assert" |
| 8 | "github.com/stretchr/testify/require" |
| 9 | ) |
| 10 | |
| 11 | var ( |
| 12 | r *regexp.Regexp |
| 13 | ) |
| 14 | |
| 15 | func init() { |
| 16 | r, _ = regexp.Compile(`{{ atmosphere_images\['(?P<ImageName>\w+)'] \| vexxhost.kubernetes.docker_image\('ref'\) }}`) |
| 17 | } |
| 18 | |
| 19 | func AssertAtmosphereImage(t *testing.T, expected string, value string) { |
| 20 | matches := r.FindStringSubmatch(value) |
| 21 | require.Len(t, matches, 2) |
| 22 | imageName := matches[1] |
| 23 | |
| 24 | image, err := GetImageByKey(imageName) |
| 25 | require.NoError(t, err) |
| 26 | |
vexxhost-bot | 232374a | 2024-11-18 12:37:05 -0500 | [diff] [blame] | 27 | assert.Contains(t, image, expected) |
Mohammed Naser | 3b3507d | 2023-11-28 21:13:39 -0500 | [diff] [blame] | 28 | } |