Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print package list when extra packages found #1791

Merged
merged 1 commit into from
May 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion test/cli/trait_assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package cli

import (
"encoding/json"
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"sort"
"strings"
"testing"

Expand Down Expand Up @@ -104,8 +106,12 @@ func assertStdoutLengthGreaterThan(length uint) traitAssertion {
func assertPackageCount(length uint) traitAssertion {
return func(tb testing.TB, stdout, _ string, _ int) {
tb.Helper()
type NameAndVersion struct {
Name string `json:"name"`
Version string `json:"version"`
}
type partial struct {
Artifacts []interface{} `json:"artifacts"`
Artifacts []NameAndVersion `json:"artifacts"`
}
var data partial

Expand All @@ -115,6 +121,14 @@ func assertPackageCount(length uint) traitAssertion {

if uint(len(data.Artifacts)) != length {
tb.Errorf("expected package count of %d, but found %d", length, len(data.Artifacts))
debugArtifacts := make([]string, len(data.Artifacts))
for i, a := range data.Artifacts {
debugArtifacts[i] = fmt.Sprintf("%s:%s", a.Name, a.Version)
}
sort.Strings(debugArtifacts)
for i, a := range debugArtifacts {
tb.Errorf("package %d: %s", i+1, a)
}

}
}
Expand Down