MCPcopy Create free account
hub / github.com/uptrace/bun / TestArrayAppend

Function TestArrayAppend

dialect/pgdialect/array_test.go:13–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11}
12
13func TestArrayAppend(t *testing.T) {
14 tcases := []struct {
15 input any
16 out string
17 }{
18 {
19 input: []byte{1, 2},
20 out: `'{1,2}'`,
21 },
22 {
23 input: []*byte{ptr(byte(1)), ptr(byte(2))},
24 out: `'{1,2}'`,
25 },
26 {
27 input: []int{1, 2},
28 out: `'{1,2}'`,
29 },
30 {
31 input: []*int{ptr(1), ptr(2)},
32 out: `'{1,2}'`,
33 },
34 {
35 input: []string{"foo", "bar"},
36 out: `'{"foo","bar"}'`,
37 },
38 {
39 input: []*string{ptr("foo"), ptr("bar")},
40 out: `'{"foo","bar"}'`,
41 },
42 }
43
44 for _, tcase := range tcases {
45 out, err := Array(tcase.input).AppendQuery(schema.NewQueryGen(New()), []byte{})
46 if err != nil {
47 t.Fatal(err)
48 }
49
50 if string(out) != tcase.out {
51 t.Errorf("expected output to be %s, was %s", tcase.out, string(out))
52 }
53 }
54}

Callers

nothing calls this directly

Calls 5

NewQueryGenFunction · 0.92
ptrFunction · 0.85
ArrayFunction · 0.85
NewFunction · 0.70
AppendQueryMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…