-
Notifications
You must be signed in to change notification settings - Fork 0
/
properties_test.go
49 lines (38 loc) · 1.07 KB
/
properties_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package dalgo2datastore
import (
"cloud.google.com/go/datastore"
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestIsEmptyJson(t *testing.T) {
t.Parallel()
//is := is.New(t)
p := datastore.Property{
Name: "TestProp1",
Value: nil,
NoIndex: true,
}
assert.True(t, IsEmptyJSON(p)) // nil should be treated as empty string
p.Value = ""
assert.True(t, IsEmptyJSON(p)) // Empty string should return true"
p.Value = "[]"
assert.True(t, IsEmptyJSON(p)) // Empty string should return true"
p.Value = "{}"
assert.True(t, IsEmptyJSON(p)) // Empty string should return true"
p.Value = "0"
assert.False(t, IsEmptyJSON(p)) // '0' string should return false"
}
func TestIsZeroTime(t *testing.T) {
t.Parallel()
p := datastore.Property{
Name: "TestProp1",
Value: nil,
NoIndex: true,
}
assert.True(t, IsZeroTime(p)) // nil should be treated as zero value
p.Value = time.Time{}
assert.True(t, IsZeroTime(p)) // should return true for zero value
p.Value = time.Now()
assert.False(t, IsZeroTime(p)) // string should return false for time.Now()
}