Files
micro/store/noop_test.go
pugnack 3deb572f72
Some checks failed
coverage / build (push) Failing after 2m12s
test / test (push) Successful in 4m27s
sync / sync (push) Successful in 7s
[v4] fix out-of-bounds behavior in seeker buffer and add tests (#219)
* add check negative position to Read() and write tests

* add tests for Write() method

* add tests for Write() method

* add checks of whence and negative position to Seek() and write tests

* add tests for Rewind()

* add tests for Close()

* add tests for Reset()

* add tests for Len()

* add tests for Bytes()

* tests polishing

* tests polishing

* tests polishing

* tests polishing
2025-06-15 17:24:48 +03:00

38 lines
559 B
Go

package store
import (
"context"
"errors"
"testing"
)
type testHook struct {
f bool
}
func (t *testHook) Exists(fn FuncExists) FuncExists {
return func(ctx context.Context, key string, opts ...ExistsOption) error {
t.f = true
return fn(ctx, key, opts...)
}
}
func TestHook(t *testing.T) {
h := &testHook{}
s := NewStore(Hooks(HookExists(h.Exists)))
if err := s.Init(); err != nil {
t.Fatal(err)
}
err := s.Exists(context.TODO(), "test")
if !errors.Is(err, ErrNotFound) {
t.Fatal(err)
}
if !h.f {
t.Fatal("hook not works")
}
}