cheapcash/writer_test.go

40 lines
600 B
Go
Raw Normal View History

2021-11-16 04:56:33 +00:00
package cheapcash_test
import (
"sync"
"testing"
"github.com/aldy505/cheapcash"
)
func TestWrite(t *testing.T) {
c := cheapcash.Default()
err := c.Write("key", []byte("value"))
if err != nil {
t.Error("an error was thrown:", err)
}
}
func TestWrite_Conccurency(t *testing.T) {
c := cheapcash.Default()
var wg sync.WaitGroup
writeFunc := func() {
err := c.Write("key1", []byte("value1"))
if err != nil {
t.Error("an error was thrown:", err)
}
wg.Done()
}
wg.Add(5)
go writeFunc()
go writeFunc()
go writeFunc()
go writeFunc()
go writeFunc()
wg.Wait()
}