@@ -243,4 +243,113 @@ query:
243243 assert .True (t , changes .GetChanges .TotalChanges () > 0 )
244244 assert .True (t , changes .PostChanges .TotalChanges () > 0 )
245245 assert .True (t , changes .QueryChanges .TotalChanges () > 0 )
246+ }
247+
248+ // TestPathItemChanges_QueryChangesNotNil ensures we hit the branches where QueryChanges is not nil
249+ // This test covers lines 63, 108, and 150 in path_item.go
250+ func TestPathItemChanges_QueryChangesNotNil (t * testing.T ) {
251+ // Create a PathItemChanges with QueryChanges present
252+ pc := & PathItemChanges {
253+ PropertyChanges : & PropertyChanges {
254+ Changes : []* Change {
255+ {
256+ ChangeType : PropertyAdded ,
257+ Property : "description" ,
258+ Breaking : false ,
259+ },
260+ },
261+ },
262+ QueryChanges : & OperationChanges {
263+ PropertyChanges : & PropertyChanges {
264+ Changes : []* Change {
265+ {
266+ ChangeType : Modified ,
267+ Property : "summary" ,
268+ Breaking : false ,
269+ },
270+ {
271+ ChangeType : PropertyRemoved ,
272+ Property : "operationId" ,
273+ Breaking : true ,
274+ },
275+ },
276+ },
277+ },
278+ TraceChanges : & OperationChanges {
279+ PropertyChanges : & PropertyChanges {
280+ Changes : []* Change {
281+ {
282+ ChangeType : Modified ,
283+ Property : "deprecated" ,
284+ Breaking : false ,
285+ },
286+ },
287+ },
288+ },
289+ }
290+
291+ // Test GetAllChanges() - this covers line 63 where QueryChanges is not nil
292+ allChanges := pc .GetAllChanges ()
293+ assert .NotNil (t , allChanges )
294+ assert .Equal (t , 4 , len (allChanges )) // 1 from PropertyChanges + 2 from QueryChanges + 1 from TraceChanges
295+
296+ // Verify QueryChanges were included
297+ queryChangeCount := 0
298+ for _ , change := range allChanges {
299+ if (change .Property == "summary" && change .ChangeType == Modified ) ||
300+ (change .Property == "operationId" && change .ChangeType == PropertyRemoved ) {
301+ queryChangeCount ++
302+ }
303+ }
304+ assert .Equal (t , 2 , queryChangeCount , "Both QueryChanges should be in the result" )
305+
306+ // Test TotalChanges() - this covers line 108 where QueryChanges is not nil
307+ total := pc .TotalChanges ()
308+ assert .Equal (t , 4 , total ) // Should include all changes
309+
310+ // Test TotalBreakingChanges() - this covers line 150 where QueryChanges is not nil
311+ breaking := pc .TotalBreakingChanges ()
312+ assert .Equal (t , 1 , breaking ) // Only the operationId removal is breaking
313+ }
314+
315+ // TestPathItemChanges_QueryChangesNil ensures we hit the branches where QueryChanges is nil
316+ // This test covers the nil checks at lines 62, 107, and 149 in path_item.go
317+ func TestPathItemChanges_QueryChangesNil (t * testing.T ) {
318+ // Create a PathItemChanges with QueryChanges nil
319+ pc := & PathItemChanges {
320+ PropertyChanges : & PropertyChanges {
321+ Changes : []* Change {
322+ {
323+ ChangeType : PropertyAdded ,
324+ Property : "summary" ,
325+ Breaking : false ,
326+ },
327+ },
328+ },
329+ QueryChanges : nil , // Explicitly nil
330+ TraceChanges : & OperationChanges {
331+ PropertyChanges : & PropertyChanges {
332+ Changes : []* Change {
333+ {
334+ ChangeType : Modified ,
335+ Property : "tags" ,
336+ Breaking : false ,
337+ },
338+ },
339+ },
340+ },
341+ }
342+
343+ // Test GetAllChanges() with nil QueryChanges - covers the if statement at line 62
344+ allChanges := pc .GetAllChanges ()
345+ assert .NotNil (t , allChanges )
346+ assert .Equal (t , 2 , len (allChanges )) // 1 from PropertyChanges + 1 from TraceChanges (QueryChanges skipped)
347+
348+ // Test TotalChanges() with nil QueryChanges - covers the if statement at line 107
349+ total := pc .TotalChanges ()
350+ assert .Equal (t , 2 , total ) // Should not include QueryChanges
351+
352+ // Test TotalBreakingChanges() with nil QueryChanges - covers the if statement at line 149
353+ breaking := pc .TotalBreakingChanges ()
354+ assert .Equal (t , 0 , breaking ) // No breaking changes in our test data
246355}
0 commit comments