MCPcopy
hub / github.com/grafana/tempo / TestStatic_Duration

Function TestStatic_Duration

pkg/traceql/ast_test.go:192–225  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

190}
191
192func TestStatic_Duration(t *testing.T) {
193 tests := []struct {
194 arg any
195 ok bool
196 }{
197 // supported values
198 {arg: time.Duration(0), ok: true},
199 {arg: time.Duration(1), ok: true},
200 {arg: time.Duration(100) * time.Second, ok: true},
201 // unsupported values
202 {arg: 1},
203 {arg: 3.14},
204 {arg: "test"},
205 {arg: true},
206 {arg: StatusOk},
207 {arg: KindClient},
208 {arg: []int{1, 2, 3}},
209 {arg: []float64{1.0, 2.2}},
210 {arg: []bool{true, true}},
211 {arg: []string{"aa", "bb"}},
212 }
213
214 for _, tt := range tests {
215 t.Run(testName(tt.arg), func(t *testing.T) {
216 static := newStatic(tt.arg)
217 d, ok := static.Duration()
218
219 require.Equal(t, tt.ok, ok)
220 if tt.ok {
221 assert.Equal(t, tt.arg, d)
222 }
223 })
224 }
225}
226
227func TestStatic_Status(t *testing.T) {
228 tests := []struct {

Callers

nothing calls this directly

Calls 5

testNameFunction · 0.85
newStaticFunction · 0.85
DurationMethod · 0.80
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected