Skip to content

Commit

Permalink
tests: don't check for exact "min: 1 %" formatting
Browse files Browse the repository at this point in the history
Only check that the output contains " 1 %". This keeps
the tests working even if the formatting changes.
  • Loading branch information
rfjakob committed Jul 21, 2018
1 parent ffe4e9f commit 5f796f9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ func TestCli(t *testing.T) {
{args: []string{"-p"}, code: -1, stdoutContains: memReport},
{args: []string{"-v"}, code: 0, stderrContains: "earlyoom v", stdoutEmpty: true},
{args: []string{"-d"}, code: -1, stdoutContains: "^ new victim (higher badness)"},
{args: []string{"-m", "1"}, code: -1, stderrContains: "1 %", stdoutContains: memReport},
{args: []string{"-m", "1"}, code: -1, stderrContains: " 1 %", stdoutContains: memReport},
{args: []string{"-m", "0"}, code: 15, stderrContains: "invalid percentage", stdoutEmpty: true},
{args: []string{"-m", "-10"}, code: 15, stderrContains: "invalid percentage", stdoutEmpty: true},
// Using "-m 100" makes no sense
{args: []string{"-m", "100"}, code: 15, stderrContains: "invalid percentage", stdoutEmpty: true},
{args: []string{"-s", "2"}, code: -1, stderrContains: "2 %", stdoutContains: memReport},
{args: []string{"-s", "2"}, code: -1, stderrContains: " 2 %", stdoutContains: memReport},
// Using "-s 100" is a valid way to ignore swap usage
{args: []string{"-s", "100"}, code: -1, stderrContains: "100 %", stdoutContains: memReport},
{args: []string{"-s", "100"}, code: -1, stderrContains: " 100 %", stdoutContains: memReport},
{args: []string{"-s", "101"}, code: 16, stderrContains: "invalid percentage", stdoutEmpty: true},
{args: []string{"-s", "0"}, code: 16, stderrContains: "invalid percentage", stdoutEmpty: true},
{args: []string{"-s", "-10"}, code: 16, stderrContains: "invalid percentage", stdoutEmpty: true},
{args: []string{"-M", mem1percent}, code: -1, stderrContains: "min: 1 %", stdoutContains: memReport},
{args: []string{"-M", mem1percent}, code: -1, stderrContains: " 1 %", stdoutContains: memReport},
{args: []string{"-M", "9999999999999999"}, code: 15, stderrContains: "at or above total memory", stdoutEmpty: true},
{args: []string{"-S", "9999999999999999"}, code: 16, stderrContains: "above total swap", stdoutEmpty: true},
{args: []string{"-r", "0"}, code: -1, stderrContains: startupMsg, stdoutEmpty: true},
Expand All @@ -98,7 +98,7 @@ func TestCli(t *testing.T) {
}
if swapTotal > 0 {
// Test cannot work when there is no swap enabled
tc := cliTestCase{args: []string{"-S", swap2percent}, code: -1, stderrContains: "min: 2 %", stdoutContains: memReport}
tc := cliTestCase{args: []string{"-S", swap2percent}, code: -1, stderrContains: " 2 %", stdoutContains: memReport}
testcases = append(testcases, tc)
}

Expand Down

0 comments on commit 5f796f9

Please sign in to comment.