MCPcopy
hub / github.com/google/mangle / TestTemporalStore_Add

Function TestTemporalStore_Add

factstore/temporal_test.go:30–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestTemporalStore_Add(t *testing.T) {
31 store := NewTemporalStore()
32
33 atom := ast.NewAtom("employed", name("/alice"))
34 interval := ast.TimeInterval(
35 ast.Date(2020, 1, 1),
36 ast.Date(2023, 12, 31),
37 )
38
39 // First add should succeed
40 added, err := store.Add(atom, interval)
41 if err != nil {
42 t.Errorf("First Add returned error: %v", err)
43 }
44 if !added {
45 t.Error("First Add should return true")
46 }
47
48 // Duplicate add should fail
49 added, err = store.Add(atom, interval)
50 if err != nil {
51 t.Errorf("Duplicate Add returned error: %v", err)
52 }
53 if added {
54 t.Error("Duplicate Add should return false")
55 }
56
57 // Adding same atom with different interval should succeed
58 interval2 := ast.TimeInterval(
59 ast.Date(2024, 1, 1),
60 ast.Date(2024, 12, 31),
61 )
62 added, err = store.Add(atom, interval2)
63 if err != nil {
64 t.Errorf("Add with different interval returned error: %v", err)
65 }
66 if !added {
67 t.Error("Add with different interval should return true")
68 }
69
70 if store.EstimateFactCount() != 2 {
71 t.Errorf("EstimateFactCount = %d, want 2", store.EstimateFactCount())
72 }
73}
74
75func TestTemporalStore_AddEternal(t *testing.T) {
76 store := NewTemporalStore()

Callers

nothing calls this directly

Calls 8

AddMethod · 0.95
EstimateFactCountMethod · 0.95
NewAtomFunction · 0.92
TimeIntervalFunction · 0.92
DateFunction · 0.92
NewTemporalStoreFunction · 0.85
ErrorMethod · 0.80
nameFunction · 0.70

Tested by

no test coverage detected