-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathcheck_response_property_all_of_updated_test.go
78 lines (68 loc) · 2.84 KB
/
check_response_property_all_of_updated_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package checker_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/tufin/oasdiff/checker"
"github.com/tufin/oasdiff/diff"
"github.com/tufin/oasdiff/load"
)
// CL: adding 'allOf' subschema to the response body or response body property
func TestResponsePropertyAllOfAdded(t *testing.T) {
s1, err := open("../data/checker/response_property_all_of_added_base.yaml")
require.NoError(t, err)
s2, err := open("../data/checker/response_property_all_of_added_revision.yaml")
require.NoError(t, err)
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
require.NoError(t, err)
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.ResponsePropertyAllOfUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 2)
require.ElementsMatch(t, []checker.ApiChange{
{
Id: checker.ResponseBodyAllOfAddedId,
Args: []any{"#/components/schemas/Rabbit", "200"},
Level: checker.INFO,
Operation: "GET",
Path: "/pets",
Source: load.NewSource("../data/checker/response_property_all_of_added_revision.yaml"),
OperationId: "listPets",
},
{
Id: checker.ResponsePropertyAllOfAddedId,
Args: []any{"#/components/schemas/Breed3", "/allOf[#/components/schemas/Dog]/breed", "200"},
Level: checker.INFO,
Operation: "GET",
Path: "/pets",
Source: load.NewSource("../data/checker/response_property_all_of_added_revision.yaml"),
OperationId: "listPets",
}}, errs)
}
// CL: removing 'allOf' subschema from the response body or response body property
func TestResponsePropertyAllOfRemoved(t *testing.T) {
s1, err := open("../data/checker/response_property_all_of_removed_base.yaml")
require.NoError(t, err)
s2, err := open("../data/checker/response_property_all_of_removed_revision.yaml")
require.NoError(t, err)
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
require.NoError(t, err)
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.ResponsePropertyAllOfUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 2)
require.ElementsMatch(t, []checker.ApiChange{
{
Id: checker.ResponseBodyAllOfRemovedId,
Args: []any{"#/components/schemas/Rabbit", "200"},
Level: checker.INFO,
Operation: "GET",
Path: "/pets",
Source: load.NewSource("../data/checker/response_property_all_of_removed_revision.yaml"),
OperationId: "listPets",
},
{
Id: checker.ResponsePropertyAllOfRemovedId,
Args: []any{"#/components/schemas/Breed3", "/allOf[#/components/schemas/Dog]/breed", "200"},
Level: checker.INFO,
Operation: "GET",
Path: "/pets",
Source: load.NewSource("../data/checker/response_property_all_of_removed_revision.yaml"),
OperationId: "listPets",
}}, errs)
}