diff --git a/go/pkg/api/path.go b/go/pkg/api/path.go index b8058b64..a5c0d412 100644 --- a/go/pkg/api/path.go +++ b/go/pkg/api/path.go @@ -401,7 +401,7 @@ func (s *state) getToplevel(name string, c change) (ast.Toplevel, error) { m, ok := c.val.(map[string]interface{}) if !ok { return nil, fmt.Errorf( - "Expecting JSON object when reading '%s' but got: %T", name, c.val) + "Expecting JSON object in attribute 'value' but got: %T", c.val) } var t ast.Toplevel var err error diff --git a/go/testdata/api/group.t b/go/testdata/api/group.t index 14e53d07..62a1ee27 100644 --- a/go/testdata/api/group.t +++ b/go/testdata/api/group.t @@ -95,7 +95,7 @@ network:n1 = { ip = 10.1.1.0/24; } } } =ERROR= -Error: Expecting JSON object when reading 'group:g1' but got: []interface {} +Error: Expecting JSON object in attribute 'value' but got: []interface {} =END= ############################################################ diff --git a/go/testdata/api/path.t b/go/testdata/api/path.t index 1d73763d..1a03a359 100644 --- a/go/testdata/api/path.t +++ b/go/testdata/api/path.t @@ -12,6 +12,39 @@ network:n1 = { ip = 10.1.1.0/24; } Error: Invalid empty path =END= +############################################################ +=TITLE=Invalid path +=INPUT= +network:n1 = { ip = 10.1.1.0/24; } +=JOB= +{ + "method": "add", + "params": { "path": "invalid" } +} +=ERROR= +Error: Expecting JSON object in attribute 'value' but got: +=END= + +############################################################ +=TITLE=Invalid global definition +=INPUT= +network:n1 = { ip = 10.1.1.0/24; } +=JOB= +{ + "method": "add", + "params": { "path": "in:valid", "value": {} } +} +=ERROR= +Error: Unknown global definition at line 3 of INPUT, near "--HERE-->in:valid" +Aborted +=OUTPUT= +@@ INPUT + network:n1 = { ip = 10.1.1.0/24; } ++ ++in:valid = { ++} +=END= + ############################################################ =TITLE=Invalid value =INPUT= @@ -38,7 +71,7 @@ network:n1 = { ip = 10.1.1.0/24; } } } =ERROR= -Error: Expecting JSON object when reading 'network:n2' but got: []interface {} +Error: Expecting JSON object in attribute 'value' but got: []interface {} =END= ############################################################ diff --git a/go/testdata/api/service.t b/go/testdata/api/service.t index 4c200fa6..7fded411 100644 --- a/go/testdata/api/service.t +++ b/go/testdata/api/service.t @@ -240,7 +240,7 @@ network:n1 = { ip = 10.1.1.0/24; } } } =ERROR= -Error: Expecting JSON object when reading 'service:s1' but got: string +Error: Expecting JSON object in attribute 'value' but got: string =END= ############################################################