ooni-probe-cli/internal/model/mocks/keyvaluestore_test.go
Simone Basso 9a0153a349
feat(oonirun): add support for OONIRun v2 links (#844)
This diff adds support for OONIRun v2 links.

Part of https://github.com/ooni/probe/issues/2184.
2022-07-08 16:53:59 +02:00

38 lines
724 B
Go

package mocks
import (
"errors"
"testing"
)
func TestKeyValueStore(t *testing.T) {
t.Run("Get", func(t *testing.T) {
expect := errors.New("mocked error")
kvs := &KeyValueStore{
MockGet: func(key string) (value []byte, err error) {
return nil, expect
},
}
out, err := kvs.Get("antani")
if !errors.Is(err, expect) {
t.Fatal("unexpected err", err)
}
if out != nil {
t.Fatal("unexpected out")
}
})
t.Run("Set", func(t *testing.T) {
expect := errors.New("mocked error")
kvs := &KeyValueStore{
MockSet: func(key string, value []byte) (err error) {
return expect
},
}
err := kvs.Set("antani", nil)
if !errors.Is(err, expect) {
t.Fatal("unexpected err", err)
}
})
}