Test a struct tag's bare number or boolean typed by its Go type, and a column's refusal offering only a datatype that holds the number

This commit is contained in:
2026-10-08 11:54:29 +02:00
committed by Lillem4n
parent 8a8c915679
commit 9e392d02fd
2 changed files with 23 additions and 4 deletions
+11
View File
@@ -253,6 +253,17 @@ func TestFakeStructTakesTheDatatypeItsGoTypeSets(t *testing.T) {
}
}
func TestFakeStructTypesABareNumberOrBooleanByItsGoType(t *testing.T) {
v := struct {
N int `fake:"[5, 6]"`
B bool `fake:"[true, false]"`
S string `fake:"[7.50]"`
}{}
if err := structData(t).FakeStruct(&v); err != nil || (v.N != 5 && v.N != 6) || v.S != "7.50" {
t.Errorf("FakeStruct = %+v, %v, want each value typed by its field", v, err)
}
}
func TestFakeStructWithNoTagsFillsNothing(t *testing.T) {
v := struct{ A string }{A: "kept"}
if err := structData(t).FakeStruct(&v); err != nil || v.A != "kept" {