Skip to content

Commit

Permalink
Add negative case for testing keyValuesFromLine
Browse files Browse the repository at this point in the history
  • Loading branch information
chansuke committed Oct 17, 2023
1 parent 81297df commit 50159d4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/kv/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,19 @@ func TestKeyValuesFromLines(t *testing.T) {
},
expectedErr: false,
},
// TODO: add negative testcases
{
desc: "invalid UTF-8 content",
content: "Invalid UTF8 Content: \x80\x81",
expectedPairs: nil,
expectedErr: true,
},
}

kvl := makeKvLoader(filesys.MakeFsInMemory())
for _, test := range tests {
pairs, err := kvl.keyValuesFromLines([]byte(test.content))
if test.expectedErr && err == nil {
t.Fatalf("%s should not return error", test.desc)
t.Fatalf("%s should return error", test.desc)
}
if !reflect.DeepEqual(pairs, test.expectedPairs) {
t.Errorf("%s should succeed, got:%v exptected:%v", test.desc, pairs, test.expectedPairs)
Expand Down

0 comments on commit 50159d4

Please sign in to comment.