MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / writeManyRows

Function writeManyRows

plugins/destination/mysql/client/client_test.go:54–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52}
53
54func writeManyRows() error {
55 ctx := context.Background()
56 p := plugin.NewPlugin("mysql", "development", New)
57 s := &Spec{
58 ConnectionString: getConnectionString(),
59 }
60 specBytes, err := json.Marshal(s)
61 if err != nil {
62 return err
63 }
64 if err := p.Init(ctx, specBytes, plugin.NewClientOptions{}); err != nil {
65 return err
66 }
67
68 const numberOfTables = 5
69 const recordsPerTable = 20
70 msgs := make([]message.WriteMessage, 0)
71 for i := 0; i < numberOfTables; i++ {
72 tableName := fmt.Sprintf("table_%d", i)
73 table := schema.TestTable(tableName, schema.TestSourceOptions{})
74 table.Columns = append(table.Columns, schema.Column{Name: "name", Type: arrow.BinaryTypes.String, PrimaryKey: true})
75 msgs = append(msgs, &message.WriteMigrateTable{Table: table})
76
77 tg := schema.NewTestDataGenerator(0)
78 for i := 0; i < recordsPerTable; i++ {
79 record := tg.Generate(table, schema.GenTestDataOptions{
80 MaxRows: 50,
81 })
82 msgs = append(msgs, &message.WriteInsert{Record: record})
83 }
84 }
85
86 err = p.WriteAll(ctx, msgs)
87 return err
88}
89
90func TestWriteManyRows(t *testing.T) {
91 err := writeManyRows()

Callers 1

TestWriteManyRowsFunction · 0.85

Calls 2

getConnectionStringFunction · 0.85
GenerateMethod · 0.80

Tested by

no test coverage detected