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

Function TestPartitionedDML

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

Source from the content-addressed store, hash-verified

716}
717
718func TestPartitionedDML(t *testing.T) {
719 if skipIntegrateTest {
720 t.Skip("Integration tests skipped")
721 }
722
723 ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second)
724 defer cancel()
725
726 session, tableId, tearDown := setup(t, ctx, []string{
727 "INSERT INTO [[TABLE]] (id, active) VALUES (1, false)",
728 })
729 defer tearDown()
730
731 stmt, err := BuildStatement(fmt.Sprintf("PARTITIONED UPDATE %s SET active = true WHERE true", tableId))
732 if err != nil {
733 t.Fatalf("invalid statement: %v", err)
734 }
735
736 if _, err := stmt.Execute(ctx, session); err != nil {
737 t.Fatalf("execution failed: %v", err)
738 }
739
740 selectStmt := spanner.NewStatement(fmt.Sprintf("SELECT active FROM %s", tableId))
741 var got bool
742 if err := session.client.Single().Query(ctx, selectStmt).Do(func(r *spanner.Row) error {
743 return r.Column(0, &got)
744 }); err != nil {
745 t.Fatalf("query failed: %v", err)
746 }
747 if want := true; want != got {
748 t.Errorf("PARTITIONED UPDATE was executed, but rows were not updated")
749 }
750}

Callers

nothing calls this directly

Calls 3

setupFunction · 0.85
BuildStatementFunction · 0.85
ExecuteMethod · 0.65

Tested by

no test coverage detected