@@ -47,6 +47,26 @@ func Test_parseColumnChange(t *testing.T) {
4747 }
4848}
4949
50+ func Test_parsePKChange (t * testing.T ) {
51+ type args struct {
52+ line string
53+ }
54+ tests := []struct {
55+ name string
56+ args args
57+ wantNames []string
58+ }{
59+ {name : "PK present" , args : args {line : "The composite primary key for this table is (**org**, **id**, **hook_id**)." }, wantNames : []string {"org" , "id" , "hook_id" }},
60+ {name : "no PK" , args : args {}, wantNames : nil },
61+ }
62+ for _ , tt := range tests {
63+ t .Run (tt .name , func (t * testing.T ) {
64+ gotNames := parsePKChange (tt .args .line )
65+ require .Equal (t , tt .wantNames , gotNames )
66+ })
67+ }
68+ }
69+
5070func Test_getChanges (t * testing.T ) {
5171 tests := []struct {
5272 name string
@@ -201,6 +221,96 @@ func Test_getChanges(t *testing.T) {
201221 },
202222 },
203223 },
224+ {
225+ name : "Should mark PK order change as breaking" ,
226+ diffDataFile : "testdata/pr_6012_diff.txt" ,
227+ wantChanges : []change {
228+ {
229+ Text : "Table `github_external_groups`: column order changed for `updated_at`" ,
230+ Breaking : false ,
231+ },
232+ {
233+ Text : "Table `github_hook_deliveries`: primary key order changed from `org, id, hook_id` to `org, hook_id, id`" ,
234+ Breaking : true ,
235+ },
236+ {
237+ Text : "Table `github_hook_deliveries`: column order changed for `delivered_at`" ,
238+ Breaking : false ,
239+ },
240+ {
241+ Text : "Table `github_hook_deliveries`: column order changed for `id`" ,
242+ Breaking : false ,
243+ },
244+ {
245+ Text : "Table `github_hooks`: column order changed for `id`" ,
246+ Breaking : false ,
247+ },
248+ {
249+ Text : "Table `github_issues`: column added with name `state_reason` and type `String`" ,
250+ Breaking : false ,
251+ },
252+ {
253+ Text : "Table `github_organization_members`: column order changed for `id`" ,
254+ Breaking : false ,
255+ },
256+ {
257+ Text : "Table `github_organizations`: column order changed for `id`" ,
258+ Breaking : false ,
259+ },
260+ {
261+ Text : "Table `github_repositories`: column added with name `has_discussions` and type `Bool`" ,
262+ Breaking : false ,
263+ },
264+ {
265+ Text : "Table `github_repositories`: column order changed for `created_at`" ,
266+ Breaking : false ,
267+ },
268+ {
269+ Text : "Table `github_repositories`: column order changed for `pushed_at`" ,
270+ Breaking : false ,
271+ },
272+ {
273+ Text : "Table `github_repositories`: column order changed for `updated_at`" ,
274+ Breaking : false ,
275+ },
276+ {
277+ Text : "Table `github_team_members`: primary key order changed from `org, id, team_id` to `org, team_id, id`" ,
278+ Breaking : true ,
279+ },
280+ {
281+ Text : "Table `github_team_members`: column order changed for `id`" ,
282+ Breaking : false ,
283+ },
284+ {
285+ Text : "Table `github_team_repositories`: primary key order changed from `org, id, team_id` to `org, team_id, id`" ,
286+ Breaking : true ,
287+ },
288+ {
289+ Text : "Table `github_team_repositories`: column added with name `has_discussions` and type `Bool`" ,
290+ Breaking : false ,
291+ },
292+ {
293+ Text : "Table `github_team_repositories`: column order changed for `created_at`" ,
294+ Breaking : false ,
295+ },
296+ {
297+ Text : "Table `github_team_repositories`: column order changed for `id`" ,
298+ Breaking : false ,
299+ },
300+ {
301+ Text : "Table `github_team_repositories`: column order changed for `pushed_at`" ,
302+ Breaking : false ,
303+ },
304+ {
305+ Text : "Table `github_team_repositories`: column order changed for `updated_at`" ,
306+ Breaking : false ,
307+ },
308+ {
309+ Text : "Table `github_workflows`: column order changed for `id`" ,
310+ Breaking : false ,
311+ },
312+ },
313+ },
204314 }
205315 for _ , tt := range tests {
206316 t .Run (tt .name , func (t * testing.T ) {
0 commit comments