-
Notifications
You must be signed in to change notification settings - Fork 27
/
query.sql_test.go
58 lines (51 loc) · 1.28 KB
/
query.sql_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package nested
import (
"context"
"github.com/jschaf/pggen/internal/pgtest"
"github.com/stretchr/testify/assert"
"testing"
)
func TestNewQuerier_ArrayNested2(t *testing.T) {
conn, cleanup := pgtest.NewPostgresSchema(t, []string{"schema.sql"})
defer cleanup()
q := NewQuerier(conn)
ctx := context.Background()
want := []ProductImageType{
{Source: "img2", Dimensions: Dimensions{22, 22}},
{Source: "img3", Dimensions: Dimensions{33, 33}},
}
t.Run("ArrayNested2", func(t *testing.T) {
rows, err := q.ArrayNested2(ctx)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, want, rows)
})
}
func TestNewQuerier_Nested3(t *testing.T) {
conn, cleanup := pgtest.NewPostgresSchema(t, []string{"schema.sql"})
defer cleanup()
q := NewQuerier(conn)
ctx := context.Background()
want := []ProductImageSetType{
{
Name: "name",
OrigImage: ProductImageType{
Source: "img1",
Dimensions: Dimensions{Width: 11, Height: 11},
},
Images: []ProductImageType{
{Source: "img2", Dimensions: Dimensions{22, 22}},
{Source: "img3", Dimensions: Dimensions{33, 33}},
},
},
}
t.Run("Nested3", func(t *testing.T) {
t.Skipf("https://github.com/jackc/pgx/issues/874")
rows, err := q.Nested3(ctx)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, want, rows)
})
}