Skip to content

Commit

Permalink
Do not specify versions during 'melange test' (Revert chainguard-dev#…
Browse files Browse the repository at this point in the history
…1579 and chainguard-dev#1518)

1518 was added with good reason, but it changed behavior
that many wolfi tests depended on (see chainguard-dev#1579) for that use case.

Revert both of those changes, restoring behavior to the way it was
last week and thus restoring functional test of may wolfi packages.

Signed-off-by: Scott Moser <[email protected]>
  • Loading branch information
smoser committed Oct 21, 2024
1 parent d30e397 commit c147d8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 2 additions & 4 deletions pkg/build/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ func (t *Test) Compile(ctx context.Context) error {
te := &cfg.Subpackages[i].Test.Environment.Contents

// Append the subpackage that we're testing to be installed.
version := fmt.Sprintf("%s-r%d", t.Configuration.Package.Version, t.Configuration.Package.Epoch)
te.Packages = append(te.Packages, sp.Name+"~"+version)
te.Packages = append(te.Packages, sp.Name)

if err := test.CompilePipelines(ctx, sm, sp.Test.Pipeline); err != nil {
return fmt.Errorf("compiling subpackage %q tests: %w", sp.Name, err)
Expand All @@ -97,8 +96,7 @@ func (t *Test) Compile(ctx context.Context) error {
if t.Package != "" {
te.Packages = append(te.Packages, t.Package)
} else {
version := fmt.Sprintf("%s-r%d", t.Configuration.Package.Version, t.Configuration.Package.Epoch)
te.Packages = append(te.Packages, t.Configuration.Package.Name+"~"+version)
te.Packages = append(te.Packages, t.Configuration.Package.Name)
}

if err := test.CompilePipelines(ctx, sm, cfg.Test.Pipeline); err != nil {
Expand Down
10 changes: 3 additions & 7 deletions pkg/build/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,8 @@ func TestInheritWorkdir(t *testing.T) {

func TestCompileTest(t *testing.T) {
test := &Test{
Package: "main",
Configuration: config.Configuration{
Package: config.Package{
Name: "main",
Version: "1.2.3",
Epoch: 4,
},
Test: &config.Test{
Environment: apko_types.ImageConfiguration{
Contents: apko_types.ImageContents{
Expand Down Expand Up @@ -111,11 +107,11 @@ func TestCompileTest(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}

if got, want := test.Configuration.Test.Environment.Contents.Packages, []string{"main-base", "main~1.2.3-r4", "main-need"}; !slices.Equal(got, want) {
if got, want := test.Configuration.Test.Environment.Contents.Packages, []string{"main-base", "main", "main-need"}; !slices.Equal(got, want) {
t.Errorf("main test packages: want %v, got %v", want, got)
}

if got, want := test.Configuration.Subpackages[0].Test.Environment.Contents.Packages, []string{"subpackage-base", "subpackage~1.2.3-r4", "subpackage-need"}; !slices.Equal(got, want) {
if got, want := test.Configuration.Subpackages[0].Test.Environment.Contents.Packages, []string{"subpackage-base", "subpackage", "subpackage-need"}; !slices.Equal(got, want) {
t.Errorf("subpackage test packages: want %v, got %v", want, got)
}
}

0 comments on commit c147d8e

Please sign in to comment.