github.com/blong14/gache@v0.0.0-20240124023949-89416fd8bbfa/client/conn_test.go (about) 1 package client_test 2 3 import ( 4 "bytes" 5 "context" 6 "testing" 7 8 gclient "github.com/blong14/gache/client" 9 ) 10 11 func TestClient(t *testing.T) { 12 ctx := context.Background() 13 conn := gclient.NewProxyClient() 14 table, key, value := []byte("default"), []byte("__key__"), []byte("__value__") 15 if err := conn.Set(ctx, table, key, value); err != nil { 16 t.Error(err) 17 } 18 actual, err := conn.Get(ctx, table, key) 19 if err != nil { 20 t.Error(err) 21 } 22 if !bytes.Equal(actual, value) { 23 t.Error("value not found") 24 } 25 _, err = conn.Get(ctx, table, []byte("__not_found__")) 26 if err == nil { 27 t.Error("should not have found the key") 28 } 29 err = conn.Close(ctx) 30 if err != nil { 31 t.Error(err) 32 } 33 } 34