Skip to content

Commit f13e4cc

Browse files
authored
fix: Check record data in tests (#1062)
This adds back assertions on the record data in destination writer tests. I'm not sure if we also need to handle ordering somehow here, but I think we can follow up with a fix for that if necessary.
1 parent f5d01c9 commit f13e4cc

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

plugin/testing_upsert.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ func (s *WriterTestSuite) testUpsertBasic(ctx context.Context) error {
6060
if totalItems != 1 {
6161
return fmt.Errorf("expected 1 item, got %d", totalItems)
6262
}
63-
63+
if diff := RecordDiff(records[0], record); diff != "" {
64+
return fmt.Errorf("record differs: %s", diff)
65+
}
6466
return nil
6567
}
6668

@@ -108,5 +110,9 @@ func (s *WriterTestSuite) testUpsertAll(ctx context.Context) error {
108110
return fmt.Errorf("expected 1 item, got %d", totalItems)
109111
}
110112

113+
if diff := RecordDiff(records[0], record); diff != "" {
114+
return fmt.Errorf("record differs: %s", diff)
115+
}
116+
111117
return nil
112118
}

plugin/testing_write_delete.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ func (s *WriterTestSuite) testDeleteStale(ctx context.Context) error {
6969
if totalItems != 1 {
7070
return fmt.Errorf("expected 1 item, got %d", totalItems)
7171
}
72-
72+
if diff := RecordDiff(records[0], record); diff != "" {
73+
return fmt.Errorf("record differs: %s", diff)
74+
}
7375
return nil
7476
}

plugin/testing_write_insert.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ func (s *WriterTestSuite) testInsertBasic(ctx context.Context) error {
6969
return fmt.Errorf("expected 2 items, got %d", totalItems)
7070
}
7171

72+
if diff := RecordDiff(readRecords[0], record); diff != "" {
73+
return fmt.Errorf("record[0] differs: %s", diff)
74+
}
75+
if diff := RecordDiff(readRecords[1], record); diff != "" {
76+
return fmt.Errorf("record[1] differs: %s", diff)
77+
}
78+
7279
return nil
7380
}
7481

@@ -115,6 +122,11 @@ func (s *WriterTestSuite) testInsertAll(ctx context.Context) error {
115122
if totalItems != 2 {
116123
return fmt.Errorf("expected 2 items, got %d", totalItems)
117124
}
118-
125+
if diff := RecordDiff(readRecords[0], record); diff != "" {
126+
return fmt.Errorf("record[0] differs: %s", diff)
127+
}
128+
if diff := RecordDiff(readRecords[1], record); diff != "" {
129+
return fmt.Errorf("record[1] differs: %s", diff)
130+
}
119131
return nil
120132
}

plugin/testing_write_migrate.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,20 @@ func (s *WriterTestSuite) migrate(ctx context.Context, target *schema.Table, sou
7878
if totalItems != 2 {
7979
return fmt.Errorf("expected 2 items, got %d", totalItems)
8080
}
81+
if diff := RecordDiff(records[0], resource1); diff != "" {
82+
return fmt.Errorf("records[0] differs: %s", diff)
83+
}
84+
if diff := RecordDiff(records[1], resource2); diff != "" {
85+
return fmt.Errorf("records[1] differs: %s", diff)
86+
}
8187
} else {
8288
totalItems = TotalRows(records)
8389
if totalItems != 1 {
8490
return fmt.Errorf("expected 1 item, got %d", totalItems)
8591
}
92+
if diff := RecordDiff(records[0], resource2); diff != "" {
93+
return fmt.Errorf("records[0] differs: %s", diff)
94+
}
8695
}
8796

8897
return nil

0 commit comments

Comments
 (0)