Only catch package not found warnings.

This commit is contained in:
Andrew Walsh 2023-11-26 21:38:32 -08:00
parent 7c7bcedcc5
commit 8b55495730
2 changed files with 7 additions and 2 deletions

View file

@ -65,7 +65,7 @@ func getPackages(names []string) AptPackages {
pkg.Name = strings.TrimSpace(strings.SplitN(line, ":", 2)[1]) pkg.Name = strings.TrimSpace(strings.SplitN(line, ":", 2)[1])
} else if strings.HasPrefix(line, "Version: ") { } else if strings.HasPrefix(line, "Version: ") {
pkg.Version = strings.TrimSpace(strings.SplitN(line, ":", 2)[1]) pkg.Version = strings.TrimSpace(strings.SplitN(line, ":", 2)[1])
} else if strings.HasPrefix(line, "N: ") || strings.HasPrefix(line, "E: ") { } else if strings.HasPrefix(line, "N: Unable to locate package ") || strings.HasPrefix(line, "E: ") {
if !contains(errorMessages, line) { if !contains(errorMessages, line) {
errorMessages = append(errorMessages, line) errorMessages = append(errorMessages, line)
} }

View file

@ -25,7 +25,7 @@ func run(t *testing.T, command string, pkgNames ...string) RunResult {
func (r *RunResult) expectSuccessfulOut(expected string) { func (r *RunResult) expectSuccessfulOut(expected string) {
if r.Err != nil { if r.Err != nil {
r.TestContext.Errorf("Error running command: %v", r.Err) r.TestContext.Errorf("Error running command: %v\n%s", r.Err, r.Stderr)
return return
} }
if r.Stderr != "" { if r.Stderr != "" {
@ -59,6 +59,11 @@ func TestNormalizedList_SamePackagesDifferentOrder_StdoutsMatch(t *testing.T) {
result.expectSuccessfulOut(expected) result.expectSuccessfulOut(expected)
} }
func TestNormalizedList_MultiVersionWarning_StdoutSingleVersion(t *testing.T) {
var result = run(t, "normalized-list", "libosmesa6-dev", "libgl1-mesa-dev")
result.expectSuccessfulOut("libgl1-mesa-dev=23.0.4-0ubuntu1~23.04.1 libosmesa6-dev=23.0.4-0ubuntu1~23.04.1")
}
func TestNormalizedList_SinglePackageExists_StdoutsSinglePackageNameVersionPair(t *testing.T) { func TestNormalizedList_SinglePackageExists_StdoutsSinglePackageNameVersionPair(t *testing.T) {
var result = run(t, "normalized-list", "xdot") var result = run(t, "normalized-list", "xdot")
result.expectSuccessfulOut("xdot=1.2-3") result.expectSuccessfulOut("xdot=1.2-3")