func Test_Get_AlternatePath_NoKey(t *testing.T) { key := "doesnotexist_enc" store, err := mock.New([]string{}) if err != nil { t.Errorf("Error creating backend: %s\n", err.Error()) } cm, err := NewConfigManager(store, bytes.NewBufferString(secring)) if err != nil { t.Errorf("Error creating config manager: %s\n", err.Error()) } _, err = cm.Get(key) if err == nil { t.Errorf("Did not get expected error\n") } }
func Test_Set_BasePath(t *testing.T) { key := "foo_enc" value := []byte("bar_enc") store, err := mock.New([]string{}) if err != nil { t.Errorf("Error creating backend: %s\n", err.Error()) } cm, err := NewConfigManager(store, bytes.NewBufferString(pubring)) if err != nil { t.Errorf("Error creating config manager: %s\n", err.Error()) } err = cm.Set(key, value) if err != nil { t.Errorf("Error adding key: %s\n", err.Error()) } }
func Test_StandardSet_BasePath(t *testing.T) { key := "foo" value := []byte("bar") store, err := mock.New([]string{}) if err != nil { t.Errorf("Error creating backend: %s\n", err.Error()) } cm, err := NewStandardConfigManager(store) if err != nil { t.Errorf("Error creating config manager: %s\n", err.Error()) } err = cm.Set(key, value) if err != nil { t.Errorf("Error adding key: %s\n", err.Error()) } }
func Test_Watch_BasePath(t *testing.T) { key := "foo_enc" store, err := mock.New([]string{}) if err != nil { t.Errorf("Error creating backend: %s\n", err.Error()) } cm, err := NewConfigManager(store, bytes.NewBufferString(secring)) if err != nil { t.Errorf("Error creating config manager: %s\n", err.Error()) } timeout := make(chan bool, 0) resp := cm.Watch(key, timeout) select { case r := <-resp: if r.Error != nil { t.Errorf("Error watching value: %s\n", r.Error.Error()) } } }
func Test_Get_BasePath(t *testing.T) { key := "foo_enc" value := []byte("bar_enc") store, err := mock.New([]string{}) if err != nil { t.Errorf("Error creating backend: %s\n", err.Error()) } cm, err := NewConfigManager(store, bytes.NewBufferString(secring)) if err != nil { t.Errorf("Error creating config manager: %s\n", err.Error()) } storedValue, err := cm.Get(key) if err != nil { t.Errorf("Error getting key: %s\n", err.Error()) } if !reflect.DeepEqual(storedValue, value) { t.Errorf("Two values did not match: %s\n", err.Error()) } }