MCPcopy Index your code
hub / github.com/cloudspannerecosystem/spanner-cli / TestDecodeColumn

Function TestDecodeColumn

decoder_test.go:80–463  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func TestDecodeColumn(t *testing.T) {
81 tests := []struct {
82 desc string
83 value interface{}
84 want string
85 }{
86 // non-nullable
87 {
88 desc: "bool",
89 value: true,
90 want: "true",
91 },
92 {
93 desc: "bytes",
94 value: []byte{'a', 'b', 'c', 'd'},
95 want: "YWJjZA==", // base64 encoded 'abc'
96 },
97 {
98 desc: "float32",
99 value: float32(1.23),
100 want: "1.230000",
101 },
102 {
103 desc: "float64",
104 value: 1.23,
105 want: "1.230000",
106 },
107 {
108 desc: "int64",
109 value: 123,
110 want: "123",
111 },
112 {
113 desc: "numeric",
114 value: big.NewRat(123, 100),
115 want: "1.23",
116 },
117 {
118 desc: "string",
119 value: "foo",
120 want: "foo",
121 },
122 {
123 desc: "timestamp",
124 value: time.Unix(1516676400, 0),
125 want: "2018-01-23T03:00:00Z",
126 },
127 {
128 desc: "date",
129 value: civil.DateOf(time.Unix(1516676400, 0)),
130 want: "2018-01-23",
131 },
132 {
133 desc: "json",
134 value: spanner.NullJSON{Value: jsonMessage{Msg: "foo"}, Valid: true},
135 want: `{"msg":"foo"}`,
136 },
137 {

Callers

nothing calls this directly

Calls 2

DecodeColumnFunction · 0.85
createColumnValueFunction · 0.85

Tested by

no test coverage detected