Files
grafana/pkg/services/store/entity/sqlstash/sqltemplate/args_test.go
T
Diego Augusto Molina cbcd945251 Unified Storage: in SQL template, also handle output data, improve API, examples and docs (#87560)
* preview of work so far

* stylistic improvements

* fix linters

* remove golden tests, they may cause the system to be too rigid to changes

* remove unnecessary code for golden tests

* remove white space mangling in Execute

* also handle output data, improve API, examples and docs

* add helper methods

* fix interface
2024-05-14 12:32:21 -03:00

33 lines
611 B
Go

package sqltemplate
import "testing"
func TestArgs_Arg(t *testing.T) {
t.Parallel()
shouldBeQuestionMark := func(t *testing.T, s string) {
t.Helper()
if s != "?" {
t.Fatalf("expecting question mark, got %q", s)
}
}
a := new(Args)
shouldBeQuestionMark(t, a.Arg(0))
shouldBeQuestionMark(t, a.Arg(1))
shouldBeQuestionMark(t, a.Arg(2))
shouldBeQuestionMark(t, a.Arg(3))
shouldBeQuestionMark(t, a.Arg(4))
for i, arg := range a.GetArgs() {
v, ok := arg.(int)
if !ok {
t.Fatalf("unexpected value: %T(%v)", arg, arg)
}
if v != i {
t.Fatalf("unexpected int value: %v", v)
}
}
}