Add fake store for unit tests

Signed-off-by: Hasan Turken <turkenh@gmail.com>
This commit is contained in:
Hasan Turken 2022-02-10 15:50:45 +03:00
parent 19034f22d1
commit 936e12174d
No known key found for this signature in database
GPG Key ID: D7AA042F8F8B488E
2 changed files with 25 additions and 29 deletions

View File

@ -1,29 +0,0 @@
package fake
import (
"context"
"github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
"github.com/crossplane/crossplane-runtime/pkg/resource"
)
type SecretStoreFns struct {
ConnectionPublisherFns
}
// ConnectionPublisherFns is the pluggable struct to produce objects with ConnectionPublisher interface.
type ConnectionPublisherFns struct {
PublishConnectionFn func(ctx context.Context, mg resource.Managed, c managed.ConnectionDetails) error
UnpublishConnectionFn func(ctx context.Context, mg resource.Managed, c managed.ConnectionDetails) error
}
// PublishConnection details for the supplied Managed resource.
func (fn ConnectionPublisherFns) PublishConnection(ctx context.Context, mg resource.Managed, c managed.ConnectionDetails) error {
return fn.PublishConnectionFn(ctx, mg, c)
}
// UnpublishConnection details for the supplied Managed resource.
func (fn ConnectionPublisherFns) UnpublishConnection(ctx context.Context, mg resource.Managed, c managed.ConnectionDetails) error {
return fn.UnpublishConnectionFn(ctx, mg, c)
}

View File

@ -0,0 +1,25 @@
package fake
import (
"context"
"github.com/crossplane/crossplane-runtime/pkg/connection/secret/store"
)
type SecretStore struct {
ReadKeyValuesFn func(ctx context.Context, i store.SecretInstance) (store.KeyValues, error)
WriteKeyValuesFn func(ctx context.Context, i store.SecretInstance, kv store.KeyValues) error
DeleteKeyValuesFn func(ctx context.Context, i store.SecretInstance, kv store.KeyValues) error
}
func (ss *SecretStore) ReadKeyValues(ctx context.Context, i store.SecretInstance) (store.KeyValues, error) {
return ss.ReadKeyValuesFn(ctx, i)
}
func (ss *SecretStore) WriteKeyValues(ctx context.Context, i store.SecretInstance, kv store.KeyValues) error {
return ss.WriteKeyValuesFn(ctx, i, kv)
}
func (ss *SecretStore) DeleteKeyValues(ctx context.Context, i store.SecretInstance, kv store.KeyValues) error {
return ss.DeleteKeyValuesFn(ctx, i, kv)
}