verify that an error is always returned if token.Valid is false (and the reverse)

This commit is contained in:
Dave Grijalva 2016-04-12 14:52:39 -07:00
parent 1b765952cc
commit c8d4fff6cc
1 changed files with 4 additions and 0 deletions

View File

@ -183,6 +183,10 @@ func TestParser_Parse(t *testing.T) {
t.Errorf("[%v] Invalid token passed validation", data.name) t.Errorf("[%v] Invalid token passed validation", data.name)
} }
if (err == nil && !token.Valid) || (err != nil && token.Valid) {
t.Errorf("[%v] Inconsistent behavior between returned error and token.Valid")
}
if data.errors != 0 { if data.errors != 0 {
if err == nil { if err == nil {
t.Errorf("[%v] Expecting error. Didn't get one.", data.name) t.Errorf("[%v] Expecting error. Didn't get one.", data.name)