Skip to content

Commit 437ce25

Browse files
committed
add test
1 parent d23ed1e commit 437ce25

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

datamodel/spec_info_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ const (
2424
)
2525

2626
var (
27-
goodJSON = `{"name":"kitty", "noises":["meow","purrrr","gggrrraaaaaooooww"]}`
28-
badJSON = `{"name":"kitty, "noises":[{"meow","purrrr","gggrrraaaaaooooww"]}}`
29-
goodYAML = `name: kitty
27+
goodJSON = `{"name":"kitty", "noises":["meow","purrrr","gggrrraaaaaooooww"]}`
28+
badJSON = `{"name":"kitty, "noises":[{"meow","purrrr","gggrrraaaaaooooww"]}}`
29+
badJSONContainingComma = `{"openapi":"3.0.3","info":{"title":"Broken API Spec","version":"1.0.0"},"paths":{"/ping":{"get":{"summary":"Ping endpoint","responses":{"200":{"description":"OK",}}}}}}`
30+
goodYAML = `name: kitty
3031
noises:
3132
- meow
3233
- purrr
@@ -118,6 +119,11 @@ func TestExtractSpecInfo_InvalidJSON(t *testing.T) {
118119
assert.Error(t, e)
119120
}
120121

122+
func TestExtractSpecInfo_InvalidJSONContainingExtraComma(t *testing.T) {
123+
_, e := ExtractSpecInfo([]byte(badJSONContainingComma))
124+
assert.EqualError(t, e, "failed to parse specification: invalid character '}' looking for beginning of object key string")
125+
}
126+
121127
func TestExtractSpecInfo_Nothing(t *testing.T) {
122128
_, e := ExtractSpecInfo([]byte(""))
123129
assert.Error(t, e)

0 commit comments

Comments
 (0)