Skip to content

Commit

Permalink
Add tests for arrys AsAnyValue
Browse files Browse the repository at this point in the history
  • Loading branch information
electron0zero committed Aug 13, 2024
1 parent bdd5620 commit b4adb74
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkg/traceql/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,38 @@ func TestStatic_AsAnyValue(t *testing.T) {
{NewStaticStatus(StatusOk), &v1.AnyValue{Value: &v1.AnyValue_StringValue{StringValue: "ok"}}},
{NewStaticKind(KindInternal), &v1.AnyValue{Value: &v1.AnyValue_StringValue{StringValue: "internal"}}},
{NewStaticNil(), &v1.AnyValue{Value: &v1.AnyValue_StringValue{StringValue: "nil"}}},
// Test for arrays
{
NewStaticIntArray([]int{1, 2}),
&v1.AnyValue{
Value: &v1.AnyValue_ArrayValue{
ArrayValue: &v1.ArrayValue{Values: []*v1.AnyValue{{Value: &v1.AnyValue_IntValue{IntValue: 1}}, {Value: &v1.AnyValue_IntValue{IntValue: 2}}}},
},
},
},
{
NewStaticFloatArray([]float64{1.1, 2.2}),
&v1.AnyValue{
Value: &v1.AnyValue_ArrayValue{
ArrayValue: &v1.ArrayValue{Values: []*v1.AnyValue{{Value: &v1.AnyValue_DoubleValue{DoubleValue: 1.1}}, {Value: &v1.AnyValue_DoubleValue{DoubleValue: 2.2}}}}},
},
},
{
NewStaticStringArray([]string{"foo", "bar"}),
&v1.AnyValue{
Value: &v1.AnyValue_ArrayValue{
ArrayValue: &v1.ArrayValue{Values: []*v1.AnyValue{{Value: &v1.AnyValue_StringValue{StringValue: "foo"}}, {Value: &v1.AnyValue_StringValue{StringValue: "bar"}}}},
},
},
},
{
NewStaticBooleanArray([]bool{true, false}),
&v1.AnyValue{
Value: &v1.AnyValue_ArrayValue{
ArrayValue: &v1.ArrayValue{Values: []*v1.AnyValue{{Value: &v1.AnyValue_BoolValue{BoolValue: true}}, {Value: &v1.AnyValue_BoolValue{BoolValue: false}}}},
},
},
},
}
for _, tc := range tt {
t.Run(fmt.Sprintf("%v", tc.s), func(t *testing.T) {
Expand Down

0 comments on commit b4adb74

Please sign in to comment.