Skip to content

Commit

Permalink
Merge pull request #1658 from quyi1993/quyi_test
Browse files Browse the repository at this point in the history
test: add unit test for function ValidateOOMScore in oom_score_test.go
  • Loading branch information
allencloud authored Jul 13, 2018
2 parents 1b45a43 + 1c1c160 commit 6756ca7
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion apis/opts/oom_score_test.go
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)
}
}

0 comments on commit 6756ca7

Please sign in to comment.