MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / TestString

Function TestString

IceFireDB-PubSub/test/cmd_string_test.go:32–84  ·  view source on GitHub ↗

Test simple GET/SET keys

(t *testing.T)

Source from the content-addressed store, hash-verified

30
31// Test simple GET/SET keys
32func TestString(t *testing.T) {
33 server.Clear()
34 c, err := proto.Dial(server.Addr())
35 ok(t, err)
36 defer c.Close()
37 s := server.Direct()
38
39 // SET command
40 mustOK(t, c,
41 "SET", "foo", "bar",
42 )
43
44 // GET command
45 mustDo(t, c,
46 "GET", "foo",
47 proto.String("bar"),
48 )
49
50 // Query server directly.
51 {
52 got, err := s.Get("foo")
53 ok(t, err)
54 equals(t, "bar", got)
55 }
56
57 // Use Set directly
58 {
59 ok(t, s.Set("aap", "noot"))
60 s.CheckGet(t, "aap", "noot")
61 mustDo(t, c,
62 "GET", "aap",
63 proto.String("noot"),
64 )
65 s.CheckGet(t, "aap", "noot")
66 // Re-set.
67 ok(t, s.Set("aap", "noot2"))
68 }
69
70 // non-existing key
71 mustNil(t, c,
72 "GET", "reallynosuchkey",
73 )
74
75 t.Run("errors", func(t *testing.T) {
76 must1(t, c,
77 "HSET", "wim", "zus", "jet",
78 )
79 mustDo(t, c,
80 "GET", "wim",
81 proto.Error(msgWrongType),
82 )
83 })
84}
85
86func TestSet(t *testing.T) {
87 server.Clear()

Callers

nothing calls this directly

Calls 15

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
StringFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
mustOKFunction · 0.70
mustDoFunction · 0.70
equalsFunction · 0.70
mustNilFunction · 0.70

Tested by

no test coverage detected