mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2025-09-20 01:57:16 +00:00
Account for colons in version value.
This commit is contained in:
parent
19a0253e65
commit
7c7bcedcc5
|
@ -62,10 +62,10 @@ func getPackages(names []string) AptPackages {
|
|||
pkg := AptPackage{}
|
||||
for _, line := range strings.Split(paragraph, "\n") {
|
||||
if strings.HasPrefix(line, "Package: ") {
|
||||
pkg.Name = strings.TrimSpace(strings.Split(line, ":")[1])
|
||||
pkg.Name = strings.TrimSpace(strings.SplitN(line, ":", 2)[1])
|
||||
} else if strings.HasPrefix(line, "Version: ") {
|
||||
pkg.Version = strings.TrimSpace(strings.Split(line, ":")[1])
|
||||
} else if strings.HasPrefix(line, "N: Unable to locate package ") || strings.HasPrefix(line, "E: ") {
|
||||
pkg.Version = strings.TrimSpace(strings.SplitN(line, ":", 2)[1])
|
||||
} else if strings.HasPrefix(line, "N: ") || strings.HasPrefix(line, "E: ") {
|
||||
if !contains(errorMessages, line) {
|
||||
errorMessages = append(errorMessages, line)
|
||||
}
|
||||
|
|
|
@ -31,14 +31,16 @@ func (r *RunResult) expectSuccessfulOut(expected string) {
|
|||
if r.Stderr != "" {
|
||||
r.TestContext.Errorf("Unexpected stderr messages found.\nExpected: none\nActual:\n'%s'", r.Stderr)
|
||||
}
|
||||
if r.Stdout != expected+"\n" { // Output will always have a end of output newline.
|
||||
r.TestContext.Errorf("Unexpected stdout found.\nExpected:\n'%s'\nActual:\n'%s'", expected, r.Stdout)
|
||||
fullExpected := expected + "\n" // Output will always have a end of output newline.
|
||||
if r.Stdout != fullExpected { // Output will always have a end of output newline.
|
||||
r.TestContext.Errorf("Unexpected stdout found.\nExpected:\n'%s'\nActual:\n'%s'", fullExpected, r.Stdout)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RunResult) expectError(expected string) {
|
||||
if r.Stderr != expected+"\n" { // Output will always have a end of output newline.
|
||||
r.TestContext.Errorf("Unexpected stderr found.\nExpected:\n'%s'\nActual:\n'%s'", expected, r.Stderr)
|
||||
fullExpected := expected + "\n" // Output will always have a end of output newline.
|
||||
if r.Stderr != fullExpected {
|
||||
r.TestContext.Errorf("Unexpected stderr found.\nExpected:\n'%s'\nActual:\n'%s'", fullExpected, r.Stderr)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +64,11 @@ func TestNormalizedList_SinglePackageExists_StdoutsSinglePackageNameVersionPair(
|
|||
result.expectSuccessfulOut("xdot=1.2-3")
|
||||
}
|
||||
|
||||
func TestNormalizedList_VersionContainsColon_StdoutsEntireVersion(t *testing.T) {
|
||||
var result = run(t, "normalized-list", "default-jre")
|
||||
result.expectSuccessfulOut("default-jre=2:1.17-74")
|
||||
}
|
||||
|
||||
func TestNormalizedList_NonExistentPackageName_StderrsAptCacheErrors(t *testing.T) {
|
||||
var result = run(t, "normalized-list", "nonexistentpackagename")
|
||||
result.expectError(
|
||||
|
|
Loading…
Reference in a new issue