MCPcopy Create free account
hub / github.com/goadesign/goa / TestServerExprValidate

Function TestServerExprValidate

expr/server_test.go:28–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func TestServerExprValidate(t *testing.T) {
29 const (
30 foo = "foo"
31 bar = "bar"
32 )
33 var (
34 validURI = URIExpr("http://example.com")
35 validURIs = []URIExpr{
36 validURI,
37 }
38 errNoURI = fmt.Errorf("host must define at least one URI")
39 errServiceUndefined = fmt.Errorf("service %q undefined", bar)
40 )
41
42 cases := map[string]struct {
43 hosts []*HostExpr
44 services []string
45 expected *eval.ValidationErrors
46 }{
47 "no error": {
48 hosts: []*HostExpr{
49 {
50 URIs: validURIs,
51 },
52 },
53 services: []string{
54 foo,
55 },
56 expected: &eval.ValidationErrors{
57 Errors: []error{},
58 },
59 },
60 "error only in hosts": {
61 hosts: []*HostExpr{
62 {
63 URIs: []URIExpr{},
64 },
65 },
66 expected: &eval.ValidationErrors{
67 Errors: []error{
68 errNoURI,
69 },
70 },
71 },
72 "error only in services": {
73 services: []string{
74 bar,
75 },
76 expected: &eval.ValidationErrors{
77 Errors: []error{
78 errServiceUndefined,
79 },
80 },
81 },
82 "error in both": {
83 hosts: []*HostExpr{
84 {
85 URIs: []URIExpr{},

Callers

nothing calls this directly

Calls 3

ValidateMethod · 0.95
URIExprTypeAlias · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected