Skip to content

Commit

Permalink
rebase: master
Browse files Browse the repository at this point in the history
  • Loading branch information
lujinghao committed Apr 27, 2024
1 parent dc982b7 commit ddc9d5f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions executor/mysql/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type testDiffPO struct {
DiffPtrValue *int
SamePtrValue *int
SliceValue []string
SliceStruct []*NestStruct
JSONValue datatypes.JSON
SameJSONValue datatypes.JSON
StructValue *NestStruct `gorm:"type:json,serialize:json"`
Expand All @@ -62,6 +63,9 @@ func TestDiffModel(t *testing.T) {
NestStruct: NestStruct{
NestNum: 100,
},
SliceStruct: []*NestStruct{
{NestName: "test"},
},
ID: "p1",
Name: "n2",
ItemPrice: 100,
Expand All @@ -88,12 +92,15 @@ func TestDiffModel(t *testing.T) {
TestDiffBasePO: TestDiffBasePO{
UpdatedAt: now,
},
ID: "p2",
Name: "n2",
ItemPrice: 50,
DiffPtrValue: &j,
SamePtrValue: &i,
SliceValue: []string{"kkk"},
ID: "p2",
Name: "n2",
ItemPrice: 50,
DiffPtrValue: &j,
SamePtrValue: &i,
SliceValue: []string{"kkk"},
SliceStruct: []*NestStruct{
{NestName: "test2"},
},
JSONValue: datatypes.JSON([]byte(`{"a":2}`)),
SameJSONValue: datatypes.JSON([]byte(`{"a":1}`)),
StructValue: &NestStruct{
Expand All @@ -111,5 +118,5 @@ func TestDiffModel(t *testing.T) {
}

result := DiffModel(p1, p2)
assert.ElementsMatch(t, result, []string{"ID", "ItemPrice", "DiffPtrValue", "CreatedAt", "SliceValue", "JSONValue", "StructValue", "UpdatedAt", "EmptyStruct1", "EmptyStruct2", "NestNum"})
assert.ElementsMatch(t, result, []string{"ID", "ItemPrice", "DiffPtrValue", "CreatedAt", "SliceValue", "JSONValue", "StructValue", "UpdatedAt", "EmptyStruct1", "EmptyStruct2", "NestNum", "SliceStruct"})
}

0 comments on commit ddc9d5f

Please sign in to comment.