|
|
@@ -1410,20 +1410,33 @@ func (f fakeRef) GetRemoteKey() string {
|
|
|
|
|
|
func TestSetSecret(t *testing.T) {
|
|
|
path := "secret"
|
|
|
- client := client{
|
|
|
+
|
|
|
+ // Testing for when SetSecret returns an error
|
|
|
+ client1 := client{
|
|
|
store: &esv1beta1.VaultProvider{
|
|
|
Path: &path,
|
|
|
},
|
|
|
logical: fake.Logical{
|
|
|
- WriteWithContextFn: fake.NewWriteWithContextFn(nil, nil),
|
|
|
+ WriteWithContextFn: fake.NewWriteWithContextFn(nil, fmt.Errorf("error")),
|
|
|
},
|
|
|
}
|
|
|
ref := fakeRef{key: "I'm a key"}
|
|
|
- err := client.SetSecret(context.Background(), []byte("HI"), ref)
|
|
|
|
|
|
- secretData := map[string]interface{}{}
|
|
|
- _, noDataClient := client.logical.WriteWithContext(context.TODO(), path, secretData)
|
|
|
+ err := client1.SetSecret(context.Background(), []byte("HI"), ref)
|
|
|
+
|
|
|
+ assert.Equal(t, err.Error(), "error")
|
|
|
+
|
|
|
+ // Testing for when SetSecret returns nil
|
|
|
+ client2 := client{
|
|
|
+ store: &esv1beta1.VaultProvider{
|
|
|
+ Path: &path,
|
|
|
+ },
|
|
|
+ logical: fake.Logical{
|
|
|
+ WriteWithContextFn: fake.NewWriteWithContextFn(nil, nil),
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
+ err = client2.SetSecret(context.Background(), []byte("HI"), ref)
|
|
|
|
|
|
- assert.Equal(t, noDataClient, nil)
|
|
|
assert.Equal(t, err, nil)
|
|
|
}
|