Skip to content
Snippets Groups Projects
Commit edc1c9e3 authored by thijsheijden's avatar thijsheijden
Browse files

Updated keyvaluedriver and its mock

parent ec0795ab
No related branches found
No related tags found
No related merge requests found
...@@ -35,13 +35,12 @@ func (d *KeyValueDriver) Start() { ...@@ -35,13 +35,12 @@ func (d *KeyValueDriver) Start() {
} }
// Get retrieves the value from the redis store that belongs to the given key // Get retrieves the value from the redis store that belongs to the given key
func (d *KeyValueDriver) Get(key *string) *string { func (d *KeyValueDriver) Get(key *string) string {
value := d.client.Get(context.Background(), *key).Val() return d.client.Get(context.Background(), *key).Val()
return &value
} }
// Set sets the key value pair in the redis store // Set sets the key value pair in the redis store
func (d *KeyValueDriver) Set(key *string, value interface{}) error { func (d *KeyValueDriver) Set(key *string, value *string) error {
status := d.client.Set(context.Background(), *key, value, 0) status := d.client.Set(context.Background(), *key, *value, 0)
return status.Err() return status.Err()
} }
...@@ -2,23 +2,23 @@ package mockkeyvaluedriver ...@@ -2,23 +2,23 @@ package mockkeyvaluedriver
// A KeyValueStore implements methods to set key-value data (mock) // A KeyValueStore implements methods to set key-value data (mock)
type KeyValueStore struct { type KeyValueStore struct {
data map[string]interface{} data map[string]string
} }
// CreateKeyValueStore creates a key value store driver (mock) // CreateKeyValueStore creates a key value store driver (mock)
func CreateKeyValueStore() *KeyValueStore { func CreateKeyValueStore() *KeyValueStore {
return &KeyValueStore{ return &KeyValueStore{
data: make(map[string]interface{}), data: make(map[string]string),
} }
} }
// Set sets a key to a value in the key value store. Expects a non-pointer as value. (mock) // Set sets a key to a value in the key value store. Expects a non-pointer as value. (mock)
func (kvs *KeyValueStore) Set(key *string, value interface{}) error { func (kvs *KeyValueStore) Set(key *string, value *string) error {
kvs.data[*key] = value kvs.data[*key] = *value
return nil return nil
} }
// Get gets the value for the supplied key from the key value store (mock) // Get gets the value for the supplied key from the key value store (mock)
func (kvs *KeyValueStore) Get(key *string) interface{} { func (kvs *KeyValueStore) Get(key *string) string {
return kvs.data[*key] return kvs.data[*key]
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment