
Files that have RESTStorage implementations now end in "storage", and files that have registries now end in "registry". I removed some underscores in file names, since it seems to be go style not to have them. I split minion_registry.go into two files. We should consider splitting this package into two, to make more clear the separation between the layers.
58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
/*
|
|
Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package registry
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestMinionRegistry(t *testing.T) {
|
|
m := MakeMinionRegistry([]string{"foo", "bar"})
|
|
if has, err := m.Contains("foo"); !has || err != nil {
|
|
t.Errorf("missing expected object")
|
|
}
|
|
if has, err := m.Contains("bar"); !has || err != nil {
|
|
t.Errorf("missing expected object")
|
|
}
|
|
if has, err := m.Contains("baz"); has || err != nil {
|
|
t.Errorf("has unexpected object")
|
|
}
|
|
|
|
if err := m.Insert("baz"); err != nil {
|
|
t.Errorf("insert failed")
|
|
}
|
|
if has, err := m.Contains("baz"); !has || err != nil {
|
|
t.Errorf("insert didn't actually insert")
|
|
}
|
|
|
|
if err := m.Delete("bar"); err != nil {
|
|
t.Errorf("delete failed")
|
|
}
|
|
if has, err := m.Contains("bar"); has || err != nil {
|
|
t.Errorf("delete didn't actually delete")
|
|
}
|
|
|
|
list, err := m.List()
|
|
if err != nil {
|
|
t.Errorf("got error calling List")
|
|
}
|
|
if !reflect.DeepEqual(list, []string{"baz", "foo"}) {
|
|
t.Errorf("Unexpected list value: %#v", list)
|
|
}
|
|
}
|