MCPcopy
hub / github.com/pocketbase/pocketbase / TestDateTimeCompare

Function TestDateTimeCompare

tools/types/datetime_test.go:195–228  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

193}
194
195func TestDateTimeCompare(t *testing.T) {
196 t.Parallel()
197
198 d1, _ := types.ParseDateTime("2024-01-01 10:00:00.123Z")
199 d2, _ := types.ParseDateTime("2024-01-02 10:00:00.123Z")
200 d3, _ := types.ParseDateTime("2024-01-03 10:00:00.123Z")
201
202 scenarios := []struct {
203 a types.DateTime
204 b types.DateTime
205 expect int
206 }{
207 // d1
208 {d1, d1, 0},
209 {d1, d2, -1},
210 {d1, d3, -1},
211 // d2
212 {d2, d1, 1},
213 {d2, d2, 0},
214 {d2, d3, -1},
215 // d3
216 {d3, d1, 1},
217 {d3, d2, 1},
218 {d3, d3, 0},
219 }
220
221 for i, s := range scenarios {
222 t.Run(fmt.Sprintf("compare_%d", i), func(t *testing.T) {
223 if v := s.a.Compare(s.b); v != s.expect {
224 t.Fatalf("Expected %v, got %v", s.expect, v)
225 }
226 })
227 }
228}
229
230func TestDateTimeEqual(t *testing.T) {
231 t.Parallel()

Callers

nothing calls this directly

Calls 3

ParseDateTimeFunction · 0.92
CompareMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…