Skip to content

Commit

Permalink
tests: Update TestImageTypePipelineNames to be less strict
Browse files Browse the repository at this point in the history
This test assumed the image's static list of pipeline names must match
the manifest, but it really only needs to check the ones with rpm or
ostree metadata.

To support the ability to have images with different pipelines (eg.
squashfs only vs. ext4+squashfs rootfs iso creation) this changes the
test to make sure the pipelines in the static list are in the manifest,
and in the order specified. But the two lists do not need to match
exactly.
  • Loading branch information
bcl committed Dec 17, 2024
1 parent 0ff71ed commit f0d5919
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/distro/distro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func listTestedDistros(t *testing.T) []string {
// needed for knowing the names of pipelines from the static object without
// having access to a manifest, which we need when parsing metadata from build
// results.
// NOTE: The static list of pipelines really only needs to include those that
// have rpm or ostree metadata in them.
func TestImageTypePipelineNames(t *testing.T) {
// types for parsing the opaque manifest with just the fields we care about
type rpmStageOptions struct {
Expand Down Expand Up @@ -138,11 +140,10 @@ func TestImageTypePipelineNames(t *testing.T) {
err = json.Unmarshal(mf, pm)
assert.NoError(err)

assert.Equal(len(allPipelines), len(pm.Pipelines))
var pmNames []string
for idx := range pm.Pipelines {
// manifest pipeline names should be identical to the ones
// defined in the image type and in the same order
assert.Equal(allPipelines[idx], pm.Pipelines[idx].Name)
// Gather the names of the manifest piplines for later
pmNames = append(pmNames, pm.Pipelines[idx].Name)

if pm.Pipelines[idx].Name == "os" {
rpmStagePresent := false
Expand Down Expand Up @@ -171,6 +172,15 @@ func TestImageTypePipelineNames(t *testing.T) {
// sure they match.
assert.Equal(imageType.Exports()[0], pm.Pipelines[len(pm.Pipelines)-1].Name)

// The pipelines named in allPipelines must exist in the manifest, and in the
// order specified (eg. 'build' first) but it does not need to be an exact
// match. Only the pipelines with rpm or ostree metadata are required.
var order int
for _, name := range allPipelines {
idx := slices.Index(pmNames, name)
assert.True(idx >= order, "%s not in order %v", name, pmNames)
order = idx
}
})
}
}
Expand Down

0 comments on commit f0d5919

Please sign in to comment.