Skip to content

Commit

Permalink
Make sure non-int/string types as CallVersion returns an error
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed May 7, 2021
1 parent 90da2d9 commit 53ea315
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions event/voip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,16 @@ func TestCallVersion_UnmarshalJSON(t *testing.T) {
err = json.Unmarshal([]byte(`"com.example.call.version"`), &version)
assert.NoError(t, err)
assert.Equal(t, event.CallVersion("com.example.call.version"), version)

err = json.Unmarshal([]byte(`1.234`), &version)
assert.Error(t, err)

err = json.Unmarshal([]byte(`false`), &version)
assert.Error(t, err)

err = json.Unmarshal([]byte(`["hmm"]`), &version)
assert.Error(t, err)

err = json.Unmarshal([]byte(`{"hmm": true}`), &version)
assert.Error(t, err)
}

0 comments on commit 53ea315

Please sign in to comment.