Test SISMEMBER
(t *testing.T)
| 121 | |
| 122 | // Test SISMEMBER |
| 123 | func TestSismember(t *testing.T) { |
| 124 | server.Clear() |
| 125 | c, err := proto.Dial(server.Addr()) |
| 126 | ok(t, err) |
| 127 | defer c.Close() |
| 128 | s := server.Direct() |
| 129 | |
| 130 | s.SetAdd("s", "aap", "noot", "mies") |
| 131 | |
| 132 | { |
| 133 | must1(t, c, "SISMEMBER", "s", "aap") |
| 134 | |
| 135 | must0(t, c, "SISMEMBER", "s", "nosuch") |
| 136 | } |
| 137 | |
| 138 | // a nonexisting key |
| 139 | must0(t, c, "SISMEMBER", "nosuch", "nosuch") |
| 140 | |
| 141 | t.Run("direct usage", func(t *testing.T) { |
| 142 | isMember, err := s.IsMember("s", "noot") |
| 143 | ok(t, err) |
| 144 | equals(t, true, isMember) |
| 145 | }) |
| 146 | |
| 147 | t.Run("errors", func(t *testing.T) { |
| 148 | mustOK(t, c, "SET", "str", "value") |
| 149 | mustDo(t, c, |
| 150 | "SISMEMBER", "str", "foo", |
| 151 | proto.Error(msgWrongType), |
| 152 | ) |
| 153 | mustDo(t, c, |
| 154 | "SISMEMBER", |
| 155 | proto.Error(errWrongNumber("sismember")), |
| 156 | ) |
| 157 | mustDo(t, c, |
| 158 | "SISMEMBER", "set", |
| 159 | proto.Error(errWrongNumber("sismember")), |
| 160 | ) |
| 161 | mustDo(t, c, |
| 162 | "SISMEMBER", "set", "spurious", "args", |
| 163 | proto.Error(errWrongNumber("sismember")), |
| 164 | ) |
| 165 | }) |
| 166 | } |
| 167 | |
| 168 | // Test SREM |
| 169 | func TestSrem(t *testing.T) { |
nothing calls this directly
no test coverage detected