-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinks_test.go
More file actions
38 lines (34 loc) · 806 Bytes
/
links_test.go
File metadata and controls
38 lines (34 loc) · 806 Bytes
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
package openapi_test
import (
"testing"
"github.com/MarkRosemaker/openapi"
)
func TestLinks_Validate_Error(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
ls openapi.Links
err string
}{
{
openapi.Links{"foo": {Value: &openapi.Link{}}},
`foo: operationRef or operationId must be set`,
},
{
openapi.Links{" ": {Value: &openapi.Link{}}},
`[" "] (" ") is invalid: must match the regular expression "^[a-zA-Z0-9\\.\\-_]+$"`,
},
{
openapi.Links{"foo": {Value: &openapi.Link{
OperationID: "myOperation",
Server: &openapi.Server{},
}}},
`foo.server.url is required`,
},
} {
t.Run(tc.err, func(t *testing.T) {
if err := tc.ls.Validate(); err == nil || err.Error() != tc.err {
t.Fatalf("want: %s, got: %s", tc.err, err)
}
})
}
}