-
Notifications
You must be signed in to change notification settings - Fork 950
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1658 from quyi1993/quyi_test
test: add unit test for function ValidateOOMScore in oom_score_test.go
- Loading branch information
Showing
1 changed file
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,48 @@ | ||
package opts | ||
|
||
import "testing" | ||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestValidateOOMScore(t *testing.T) { | ||
// TODO | ||
type TestCase struct { | ||
input int64 | ||
expected error | ||
} | ||
|
||
testCases := []TestCase{ | ||
{ | ||
input: -1000, | ||
expected: nil, | ||
}, | ||
{ | ||
input: 1000, | ||
expected: nil, | ||
}, | ||
{ | ||
input: 0, | ||
expected: nil, | ||
}, | ||
{ | ||
input: -2000, | ||
expected: fmt.Errorf("oom-score-adj should be in range [-1000, 1000]"), | ||
}, | ||
{ | ||
input: 2000, | ||
expected: fmt.Errorf("oom-score-adj should be in range [-1000, 1000]"), | ||
}, | ||
{ | ||
input: 200, | ||
expected: nil, | ||
}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
err := ValidateOOMScore(testCase.input) | ||
assert.Equal(t, testCase.expected, err) | ||
} | ||
} |