Unified Storage: Add SQL template package (#87524)

* added sqltemplate package

* addded example

* fix linting issues

* improve code readability

* fix documentation
This commit is contained in:
Diego Augusto Molina
2024-05-08 17:58:18 -03:00
committed by GitHub
parent 4b38253b20
commit acf17c7fb1
11 changed files with 535 additions and 0 deletions
@@ -0,0 +1,34 @@
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 {
v, ok := arg.(int)
if !ok {
t.Fatalf("unexpected value: %T(%v)", arg, arg)
}
if v != i {
t.Fatalf("unexpected int value: %v", v)
}
}
}