github.com/goravel/framework@v1.13.9/database/gorm/utils_test.go (about) 1 package gorm 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestCopyStruct(t *testing.T) { 10 type Data struct { 11 Name string 12 age int 13 } 14 15 data := copyStruct(Data{Name: "name", age: 18}) 16 17 assert.Equal(t, "name", data.Field(0).Interface().(string)) 18 assert.Panics(t, func() { 19 data.Field(1).Interface() 20 }) 21 }