Skip to content

Commit

Permalink
Only catch package not found warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
awalsh128 committed Nov 27, 2023
1 parent 7c7bced commit 8b55495
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apt_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func getPackages(names []string) AptPackages {
pkg.Name = strings.TrimSpace(strings.SplitN(line, ":", 2)[1])
} else if strings.HasPrefix(line, "Version: ") {
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) {
errorMessages = append(errorMessages, line)
}
Expand Down
7 changes: 6 additions & 1 deletion apt_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func run(t *testing.T, command string, pkgNames ...string) RunResult {

func (r *RunResult) expectSuccessfulOut(expected string) {
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
}
if r.Stderr != "" {
Expand Down Expand Up @@ -59,6 +59,11 @@ func TestNormalizedList_SamePackagesDifferentOrder_StdoutsMatch(t *testing.T) {
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) {
var result = run(t, "normalized-list", "xdot")
result.expectSuccessfulOut("xdot=1.2-3")
Expand Down

0 comments on commit 8b55495

Please sign in to comment.