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

Function TestSet

IceFireDB-PubSub/test/cmd_string_test.go:86–228  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

84}
85
86func TestSet(t *testing.T) {
87 server.Clear()
88 c, err := proto.Dial(server.Addr())
89 ok(t, err)
90 defer c.Close()
91 s := server.Direct()
92
93 t.Run("basic", func(t *testing.T) {
94 // Simple case
95 mustOK(t, c,
96 "SET", "aap", "noot",
97 )
98
99 // Overwrite other types.
100 s.HSet("wim", "teun", "vuur")
101 mustOK(t, c,
102 "SET", "wim", "gijs",
103 )
104 s.CheckGet(t, "wim", "gijs")
105 })
106
107 t.Run("NX", func(t *testing.T) {
108 // new key
109 mustOK(t, c,
110 "SET", "mies", "toon", "NX",
111 )
112 // now existing key
113 mustNil(t, c,
114 "SET", "mies", "toon", "NX",
115 )
116 // lowercase NX is no problem
117 mustNil(t, c,
118 "SET", "mies", "toon", "nx",
119 )
120 })
121
122 // XX argument - only set if exists
123 t.Run("XX", func(t *testing.T) {
124 // new key, no go
125 mustNil(t, c,
126 "SET", "one", "two", "XX",
127 )
128
129 s.Set("one", "three")
130
131 mustOK(t, c,
132 "SET", "one", "two", "XX",
133 )
134 s.CheckGet(t, "one", "two")
135
136 // XX with another key type
137 s.HSet("eleven", "twelve", "thirteen")
138 mustOK(t, c,
139 "SET", "eleven", "fourteen", "XX",
140 )
141 s.CheckGet(t, "eleven", "fourteen")
142 })
143

Callers

nothing calls this directly

Calls 14

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

Tested by

no test coverage detected