Diff

spec/core_storagemanager_spec.lua @ 13133:3692265becb7

storagemanager tests: Reorder test data in chronological order Why was the test data not in chronological order? Altho, maybe that was the point? Except for MAM, the data might *not* be in chronological order!
author Kim Alvefur <zash@zash.se>
date Tue, 11 May 2021 02:04:59 +0200
parent 12956:52fcdfe710ca
child 13243:c5ccdfbbe9c1
line wrap: on
line diff
--- a/spec/core_storagemanager_spec.lua	Fri Jun 09 17:38:46 2023 +0200
+++ b/spec/core_storagemanager_spec.lua	Tue May 11 02:04:59 2021 +0200
@@ -341,13 +341,13 @@
 				local test_time = 1539204123;
 
 				local test_data = {
-					{ nil, test_stanza, test_time, "contact@example.com" };
-					{ nil, test_stanza, test_time+1, "contact2@example.com" };
-					{ nil, test_stanza, test_time+2, "contact2@example.com" };
+					{ nil, test_stanza, test_time-3, "contact@example.com" };
+					{ nil, test_stanza, test_time-2, "contact2@example.com" };
 					{ nil, test_stanza, test_time-1, "contact2@example.com" };
-					{ nil, test_stanza, test_time-1, "contact3@example.com" };
-					{ nil, test_stanza, test_time+0, "contact3@example.com" };
+					{ nil, test_stanza, test_time+0, "contact2@example.com" };
 					{ nil, test_stanza, test_time+1, "contact3@example.com" };
+					{ nil, test_stanza, test_time+2, "contact3@example.com" };
+					{ nil, test_stanza, test_time+3, "contact3@example.com" };
 				};
 
 				it("can be added to", function ()
@@ -390,7 +390,7 @@
 							assert.equal("test", item.name);
 							assert.equal("urn:example:foo", item.attr.xmlns);
 							assert.equal(2, #item.tags);
-							assert.equal(test_time, when);
+							assert.equal(test_time-3, when);
 						end
 						assert.equal(1, count);
 					end);
@@ -428,16 +428,16 @@
 							assert.equal("test", item.name);
 							assert.equal("urn:example:foo", item.attr.xmlns);
 							assert.equal(2, #item.tags);
-							assert(test_time <= when);
+							assert(when >= test_time, ("%d >= %d"):format(when, test_time));
 						end
-						assert.equal(#test_data - 2, count);
+						assert.equal(#test_data - 3, count);
 					end);
 
 					it("by time (start+end)", function ()
 						-- luacheck: ignore 211/err
 						local data, err = archive:find("user", {
-							["start"] = test_time;
-							["end"] = test_time+1;
+							["start"] = test_time-1;
+							["end"] = test_time+2;
 						});
 						assert.truthy(data);
 						local count = 0;
@@ -448,8 +448,8 @@
 							assert.equal("test", item.name);
 							assert.equal("urn:example:foo", item.attr.xmlns);
 							assert.equal(2, #item.tags);
-							assert(when >= test_time, ("%d >= %d"):format(when, test_time));
-							assert(when <= test_time+1, ("%d <= %d"):format(when, test_time+1));
+							assert(when >= test_time-1, ("%d >= %d"):format(when, test_time));
+							assert(when <= test_time+2, ("%d <= %d"):format(when, test_time+1));
 						end
 						assert.equal(4, count);
 					end);
@@ -596,7 +596,7 @@
 					local data, err = archive:find("user", {
 						with = "contact@example.com";
 					});
-					assert.truthy(data);
+					assert.truthy(data, err);
 					local count = 0;
 					for id, item, when in data do -- luacheck: ignore id item when
 						count = count + 1;