From ce0fa5f249f864d5f2580fc659089618fd5fb313 Mon Sep 17 00:00:00 2001 From: "luman.qy" Date: Mon, 9 Jul 2018 20:44:46 +0800 Subject: [PATCH 1/2] oom_score_test.go --- apis/opts/oom_score_test.go | 43 ++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/apis/opts/oom_score_test.go b/apis/opts/oom_score_test.go index 2f82248a3..8b3d465ca 100644 --- a/apis/opts/oom_score_test.go +++ b/apis/opts/oom_score_test.go @@ -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: nil, + }, + { + input: 2000, + expected: fmt.Errorf("oom-score-adj should be in range [-1000, 1000]"), + }, + { + input: 200, + expected: fmt.Errorf("oom-score-adj should be in range [-1000, 1000]"), + }, + } + + for _, testCase := range testCases { + err := ValidateOOMScore(testCase.input) + assert.Equal(t, testCase.expected, err) + } } From 1c1c16087862f03f5dcd85c5638edd0e66f18db3 Mon Sep 17 00:00:00 2001 From: "luman.qy" Date: Tue, 10 Jul 2018 09:34:26 +0800 Subject: [PATCH 2/2] oom_score_test.go --- apis/opts/oom_score_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apis/opts/oom_score_test.go b/apis/opts/oom_score_test.go index 8b3d465ca..79046a98b 100644 --- a/apis/opts/oom_score_test.go +++ b/apis/opts/oom_score_test.go @@ -29,7 +29,7 @@ func TestValidateOOMScore(t *testing.T) { }, { input: -2000, - expected: nil, + expected: fmt.Errorf("oom-score-adj should be in range [-1000, 1000]"), }, { input: 2000, @@ -37,7 +37,7 @@ func TestValidateOOMScore(t *testing.T) { }, { input: 200, - expected: fmt.Errorf("oom-score-adj should be in range [-1000, 1000]"), + expected: nil, }, }