From c4b54331555219f892c72bd7a7c26eee6879a563 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 18 Mar 2024 14:02:02 +0800 Subject: [PATCH] Fix test --- tests/types_test.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/types_test.go b/tests/types_test.go index e06a3be8..bb07aeaf 100644 --- a/tests/types_test.go +++ b/tests/types_test.go @@ -635,12 +635,14 @@ func (d *ZDecimal) FromDB(data []byte) error { func (d ZDecimal) ToDB() ([]byte, error) { return []byte(fmt.Sprintf("%d", (d.value).Int64())), nil } + func (d ZDecimal) IsZero() bool { if d.value == nil { return true } return d.value.Sign() == 0 } + func (d ZDecimal) String() string { if d.value == nil { return "0" @@ -649,16 +651,16 @@ func (d ZDecimal) String() string { } func TestZDecimal(t *testing.T) { - type MyMoney struct { + type ZMyMoney struct { Id int64 Account string Amount ZDecimal } assert.NoError(t, PrepareEngine()) - assertSync(t, new(MyMoney)) + assertSync(t, new(ZMyMoney)) - _, err := testEngine.Insert(&MyMoney{ + _, err := testEngine.Insert(&ZMyMoney{ Account: "test", Amount: ZDecimal{ value: big.NewInt(10000000000000000), @@ -666,19 +668,19 @@ func TestZDecimal(t *testing.T) { }) assert.NoError(t, err) - var m = MyMoney{ + m := ZMyMoney{ Id: 1, } has, err := testEngine.Get(&m) assert.NoError(t, err) assert.True(t, has) - _, err = testEngine.Update(&MyMoney{ + _, err = testEngine.Update(&ZMyMoney{ Id: 1, Account: "test2", }) assert.NoError(t, err) - var m2 = MyMoney{ + m2 := ZMyMoney{ Id: 1, } has, err = testEngine.Get(&m2) @@ -688,5 +690,4 @@ func TestZDecimal(t *testing.T) { assert.Equal(t, "test2", "test2") assert.False(t, m.Amount.IsZero()) assert.Equal(t, "10000000000000000", m.Amount.String()) - }