MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / TestParseQueryParams

Function TestParseQueryParams

internal/metadata/meta_test.go:56–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func TestParseQueryParams(t *testing.T) {
57 for _, comments := range [][]string{
58 {
59 " name: CreateFoo :one",
60 " @param foo_id UUID",
61 },
62 {
63 " name: CreateFoo :one ",
64 " @param foo_id UUID ",
65 },
66 {
67 " name: CreateFoo :one",
68 "@param foo_id UUID",
69 " invalid",
70 },
71 {
72 " name: CreateFoo :one",
73 " @invalid",
74 " @param foo_id UUID",
75 },
76 {
77 " name: GetFoos :many ",
78 " @param foo_id UUID ",
79 " @param @invalid UUID ",
80 },
81 } {
82 params, _, _, err := ParseCommentFlags(comments)
83 if err != nil {
84 t.Errorf("expected comments to parse, got err: %s", err)
85 }
86
87 pt, ok := params["foo_id"]
88 if !ok {
89 t.Errorf("expected param not found")
90 }
91
92 if pt != "UUID" {
93 t.Error("unexpected param metadata:", pt)
94 }
95
96 _, ok = params["invalid"]
97 if ok {
98 t.Errorf("unexpected param found")
99 }
100 }
101}
102
103func TestParseQueryFlags(t *testing.T) {
104 for _, comments := range [][]string{

Callers

nothing calls this directly

Calls 2

ParseCommentFlagsFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected