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

Function TestTemporalStore_IntervalLimit

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

Source from the content-addressed store, hash-verified

100}
101
102func TestTemporalStore_IntervalLimit(t *testing.T) {
103 // Use a small custom limit for faster testing
104 customLimit := 100
105 store := NewTemporalStore(WithMaxIntervalsPerAtom(customLimit))
106 atom := ast.NewAtom("test", name("/foo"))
107
108 // Add intervals up to the limit
109 for i := 0; i < customLimit; i++ {
110 start := time.Date(2020, 1, 1, i, 0, 0, 0, time.UTC)
111 end := time.Date(2020, 1, 1, i, 59, 59, 0, time.UTC)
112 added, err := store.Add(atom, ast.TimeInterval(start, end))
113 if err != nil {
114 t.Fatalf("Add %d returned unexpected error: %v", i, err)
115 }
116 if !added {
117 t.Fatalf("Add %d should return true", i)
118 }
119 }
120
121 // Next add should fail with ErrIntervalLimitExceeded
122 start := time.Date(2020, 1, 1, customLimit, 0, 0, 0, time.UTC)
123 end := time.Date(2020, 1, 1, customLimit, 59, 59, 0, time.UTC)
124 added, err := store.Add(atom, ast.TimeInterval(start, end))
125 if !errors.Is(err, ErrIntervalLimitExceeded) {
126 t.Errorf("Add beyond limit: err = %v, want ErrIntervalLimitExceeded", err)
127 }
128 if added {
129 t.Error("Add beyond limit should return false")
130 }
131}
132
133func TestTemporalStore_NoLimit(t *testing.T) {
134 // Negative limit means no limit

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected