-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtag_test.go
21 lines (17 loc) · 877 Bytes
/
tag_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package openapi_test
import (
"testing"
openapi "github.com/nasa9084/go-openapi"
)
func TestTag_Validate(t *testing.T) {
nameRequiredError := openapi.ErrRequired{Target: "tag.name"}
candidates := []candidate{
{"empty", openapi.Tag{}, nameRequiredError},
{"withEmptyExternalDocs", openapi.Tag{ExternalDocs: &openapi.ExternalDocumentation{}}, nameRequiredError},
{"withValidExternalDocs", openapi.Tag{ExternalDocs: &openapi.ExternalDocumentation{URL: exampleCom}}, nameRequiredError},
{"withName", openapi.Tag{Name: "foo"}, nil},
{"withNameAndEmptyExternalDocs", openapi.Tag{Name: "foo", ExternalDocs: &openapi.ExternalDocumentation{}}, openapi.ErrRequired{Target: "externalDocumentation.url"}},
{"withNameAndValidExternalDocs", openapi.Tag{Name: "foo", ExternalDocs: &openapi.ExternalDocumentation{URL: exampleCom}}, nil},
}
testValidater(t, candidates)
}