mirror of https://github.com/VinGarcia/ksql.git
Add error message for structs with no ksql tags
parent
b63990c9f6
commit
d9f9d27266
|
@ -272,10 +272,12 @@ func getTagNames(t reflect.Type) (StructInfo, error) {
|
|||
})
|
||||
}
|
||||
|
||||
if len(info.byIndex) > 0 {
|
||||
info.IsNestedStruct = true
|
||||
if len(info.byIndex) == 0 {
|
||||
return StructInfo{}, fmt.Errorf("the struct must contain at least one attribute with the ksql tag")
|
||||
}
|
||||
|
||||
info.IsNestedStruct = true
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,18 @@ func TestStructToMap(t *testing.T) {
|
|||
|
||||
assert.NotEqual(t, nil, err)
|
||||
})
|
||||
|
||||
t.Run("should return error for structs with no ksql tags", func(t *testing.T) {
|
||||
_, err := StructToMap(struct {
|
||||
Name string
|
||||
Age int `json:"age"`
|
||||
}{
|
||||
Name: "fake-name",
|
||||
Age: 42,
|
||||
})
|
||||
|
||||
assert.NotEqual(t, nil, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestFillStructWith(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue