(t *testing.T)
| 281 | } |
| 282 | |
| 283 | func TestRPushPop(t *testing.T) { |
| 284 | server.Clear() |
| 285 | c, err := proto.Dial(server.Addr()) |
| 286 | ok(t, err) |
| 287 | defer c.Close() |
| 288 | s := server.Direct() |
| 289 | { |
| 290 | mustDo(t, c, |
| 291 | "RPUSH", "l", "aap", "noot", "mies", |
| 292 | proto.Int(3), |
| 293 | ) |
| 294 | |
| 295 | mustDo(t, c, |
| 296 | "LRANGE", "l", "0", "0", |
| 297 | proto.Strings("aap"), |
| 298 | ) |
| 299 | |
| 300 | mustDo(t, c, |
| 301 | "LRANGE", "l", "-1", "-1", |
| 302 | proto.Strings("mies"), |
| 303 | ) |
| 304 | } |
| 305 | |
| 306 | // Push more. |
| 307 | { |
| 308 | mustDo(t, c, |
| 309 | "RPUSH", "l", "aap2", "noot2", "mies2", |
| 310 | proto.Int(6), |
| 311 | ) |
| 312 | |
| 313 | mustDo(t, c, |
| 314 | "LRANGE", "l", "0", "0", |
| 315 | proto.Strings("aap"), |
| 316 | ) |
| 317 | |
| 318 | mustDo(t, c, |
| 319 | "LRANGE", "l", "-1", "-1", |
| 320 | proto.Strings("mies2"), |
| 321 | ) |
| 322 | } |
| 323 | |
| 324 | // Direct usage |
| 325 | { |
| 326 | l, err := s.Push("l2", "a") |
| 327 | ok(t, err) |
| 328 | equals(t, 1, l) |
| 329 | l, err = s.Push("l2", "b") |
| 330 | ok(t, err) |
| 331 | equals(t, 2, l) |
| 332 | list, err := s.List("l2") |
| 333 | ok(t, err) |
| 334 | equals(t, []string{"a", "b"}, list) |
| 335 | |
| 336 | el, err := s.Pop("l2") |
| 337 | ok(t, err) |
| 338 | equals(t, "b", el) |
| 339 | el, err = s.Pop("l2") |
| 340 | ok(t, err) |
nothing calls this directly
no test coverage detected