99
1010 "github.com/apache/arrow/go/v12/arrow"
1111 "github.com/apache/arrow/go/v12/arrow/array"
12- "github.com/apache/arrow/go/v12/arrow/memory"
1312 "github.com/cloudquery/plugin-sdk/v2/schema"
1413 "github.com/cloudquery/plugin-sdk/v2/specs"
1514 "github.com/cloudquery/plugin-sdk/v2/testdata"
@@ -22,7 +21,7 @@ func tableUUIDSuffix() string {
2221 return strings .ReplaceAll (uuid .NewString (), "-" , "_" )
2322}
2423
25- func testMigration (ctx context.Context , mem memory. Allocator , _ * testing.T , p * Plugin , logger zerolog.Logger , spec specs.Destination , target * arrow.Schema , source * arrow.Schema , mode specs.MigrateMode ) error {
24+ func testMigration (ctx context.Context , _ * testing.T , p * Plugin , logger zerolog.Logger , spec specs.Destination , target * arrow.Schema , source * arrow.Schema , mode specs.MigrateMode ) error {
2625 if err := p .Init (ctx , logger , spec ); err != nil {
2726 return fmt .Errorf ("failed to init plugin: %w" , err )
2827 }
@@ -41,19 +40,15 @@ func testMigration(ctx context.Context, mem memory.Allocator, _ *testing.T, p *P
4140 SyncTime : syncTime ,
4241 MaxRows : 1 ,
4342 }
44- resource1 := testdata .GenTestData (mem , source , opts )[0 ]
45- resource1 .Retain ()
46- defer resource1 .Release ()
43+ resource1 := testdata .GenTestData (source , opts )[0 ]
4744 if err := p .writeOne (ctx , sourceSpec , syncTime , resource1 ); err != nil {
4845 return fmt .Errorf ("failed to write one: %w" , err )
4946 }
5047
5148 if err := p .Migrate (ctx , []* arrow.Schema {target }); err != nil {
5249 return fmt .Errorf ("failed to migrate existing table: %w" , err )
5350 }
54- resource2 := testdata .GenTestData (mem , target , opts )[0 ]
55- resource2 .Retain ()
56- defer resource2 .Release ()
51+ resource2 := testdata .GenTestData (target , opts )[0 ]
5752 if err := p .writeOne (ctx , sourceSpec , syncTime , resource2 ); err != nil {
5853 return fmt .Errorf ("failed to write one after migration: %w" , err )
5954 }
@@ -85,7 +80,6 @@ func testMigration(ctx context.Context, mem memory.Allocator, _ *testing.T, p *P
8580
8681func (* PluginTestSuite ) destinationPluginTestMigrate (
8782 ctx context.Context ,
88- mem memory.Allocator ,
8983 t * testing.T ,
9084 newPlugin NewPluginFunc ,
9185 logger zerolog.Logger ,
@@ -117,7 +111,7 @@ func (*PluginTestSuite) destinationPluginTestMigrate(
117111 }, & md )
118112
119113 p := newPlugin ()
120- if err := testMigration (ctx , mem , t , p , logger , spec , target , source , strategy .AddColumn ); err != nil {
114+ if err := testMigration (ctx , t , p , logger , spec , target , source , strategy .AddColumn ); err != nil {
121115 t .Fatalf ("failed to migrate %s: %v" , tableName , err )
122116 }
123117 if err := p .Close (ctx ); err != nil {
@@ -147,7 +141,7 @@ func (*PluginTestSuite) destinationPluginTestMigrate(
147141 {Name : "bool" , Type : arrow .FixedWidthTypes .Boolean },
148142 }, & md )
149143 p := newPlugin ()
150- if err := testMigration (ctx , mem , t , p , logger , spec , target , source , strategy .AddColumnNotNull ); err != nil {
144+ if err := testMigration (ctx , t , p , logger , spec , target , source , strategy .AddColumnNotNull ); err != nil {
151145 t .Fatalf ("failed to migrate add_column_not_null: %v" , err )
152146 }
153147 if err := p .Close (ctx ); err != nil {
@@ -177,7 +171,7 @@ func (*PluginTestSuite) destinationPluginTestMigrate(
177171 }, & md )
178172
179173 p := newPlugin ()
180- if err := testMigration (ctx , mem , t , p , logger , spec , target , source , strategy .RemoveColumn ); err != nil {
174+ if err := testMigration (ctx , t , p , logger , spec , target , source , strategy .RemoveColumn ); err != nil {
181175 t .Fatalf ("failed to migrate remove_column: %v" , err )
182176 }
183177 if err := p .Close (ctx ); err != nil {
@@ -207,7 +201,7 @@ func (*PluginTestSuite) destinationPluginTestMigrate(
207201 }, & md )
208202
209203 p := newPlugin ()
210- if err := testMigration (ctx , mem , t , p , logger , spec , target , source , strategy .RemoveColumnNotNull ); err != nil {
204+ if err := testMigration (ctx , t , p , logger , spec , target , source , strategy .RemoveColumnNotNull ); err != nil {
211205 t .Fatalf ("failed to migrate remove_column_not_null: %v" , err )
212206 }
213207 if err := p .Close (ctx ); err != nil {
@@ -238,7 +232,7 @@ func (*PluginTestSuite) destinationPluginTestMigrate(
238232 }, & md )
239233
240234 p := newPlugin ()
241- if err := testMigration (ctx , mem , t , p , logger , spec , target , source , strategy .ChangeColumn ); err != nil {
235+ if err := testMigration (ctx , t , p , logger , spec , target , source , strategy .ChangeColumn ); err != nil {
242236 t .Fatalf ("failed to migrate change_column: %v" , err )
243237 }
244238 if err := p .Close (ctx ); err != nil {
0 commit comments