Test simple GET/SET keys
(t *testing.T)
| 30 | |
| 31 | // Test simple GET/SET keys |
| 32 | func 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 | |
| 86 | func TestSet(t *testing.T) { |
| 87 | server.Clear() |
nothing calls this directly
no test coverage detected