-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathcheck_new_request_non_path_default_parameter_test.go
89 lines (82 loc) · 2.97 KB
/
check_new_request_non_path_default_parameter_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
79
80
81
82
83
84
85
86
87
88
89
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"
)
// BC: new header, query and cookie required request default param is breaking
func TestNewRequestNonPathParameter_DetectsNewRequiredPathsAndNewOperations(t *testing.T) {
s1, err := open("../data/request_params/base.yaml")
require.NoError(t, err)
s2, err := open("../data/request_params/required-request-params.yaml")
require.NoError(t, err)
d, osm, err := diff.GetWithOperationsSourcesMap(&diff.Config{}, s1, s2)
require.NoError(t, err)
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.NewRequestNonPathDefaultParameterCheck), d, osm, checker.INFO)
require.NotEmpty(t, errs)
require.Len(t, errs, 7)
require.ElementsMatch(t, []checker.ApiChange{
{
Id: checker.NewRequiredRequestDefaultParameterToExistingPathId,
Args: []any{"query", "version"},
Level: 3,
Operation: "GET",
OperationId: "getTest",
Path: "/api/test1",
Source: load.NewSource("../data/request_params/required-request-params.yaml"),
},
{
Id: checker.NewRequiredRequestDefaultParameterToExistingPathId,
Args: []any{"query", "version"},
Level: 3,
Operation: "POST",
Path: "/api/test1",
Source: load.NewSource("../data/request_params/required-request-params.yaml"),
},
{
Id: checker.NewRequiredRequestDefaultParameterToExistingPathId,
Args: []any{"query", "id"},
Level: 3,
Operation: "GET",
OperationId: "getTest",
Path: "/api/test2",
Source: load.NewSource("../data/request_params/required-request-params.yaml"),
},
{
Id: checker.NewRequiredRequestDefaultParameterToExistingPathId,
Args: []any{"header", "If-None-Match"},
Level: 3,
Operation: "GET",
OperationId: "getTest",
Path: "/api/test3",
Source: load.NewSource("../data/request_params/required-request-params.yaml"),
},
{
Id: checker.NewOptionalRequestDefaultParameterToExistingPathId,
Args: []any{"query", "optionalQueryParam"},
Level: 1,
Operation: "GET",
OperationId: "getTest",
Path: "/api/test1",
Source: load.NewSource("../data/request_params/required-request-params.yaml"),
},
{
Id: checker.NewOptionalRequestDefaultParameterToExistingPathId,
Args: []any{"query", "optionalQueryParam"},
Level: 1,
Operation: "POST",
Path: "/api/test1",
Source: load.NewSource("../data/request_params/required-request-params.yaml"),
},
{
Id: checker.NewOptionalRequestDefaultParameterToExistingPathId,
Args: []any{"header", "optionalHeaderParam"},
Level: 1,
Operation: "GET",
OperationId: "getTest",
Path: "/api/test2",
Source: load.NewSource("../data/request_params/required-request-params.yaml"),
}}, errs)
}