File: jsonb_array_test.go

package info (click to toggle)
golang-github-jackc-pgtype 1.10.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,656 kB
  • sloc: sh: 32; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 924 bytes parent folder | download
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
package pgtype_test

import (
	"testing"

	"github.com/jackc/pgtype"
	"github.com/jackc/pgtype/testutil"
)

func TestJSONBArrayTranscode(t *testing.T) {
	testutil.TestSuccessfulTranscode(t, "jsonb[]", []interface{}{
		&pgtype.JSONBArray{
			Elements:   nil,
			Dimensions: nil,
			Status:     pgtype.Present,
		},
		&pgtype.JSONBArray{
			Elements: []pgtype.JSONB{
				{Bytes: []byte(`"foo"`), Status: pgtype.Present},
				{Status: pgtype.Null},
			},
			Dimensions: []pgtype.ArrayDimension{{Length: 2, LowerBound: 1}},
			Status:     pgtype.Present,
		},
		&pgtype.JSONBArray{Status: pgtype.Null},
		&pgtype.JSONBArray{
			Elements: []pgtype.JSONB{
				{Bytes: []byte(`"foo"`), Status: pgtype.Present},
				{Bytes: []byte("null"), Status: pgtype.Present},
				{Bytes: []byte("42"), Status: pgtype.Present},
			},
			Dimensions: []pgtype.ArrayDimension{{Length: 3, LowerBound: 1}},
			Status:     pgtype.Present,
		},
	})
}