(t *testing.T)
| 84 | } |
| 85 | |
| 86 | func 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 |
nothing calls this directly
no test coverage detected