-
Notifications
You must be signed in to change notification settings - Fork 67
/
check_request_parameters_min_updated_test.go
54 lines (48 loc) · 2.04 KB
/
check_request_parameters_min_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
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: increasing minimum value of request parameter
func TestRequestParameterMinIncreased(t *testing.T) {
s1, err := open("../data/checker/request_parameter_min_increased_base.yaml")
require.NoError(t, err)
s2, err := open("../data/checker/request_parameter_min_increased_revision.yaml")
require.NoError(t, err)
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
require.NoError(t, err)
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestParameterMinUpdatedCheck), d, osm, checker.ERR)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: checker.RequestParameterMinIncreasedId,
Args: []any{"path", "groupId", 1.0, 10.0},
Level: checker.ERR,
Operation: "POST",
Path: "/api/v1.0/groups",
Source: load.NewSource("../data/checker/request_parameter_min_increased_revision.yaml"),
OperationId: "createOneGroup",
}, errs[0])
}
// CL: decreasing minimum value of request parameter
func TestRequestParameterMinDecreased(t *testing.T) {
s1, err := open("../data/checker/request_parameter_min_increased_revision.yaml")
require.NoError(t, err)
s2, err := open("../data/checker/request_parameter_min_increased_base.yaml")
require.NoError(t, err)
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
require.NoError(t, err)
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestParameterMinUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: checker.RequestParameterMinDecreasedId,
Args: []any{"path", "groupId", 10.0, 1.0},
Level: checker.INFO,
Operation: "POST",
Path: "/api/v1.0/groups",
Source: load.NewSource("../data/checker/request_parameter_min_increased_base.yaml"),
OperationId: "createOneGroup",
}, errs[0])
}