Updates based on comments

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2018-10-04 12:50:12 -07:00
parent 0d1d51a3bb
commit b014db8502
2 changed files with 4 additions and 7 deletions

View File

@@ -1008,13 +1008,11 @@ func TestAccountGlobalDefault(t *testing.T) {
opts := defaultServerOptions
s := New(&opts)
acc := s.LookupAccount(globalAccountName)
if acc == nil {
if acc := s.LookupAccount(globalAccountName); acc == nil {
t.Fatalf("Expected a global default account on a new server, got none.")
}
// Make sure we can not create one with same name..
_, err := s.RegisterAccount(globalAccountName)
if err == nil {
if _, err := s.RegisterAccount(globalAccountName); err == nil {
t.Fatalf("Expected error trying to create a new reserved account")
}
@@ -1022,8 +1020,7 @@ func TestAccountGlobalDefault(t *testing.T) {
confFileName := createConfFile(t, []byte(`accounts { $G {} }`))
defer os.Remove(confFileName)
_, err = ProcessConfigFile(confFileName)
if err == nil {
if _, err := ProcessConfigFile(confFileName); err == nil {
t.Fatalf("Expected an error parsing config file with reserved account")
}
}

View File

@@ -629,7 +629,7 @@ type importService struct {
// Checks if an account name is reserved.
func isReservedAccount(name string) bool {
return strings.Compare(name, globalAccountName) == 0
return name == globalAccountName
}
// parseAccounts will parse the different accounts syntax.