Skip to content

Commit

Permalink
empty namespace allowed
Browse files Browse the repository at this point in the history
In accordance with Avro specification: http://avro.apache.org/docs/1.9.1/spec.html#names

Resolves: linkedin#177
  • Loading branch information
Karrick S. McDermott committed Oct 14, 2019
1 parent 6315d37 commit 3f2df38
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions name.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ func newNameFromSchemaMap(enclosingNamespace string, schemaMap map[string]interf
}
if namespace, ok := schemaMap["namespace"]; ok {
namespaceString, ok = namespace.(string)
if !ok || namespaceString == nullNamespace {
return nil, fmt.Errorf("schema namespace, if provided, ought to be non-empty string; received: %T: %v", namespace, namespace)
if !ok {
return nil, fmt.Errorf("schema namespace, if provided, ought to be a string; received: %T: %v", namespace, namespace)
}
}

Expand Down
16 changes: 16 additions & 0 deletions name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,19 @@ func TestNameWithoutDotsButWithEmptyNamespaceAndEnclosingName(t *testing.T) {
t.Errorf("GOT: %#v; WANT: %#v", actual, expected)
}
}

func TestNewNameFromSchemaMap(t *testing.T) {
n, err := newNameFromSchemaMap(nullNamespace, map[string]interface{}{
"name": "foo",
"namespace": "",
"type": map[string]interface{}{},
})
ensureError(t, err)

if got, want := n.fullName, "foo"; got != want {
t.Errorf("GOT: %q; WANT: %q", got, want)
}
if got, want := n.namespace, ""; got != want {
t.Errorf("GOT: %q; WANT: %q", got, want)
}
}

0 comments on commit 3f2df38

Please sign in to comment.