MCPcopy
hub / github.com/sqlc-dev/sqlc / TestSelector

Function TestSelector

internal/compiler/selector_test.go:5–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3import "testing"
4
5func TestSelector(t *testing.T) {
6 t.Parallel()
7
8 selectorExpectColumnExpr := func(t *testing.T, selector selector, expected, name string, column *Column) {
9 if actual := selector.ColumnExpr(name, column); expected != actual {
10 t.Errorf("Expected %v, got %v for data type %v", expected, actual, column.DataType)
11 }
12 }
13
14 t.Run("DefaultSelectorColumnExpr", func(t *testing.T) {
15 t.Parallel()
16
17 selector := newDefaultSelector()
18
19 selectorExpectColumnExpr(t, selector, "my_column", "my_column", &Column{DataType: "integer"})
20 selectorExpectColumnExpr(t, selector, "my_column", "my_column", &Column{DataType: "json"})
21 selectorExpectColumnExpr(t, selector, "my_column", "my_column", &Column{DataType: "jsonb"})
22 selectorExpectColumnExpr(t, selector, "my_column", "my_column", &Column{DataType: "text"})
23 })
24
25 t.Run("SQLiteSelectorColumnExpr", func(t *testing.T) {
26 t.Parallel()
27
28 selector := newSQLiteSelector()
29
30 selectorExpectColumnExpr(t, selector, "my_column", "my_column", &Column{DataType: "integer"})
31 selectorExpectColumnExpr(t, selector, "my_column", "my_column", &Column{DataType: "json"})
32 selectorExpectColumnExpr(t, selector, "json(my_column)", "my_column", &Column{DataType: "jsonb"})
33 selectorExpectColumnExpr(t, selector, "my_column", "my_column", &Column{DataType: "text"})
34 })
35}

Callers

nothing calls this directly

Calls 3

newDefaultSelectorFunction · 0.85
newSQLiteSelectorFunction · 0.85
ColumnExprMethod · 0.65

Tested by

no test coverage detected