|
| 1 | +// This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | +// file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 | + |
| 5 | +//go:build integration |
| 6 | + |
| 7 | +package integration_test |
| 8 | + |
| 9 | +import ( |
| 10 | + "testing" |
| 11 | + |
| 12 | + "github.com/stretchr/testify/assert" |
| 13 | + "github.com/stretchr/testify/require" |
| 14 | + |
| 15 | + "github.com/siderolabs/image-factory/cmd/image-factory/cmd" |
| 16 | + "github.com/siderolabs/image-factory/pkg/client" |
| 17 | +) |
| 18 | + |
| 19 | +// TestBrokenVersions verifies that versions listed in BrokenTalosVersions are |
| 20 | +// excluded from the /versions response and reported by /versions?broken=true. |
| 21 | +func TestBrokenVersions(t *testing.T) { |
| 22 | + t.Parallel() |
| 23 | + |
| 24 | + const brokenVersion = "v1.13.1" |
| 25 | + |
| 26 | + options := cmd.DefaultOptions |
| 27 | + options.Cache.OCI = cacheRepository.OCIRepositoryOptions |
| 28 | + options.Metrics.Namespace = "test_broken_versions" |
| 29 | + options.Build.BrokenTalosVersions = []string{brokenVersion[1:]} |
| 30 | + |
| 31 | + ctx, listenAddr, _ := setupFactory(t, options) |
| 32 | + baseURL := "http://" + listenAddr |
| 33 | + |
| 34 | + c, err := client.New(baseURL, clientAuthCredentials()...) |
| 35 | + require.NoError(t, err) |
| 36 | + |
| 37 | + broken, err := c.BrokenVersions(ctx) |
| 38 | + require.NoError(t, err) |
| 39 | + |
| 40 | + assert.Contains(t, broken, brokenVersion) |
| 41 | + |
| 42 | + versions, err := c.Versions(ctx) |
| 43 | + require.NoError(t, err) |
| 44 | + |
| 45 | + assert.NotContains(t, versions, brokenVersion) |
| 46 | +} |
0 commit comments