Add test about interface type array

This commit is contained in:
KEHyeon 2025-04-13 18:59:32 +09:00
parent b5d069300c
commit f5ac40e395

View File

@ -791,3 +791,15 @@ func TestCreateFromMapWithTable(t *testing.T) {
t.Errorf("failed to create data from map with table, @id != id") t.Errorf("failed to create data from map with table, @id != id")
} }
} }
func TestCreateWithInterfaceArrayType(t *testing.T) {
user := *GetUser("create", Config{})
type UserInterface interface{}
var userInterface UserInterface = &user
if results := DB.Create([]UserInterface{userInterface}); results.Error != nil {
t.Fatalf("errors happened when create: %v", results.Error)
} else if results.RowsAffected != 1 {
t.Fatalf("rows affected expects: %v, got %v", 1, results.RowsAffected)
}
}