Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Added default condition for unsupported type while creating literal (#…
Browse files Browse the repository at this point in the history
…124)

* Changed the String formatter from %s to %v and added more unit tests

Signed-off-by: pmahindrakar-oss <[email protected]>

* Added unsupported type default condition

Signed-off-by: pmahindrakar-oss <[email protected]>

Co-authored-by: pmahindrakar-oss <[email protected]>
  • Loading branch information
pmahindrakar-oss and pmahindrakar-oss authored Mar 17, 2021
1 parent 4f61bdf commit 334cd39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clients/go/coreutils/literals.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ func MakeLiteralForType(t *core.LiteralType, v interface{}) (*core.Literal, erro
return nil, err
}
return lv, nil
default:
return nil, fmt.Errorf("unsupported type %s", t.String())
}

return l, nil
}
10 changes: 10 additions & 0 deletions clients/go/coreutils/literals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,4 +515,14 @@ func TestMakeLiteralForType(t *testing.T) {
actualVal, _ := ExtractFromLiteral(val)
assert.Equal(t, expectedVal, actualVal)
})

t.Run("UnsupportedType", func(t *testing.T) {
var literalType = &core.LiteralType{Type: &core.LiteralType_Schema{
Schema: &core.SchemaType{}}}
var schema interface{}
_, err := MakeLiteralForType(literalType, schema)
expectedErrorf := fmt.Errorf("unsupported type schema:<> ")
assert.Equal(t, expectedErrorf, err)

})
}

0 comments on commit 334cd39

Please sign in to comment.