Skip to content

Commit e713b8c

Browse files
adiholdenromange
authored andcommitted
remove lmpop unit tests
Also remove sentinel_test.py only for this branch. Signed-off-by: adi_holden <[email protected]> Signed-off-by: Roman Gershman <[email protected]>
1 parent b16b534 commit e713b8c

File tree

2 files changed

+0
-529
lines changed

2 files changed

+0
-529
lines changed

src/server/list_family_test.cc

Lines changed: 0 additions & 221 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,227 +1086,6 @@ TEST_F(ListFamilyTest, ContendExpire) {
10861086
}
10871087
}
10881088

1089-
TEST_F(ListFamilyTest, LMPopInvalidSyntax) {
1090-
// Not enough arguments
1091-
auto resp = Run({"lmpop", "1", "a"});
1092-
EXPECT_THAT(resp, ErrArg("wrong number of arguments"));
1093-
1094-
// Zero keys
1095-
resp = Run({"lmpop", "0", "LEFT", "COUNT", "1"});
1096-
EXPECT_THAT(resp, ErrArg("syntax error"));
1097-
1098-
// Number of keys is not uint
1099-
resp = Run({"lmpop", "aa", "a", "LEFT"});
1100-
EXPECT_THAT(resp, ErrArg("value is not an integer or out of range"));
1101-
1102-
// Missing LEFT/RIGHT
1103-
resp = Run({"lmpop", "1", "a", "COUNT", "1"});
1104-
EXPECT_THAT(resp, ErrArg("syntax error"));
1105-
1106-
// Wrong number of keys
1107-
resp = Run({"lmpop", "1", "a", "b", "LEFT"});
1108-
EXPECT_THAT(resp, ErrArg("syntax error"));
1109-
1110-
// COUNT without number
1111-
resp = Run({"lmpop", "1", "a", "LEFT", "COUNT"});
1112-
EXPECT_THAT(resp, ErrArg("syntax error"));
1113-
1114-
// COUNT is not uint
1115-
resp = Run({"lmpop", "1", "a", "LEFT", "COUNT", "boo"});
1116-
EXPECT_THAT(resp, ErrArg("value is not an integer or out of range"));
1117-
1118-
// Too many arguments
1119-
resp = Run({"lmpop", "1", "c", "LEFT", "COUNT", "2", "foo"});
1120-
EXPECT_THAT(resp, ErrArg("syntax error"));
1121-
}
1122-
1123-
TEST_F(ListFamilyTest, LMPop) {
1124-
// All lists are empty
1125-
auto resp = Run({"lmpop", "1", "e", "LEFT"});
1126-
EXPECT_THAT(resp, ArgType(RespExpr::NIL));
1127-
1128-
// LEFT operation
1129-
resp = Run({"lpush", "a", "a1", "a2"});
1130-
EXPECT_THAT(resp, IntArg(2));
1131-
1132-
resp = Run({"lmpop", "1", "a", "LEFT"});
1133-
EXPECT_THAT(resp, RespArray(ElementsAre("a", RespArray(ElementsAre("a2")))));
1134-
1135-
// RIGHT operation
1136-
resp = Run({"lpush", "b", "b1", "b2"});
1137-
EXPECT_THAT(resp, IntArg(2));
1138-
1139-
resp = Run({"lmpop", "1", "b", "RIGHT"});
1140-
EXPECT_THAT(resp, RespArray(ElementsAre("b", RespArray(ElementsAre("b1")))));
1141-
1142-
// COUNT > 1
1143-
resp = Run({"lpush", "c", "c1", "c2"});
1144-
EXPECT_THAT(resp, IntArg(2));
1145-
1146-
resp = Run({"lmpop", "1", "c", "RIGHT", "COUNT", "2"});
1147-
EXPECT_THAT(resp, RespArray(ElementsAre("c", RespArray(ElementsAre("c1", "c2")))));
1148-
1149-
resp = Run({"llen", "c"});
1150-
EXPECT_THAT(resp, IntArg(0));
1151-
1152-
// COUNT > number of elements in list
1153-
resp = Run({"lpush", "d", "d1", "d2"});
1154-
EXPECT_THAT(resp, IntArg(2));
1155-
1156-
resp = Run({"lmpop", "1", "d", "RIGHT", "COUNT", "3"});
1157-
EXPECT_THAT(resp, RespArray(ElementsAre("d", RespArray(ElementsAre("d1", "d2")))));
1158-
1159-
resp = Run({"llen", "d"});
1160-
EXPECT_THAT(resp, IntArg(0));
1161-
1162-
// First non-empty list is not the first list
1163-
resp = Run({"lpush", "x", "x1"});
1164-
EXPECT_THAT(resp, IntArg(1));
1165-
1166-
resp = Run({"lpush", "y", "y1"});
1167-
EXPECT_THAT(resp, IntArg(1));
1168-
1169-
resp = Run({"lmpop", "3", "empty", "x", "y", "RIGHT"});
1170-
EXPECT_THAT(resp, RespArray(ElementsAre("x", RespArray(ElementsAre("x1")))));
1171-
1172-
resp = Run({"llen", "x"});
1173-
EXPECT_THAT(resp, IntArg(0));
1174-
}
1175-
1176-
TEST_F(ListFamilyTest, LMPopMultipleElements) {
1177-
// Test removing multiple elements from left end
1178-
Run({"rpush", "list1", "a", "b", "c", "d", "e"});
1179-
auto resp = Run({"lmpop", "1", "list1", "LEFT", "COUNT", "3"});
1180-
EXPECT_THAT(resp, RespArray(ElementsAre("list1", RespArray(ElementsAre("a", "b", "c")))));
1181-
1182-
resp = Run({"lrange", "list1", "0", "-1"});
1183-
EXPECT_THAT(resp.GetVec(), ElementsAre("d", "e"));
1184-
1185-
// Test removing multiple elements from right end
1186-
Run({"rpush", "list2", "v", "w", "x", "y", "z"});
1187-
resp = Run({"lmpop", "1", "list2", "RIGHT", "COUNT", "2"});
1188-
EXPECT_THAT(resp, RespArray(ElementsAre("list2", RespArray(ElementsAre("z", "y")))));
1189-
1190-
resp = Run({"lrange", "list2", "0", "-1"});
1191-
EXPECT_THAT(resp.GetVec(), ElementsAre("v", "w", "x"));
1192-
}
1193-
1194-
TEST_F(ListFamilyTest, LMPopMultipleLists) {
1195-
// Test finding first non-empty list
1196-
Run({"rpush", "list1", "a", "b"});
1197-
Run({"rpush", "list2", "c", "d"});
1198-
Run({"rpush", "list3", "e", "f"});
1199-
1200-
// Pop from first non-empty list
1201-
auto resp = Run({"lmpop", "3", "list1", "list2", "list3", "LEFT"});
1202-
EXPECT_THAT(resp, RespArray(ElementsAre("list1", RespArray(ElementsAre("a")))));
1203-
1204-
// Pop from second list after first becomes empty
1205-
Run({"lmpop", "1", "list1", "LEFT"}); // Empty list1
1206-
resp = Run({"lmpop", "3", "list1", "list2", "list3", "RIGHT", "COUNT", "2"});
1207-
EXPECT_THAT(resp, RespArray(ElementsAre("list2", RespArray(ElementsAre("d", "c")))));
1208-
1209-
// Verify third list remains untouched
1210-
resp = Run({"lrange", "list3", "0", "-1"});
1211-
EXPECT_THAT(resp.GetVec(), ElementsAre("e", "f"));
1212-
}
1213-
1214-
TEST_F(ListFamilyTest, LMPopEdgeCases) {
1215-
// Test with empty list
1216-
Run({"rpush", "empty_list", "a"});
1217-
Run({"lpop", "empty_list"});
1218-
auto resp = Run({"lmpop", "1", "empty_list", "LEFT"});
1219-
EXPECT_THAT(resp, ArgType(RespExpr::NIL));
1220-
1221-
// Test with non-existent list
1222-
resp = Run({"lmpop", "1", "nonexistent", "LEFT"});
1223-
EXPECT_THAT(resp, ArgType(RespExpr::NIL));
1224-
1225-
// Test with wrong type key
1226-
Run({"set", "string_key", "value"});
1227-
resp = Run({"lmpop", "1", "string_key", "LEFT"});
1228-
EXPECT_THAT(resp, ErrArg("WRONGTYPE Operation against a key holding the wrong kind of value"));
1229-
1230-
// Test without COUNT parameter - should return 1 element by default
1231-
Run({"rpush", "list", "a", "b"});
1232-
resp = Run({"lmpop", "1", "list", "LEFT"});
1233-
EXPECT_THAT(resp,
1234-
RespArray(ElementsAre(
1235-
"list", RespArray(ElementsAre("a"))))); // Should return 1 element by default
1236-
1237-
// Test with COUNT = 0 - should return error
1238-
resp = Run({"lmpop", "1", "list", "LEFT", "COUNT", "0"});
1239-
EXPECT_THAT(resp, RespArray(ElementsAre("list", RespArray(ElementsAre()))));
1240-
1241-
// Test with negative COUNT - should return error
1242-
resp = Run({"lmpop", "1", "list", "LEFT", "COUNT", "-1"});
1243-
EXPECT_THAT(resp, RespArray(ElementsAre("list", RespArray(ElementsAre("b")))));
1244-
}
1245-
1246-
TEST_F(ListFamilyTest, LMPopDocExample) {
1247-
// Try to pop from non-existing lists
1248-
auto resp = Run({"LMPOP", "2", "non1", "non2", "LEFT", "COUNT", "10"});
1249-
EXPECT_THAT(resp, ArgType(RespExpr::NIL));
1250-
1251-
// Create first list and test basic pop
1252-
resp = Run({"LPUSH", "mylist", "one", "two", "three", "four", "five"});
1253-
EXPECT_THAT(resp, IntArg(5));
1254-
1255-
resp = Run({"LMPOP", "1", "mylist", "LEFT"});
1256-
EXPECT_THAT(resp, RespArray(ElementsAre("mylist", RespArray(ElementsAre("five")))));
1257-
1258-
resp = Run({"LRANGE", "mylist", "0", "-1"});
1259-
EXPECT_THAT(resp.GetVec(), ElementsAre("four", "three", "two", "one"));
1260-
1261-
// Test RIGHT pop with COUNT
1262-
resp = Run({"LMPOP", "1", "mylist", "RIGHT", "COUNT", "10"});
1263-
EXPECT_THAT(resp, RespArray(ElementsAre("mylist",
1264-
RespArray(ElementsAre("one", "two", "three", "four")))));
1265-
1266-
// Create two lists and test multi-key pop
1267-
resp = Run({"LPUSH", "mylist", "one", "two", "three", "four", "five"});
1268-
EXPECT_THAT(resp, IntArg(5));
1269-
1270-
resp = Run({"LPUSH", "mylist2", "a", "b", "c", "d", "e"});
1271-
EXPECT_THAT(resp, IntArg(5));
1272-
1273-
resp = Run({"LMPOP", "2", "mylist", "mylist2", "RIGHT", "COUNT", "3"});
1274-
EXPECT_THAT(resp,
1275-
RespArray(ElementsAre("mylist", RespArray(ElementsAre("one", "two", "three")))));
1276-
1277-
resp = Run({"LRANGE", "mylist", "0", "-1"});
1278-
EXPECT_THAT(resp.GetVec(), ElementsAre("five", "four"));
1279-
1280-
resp = Run({"LMPOP", "2", "mylist", "mylist2", "RIGHT", "COUNT", "5"});
1281-
EXPECT_THAT(resp, RespArray(ElementsAre("mylist", RespArray(ElementsAre("four", "five")))));
1282-
1283-
resp = Run({"LMPOP", "2", "mylist", "mylist2", "RIGHT", "COUNT", "10"});
1284-
EXPECT_THAT(resp,
1285-
RespArray(ElementsAre("mylist2", RespArray(ElementsAre("a", "b", "c", "d", "e")))));
1286-
1287-
// Verify both lists are now empty
1288-
resp = Run({"EXISTS", "mylist", "mylist2"});
1289-
EXPECT_THAT(resp, IntArg(0));
1290-
}
1291-
1292-
TEST_F(ListFamilyTest, LMPopWrongType) {
1293-
// Setup: create a list and a hash
1294-
Run({"lpush", "l1", "e1"});
1295-
Run({"hset", "foo", "k1", "v1"});
1296-
1297-
// Test: first key is wrong type
1298-
auto resp = Run({"lmpop", "2", "foo", "l1", "left"});
1299-
EXPECT_THAT(resp, ErrArg("WRONGTYPE Operation against a key holding the wrong kind of value"));
1300-
1301-
// Test: second key is wrong type but first doesn't exist
1302-
resp = Run({"lmpop", "2", "nonexistent", "foo", "left"});
1303-
EXPECT_THAT(resp, ErrArg("WRONGTYPE Operation against a key holding the wrong kind of value"));
1304-
1305-
// Test: second key is wrong type but first is a valid list
1306-
resp = Run({"lmpop", "2", "l1", "foo", "left"});
1307-
EXPECT_THAT(resp, RespArray(ElementsAre("l1", RespArray(ElementsAre("e1")))));
1308-
}
1309-
13101089
// Reproduce a flow that trigerred a wrong DCHECK in the transaction flow.
13111090
TEST_F(ListFamilyTest, AwakeMulti) {
13121091
auto f1 = pp_->at(1)->LaunchFiber(Launch::dispatch, [&] {

0 commit comments

Comments
 (0)