This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
forked from datacontract/datacontract-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
breaking_test.go
64 lines (61 loc) · 1.77 KB
/
breaking_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
package datacontract
import (
"bytes"
"testing"
)
func TestBreaking(t *testing.T) {
type args struct {
dataContractLocation string
stableDataContractLocation string
pathToModels []string
pathToType []string
pathToSpecification []string
}
tests := []LogOutputTest[args]{
{
name: "breaking",
args: args{
dataContractLocation: "test_resources/breaking/breaking_datacontract.yaml",
stableDataContractLocation: "test_resources/breaking/datacontract.yaml",
pathToModels: []string{"models"},
pathToType: []string{"schema", "type"},
pathToSpecification: []string{"schema", "specification"},
},
wantErr: true,
wantOutput: `Found 1 differences between the data contracts!
🔴 Difference 1:
Description: field 'my_table.my_column' was removed
Type: field-removed
Severity: breaking
Level: field
InternalModel: my_table
InternalField: my_column
`,
},
{
name: "not-breaking",
args: args{
dataContractLocation: "test_resources/breaking/not_breaking_datacontract.yaml",
stableDataContractLocation: "test_resources/breaking/datacontract.yaml",
pathToModels: []string{"models"},
pathToType: []string{"schema", "type"},
pathToSpecification: []string{"schema", "specification"},
},
wantErr: false,
wantOutput: `Found 0 differences between the data contracts!
`,
},
}
for _, tt := range tests {
RunLogOutputTest(t, tt, "Breaking", func(buffer *bytes.Buffer) error {
return Breaking(
tt.args.dataContractLocation,
tt.args.stableDataContractLocation,
tt.args.pathToModels,
tt.args.pathToType,
tt.args.pathToSpecification,
buffer,
)
})
}
}