Skip to content

Commit

Permalink
add server and client test
Browse files Browse the repository at this point in the history
  • Loading branch information
satoshi-099 committed Oct 23, 2023
1 parent c0a3f5d commit a7a52da
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion rotom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func TestDB(t *testing.T) {
assert.False(db.Remove("num-new"))

db.printRuntimeStats()
go db.Listen("localhost:7676")
time.Sleep(time.Second * 5)

// close
Expand Down Expand Up @@ -463,3 +462,29 @@ func TestSetAndBitmap(t *testing.T) {
assert.Equal(err, base.ErrWrongType)
}
}

func TestClient(t *testing.T) {
assert := assert.New(t)

cfg := DefaultConfig
cfg.Path = gofakeit.UUID() + ".db"
db, err := Open(cfg)
assert.Nil(err)

go db.Listen("localhost:9876")
time.Sleep(time.Second)

cli, err := NewClient("localhost:9876")
assert.Nil(err)

validator := NewCodec(Response).Int(int64(RES_SUCCESS)).Str("ok").B

for i := 0; i < 10000; i++ {
k := gofakeit.Phone()
v := gofakeit.UUID()

res, err := cli.Set(k, []byte(v))
assert.Equal(res, validator)
assert.Nil(err)
}
}

0 comments on commit a7a52da

Please sign in to comment.