Skip to content

Commit bdff91e

Browse files
fredbicasualjim
authored andcommitted
refactored diff CLI and associated tests
* fixes #2103 (--destination flag was not honoured) * refactor tests for CLI diff: getting rid of the test dependency github.com/corbym/gocrest * introduced positional arg parsing with auto-generator doc (see https://pkg.go.dev/github.com/jessevdk/go-flags?tab=doc#Arg) * refactor output handling: only top-level is controlling the output, all other funcs return io.Reader (easier to test) * more test coverage (diff pkg is lagging behind the standard expected coverage, which should be above 80%) * un-export some of the internal "DSL" stuff (however, kept status codes and diff structures exposed) * updated usage doc Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent 9a51002 commit bdff91e

File tree

7 files changed

+25
-11
lines changed

7 files changed

+25
-11
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
BREAKING CHANGES:
2+
=================
3+
/a/:get -> 200 Response - array[A1].personality : string - Added possible enumeration(s) <sane>
4+
/a/:get Request - Query.personality - Deleted possible enumeration(s) <saucy>
5+
/a/{id}:get -> 200 Response - array[A1].personality : string - Added possible enumeration(s) <sane>
6+
/b/:get -> 200 Response - array[A1].personality : string - Added possible enumeration(s) <sane>
7+
8+
compatibility test FAILED: 4 breaking changes detected

diff/fixtures/enum.diff.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ NON-BREAKING CHANGES:
44
/a/:get Request - Query.personality - Added possible enumeration(s) <extrovert>
55
/a/{id}:get -> 200 Response - array[A1].personality : string - Deleted possible enumeration(s) <crazy>
66
/b/:get -> 200 Response - array[A1].personality : string - Deleted possible enumeration(s) <crazy>
7-
7+
88
BREAKING CHANGES:
99
=================
1010
/a/:get -> 200 Response - array[A1].personality : string - Added possible enumeration(s) <sane>
1111
/a/:get Request - Query.personality - Deleted possible enumeration(s) <saucy>
1212
/a/{id}:get -> 200 Response - array[A1].personality : string - Added possible enumeration(s) <sane>
1313
/b/:get -> 200 Response - array[A1].personality : string - Added possible enumeration(s) <sane>
14-
14+
15+
compatibility test FAILED: 4 breaking changes detected

diff/fixtures/kitchensink.diff.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ NON-BREAKING CHANGES:
1010
/a/:get Request - Query.changeMaxInt - Widened type <Maximum 200.000000->300.000000>
1111
/a/:get Request - Query.removeMaxInt - Widened type <Exclusive Maximum Removed:true->false>
1212
/a/:get Request - Query.wideryString - Widened type <integer -> string>
13-
13+
1414
BREAKING CHANGES:
1515
=================
1616
Metadata - Spec Metadata - Changed base path </api -> /apibaby>
@@ -24,4 +24,5 @@ NON-BREAKING CHANGES:
2424
/a/:get Request - Query.changeMinInt - Narrowed type <Minimum 200.000000->300.000000>
2525
/a/:get Request - Query.changeyPattern - Changed type <Pattern Changed:*->anewpattern>
2626
/a/:get Request - Query.primToObj : A2 - Changed type <integer -> obj>
27-
27+
28+
compatibility test FAILED: 11 breaking changes detected

diff/fixtures/param.diff.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ NON-BREAKING CHANGES:
77
/a/{id}:post Request - Header.newboris - Added optional param
88
/a/{id}:post Request - Header.optboris - Deleted optional param
99
/a/{id}:post Request - Header.reqdboris - Deleted required param
10-
10+
1111
BREAKING CHANGES:
1212
=================
1313
/a/:post -> 200 Response - otherDeletedName : string - Deleted property
@@ -18,4 +18,5 @@ NON-BREAKING CHANGES:
1818
/a/{id}:post -> 200 Response - otherDeletedName : string - Deleted property
1919
/a/{id}:post Request - Header.changedboris - Narrowed type <string -> integer>
2020
/b/:post -> 200 Response - otherDeletedName : string - Deleted property
21-
21+
22+
compatibility test FAILED: 8 breaking changes detected

diff/fixtures/path.diff.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ NON-BREAKING CHANGES:
33
/a/:put Request- Added endpoint
44
/a/{id}:post Request- Deleted a deprecated endpoint
55
/newpath/:post Request- Added endpoint
6-
6+
77
BREAKING CHANGES:
88
=================
99
/a/:post Request- Deleted endpoint
1010
/b/:post Request- Deleted endpoint
11-
11+
12+
compatibility test FAILED: 2 breaking changes detected

diff/fixtures/response.diff.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ NON-BREAKING CHANGES:
55
/a/:put -> 200 Response - description : string - Narrowed type <string -> integer.int32>
66
/a/{id}:get -> 200 Response - colour : string - Added property
77
/a/{id}:get -> 200 Response - description : string - Narrowed type <string -> integer.int32>
8-
8+
99
BREAKING CHANGES:
1010
=================
1111
/a/:get -> 200 Response- Deleted response
12-
12+
13+
compatibility test FAILED: 1 breaking changes detected

diff/fixtures/uber.diff.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ NON-BREAKING CHANGES:
55
/estimates/price:get Request- Deleted a tag <DeadTagWalking>
66
/products:get Request - latitude - Deleted a description
77
/products:get Request- Deleted a description
8-
8+
9+
compatibility test OK. No breaking changes identified.

0 commit comments

Comments
 (0)