-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStringCommandTest.java
More file actions
53 lines (43 loc) · 1.25 KB
/
Copy pathStringCommandTest.java
File metadata and controls
53 lines (43 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.vaultdb;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
class StringCommandTest {
private VaultDBEngine engine;
@BeforeEach
void setUp() {
engine = new VaultDBEngine();
}
@Test
void pingReturnsPong() {
assertEquals("PONG", engine.ping());
}
@Test
void setAndGetString() throws IOException {
String response = TestSupport.execute(engine, "SET", "name", "vault");
assertTrue(response.startsWith("+OK"));
assertEquals("vault", engine.get("name"));
}
@Test
void getMissingKeyReturnsNull() {
assertNull(engine.get("missing"));
}
@Test
void delRemovesKeys() {
engine.set("a", "1");
engine.set("b", "2");
assertEquals(2, engine.del("a", "b"));
assertEquals(0, engine.exists("a", "b"));
}
@Test
void incrAndDecrWork() {
assertEquals(1, engine.incr("count"));
assertEquals(2, engine.incr("count"));
assertEquals(1, engine.decr("count"));
assertEquals("1", engine.get("count"));
}
}