MCPcopy Create free account
hub / github.com/cloudspannerecosystem/spanner-cli / TestSelect

Function TestSelect

integration_test.go:159–195  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

157}
158
159func TestSelect(t *testing.T) {
160 if skipIntegrateTest {
161 t.Skip("Integration tests skipped")
162 }
163
164 ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second)
165 defer cancel()
166
167 session, tableId, tearDown := setup(t, ctx, []string{
168 "INSERT INTO [[TABLE]] (id, active) VALUES (1, true), (2, false)",
169 })
170 defer tearDown()
171
172 stmt, err := BuildStatement(fmt.Sprintf("SELECT id, active FROM %s ORDER BY id ASC", tableId))
173 if err != nil {
174 t.Fatalf("invalid statement: error=%s", err)
175 }
176
177 result, err := stmt.Execute(ctx, session)
178 if err != nil {
179 t.Fatalf("unexpected error happened: %s", err)
180 }
181
182 compareResult(t, result, &Result{
183 ColumnNames: []string{"id", "active"},
184 Rows: []Row{
185 Row{[]string{"1", "true"}},
186 Row{[]string{"2", "false"}},
187 },
188 AffectedRows: 2,
189 ColumnTypes: []*pb.StructType_Field{
190 {Name: "id", Type: &pb.Type{Code: pb.TypeCode_INT64}},
191 {Name: "active", Type: &pb.Type{Code: pb.TypeCode_BOOL}},
192 },
193 IsMutation: false,
194 })
195}
196
197func TestDml(t *testing.T) {
198 if skipIntegrateTest {

Callers

nothing calls this directly

Calls 4

setupFunction · 0.85
BuildStatementFunction · 0.85
compareResultFunction · 0.85
ExecuteMethod · 0.65

Tested by

no test coverage detected