mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-09-21 17:04:00 +00:00
Address review on the test framework
- The registry is a Suite, created around the environment factory it runs its tests with, so the plugin's env.lua reads as: build environments, hand the test files a suite of them. The suite returned there becomes `...` in each test file, which is now said where it happens. - pass and fail are the primitives every other check goes through. eq and deep_eq assert rather than compare, failing with both values in the detail. - Stubs are extended through extend_requires, extend_script, extend_game and extend_defines, a recursive merge which raises when a value already exists, rather than by mutating the tables. The strict labels carry the factorio class names. - The stubs record registered metatables and can save and load the script data the way factorio does: functions are refused and only registered metatables survive. env.save_load() uses it, and a new on_load test shows role methods and held roles surviving the round trip, which only passes because the module registers its metatable. - The names helper moved out of the shared framework, it is role specific. - Tests are named after the function or method they cover, on both sides: the lua tests read as "role:assign applies locally and is sent", and the javascript files wrap their tests in the class they exercise with subtests per method. module.test.js is control.test.js, after the file it covers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
24d36db601
commit
7adcdde9dc
@@ -7,7 +7,7 @@ const fullMeta = new messages.RoleMetaRecord(
|
||||
7, 3, 1, "Mod", "[Mod]", new messages.RoleColor(1, 2, 3), 3600000, true, 12345, false,
|
||||
);
|
||||
|
||||
t.test("RoleColor", subtest => {
|
||||
t.test("class RoleColor", subtest => {
|
||||
testRoundTripJsonSerialisable(messages.RoleColor, testMatrix(
|
||||
[0, 255], // r
|
||||
[0, 128], // g
|
||||
@@ -17,7 +17,7 @@ t.test("RoleColor", subtest => {
|
||||
subtest.end();
|
||||
});
|
||||
|
||||
t.test("RoleMetaRecord", subtest => {
|
||||
t.test("class RoleMetaRecord", subtest => {
|
||||
testRoundTripJsonSerialisable(messages.RoleMetaRecord, testMatrix(
|
||||
[7], // id
|
||||
[3], // order
|
||||
@@ -34,7 +34,7 @@ t.test("RoleMetaRecord", subtest => {
|
||||
subtest.end();
|
||||
});
|
||||
|
||||
t.test("RoleRecord", subtest => {
|
||||
t.test("class RoleRecord", subtest => {
|
||||
testRoundTripJsonSerialisable(messages.RoleRecord, testMatrix(
|
||||
[7], // id
|
||||
["Moderator"], // name
|
||||
@@ -48,7 +48,7 @@ t.test("RoleRecord", subtest => {
|
||||
subtest.end();
|
||||
});
|
||||
|
||||
t.test("AssignmentRecord", subtest => {
|
||||
t.test("class AssignmentRecord", subtest => {
|
||||
testRoundTripJsonSerialisable(messages.AssignmentRecord, testMatrix(
|
||||
["alice"], // name
|
||||
[new Set(), new Set([5, 6])], // roleIds
|
||||
@@ -59,19 +59,34 @@ t.test("AssignmentRecord", subtest => {
|
||||
subtest.end();
|
||||
});
|
||||
|
||||
t.test("update events and requests", subtest => {
|
||||
const record = new messages.RoleRecord(7, "Moderator", ["a.b"], fullMeta, true, 12345);
|
||||
const assignment = new messages.AssignmentRecord("alice", new Set([5]), 12345);
|
||||
const sampleRecord = new messages.RoleRecord(7, "Moderator", ["a.b"], fullMeta, true, 12345);
|
||||
const sampleAssignment = new messages.AssignmentRecord("alice", new Set([5]), 12345);
|
||||
|
||||
t.test("class RoleUpdatedEvent", subtest => {
|
||||
testRoundTripJsonSerialisable(messages.RoleUpdatedEvent, testMatrix(
|
||||
[[], [record]], // updates
|
||||
[[], [sampleRecord]], // updates
|
||||
));
|
||||
subtest.pass("round trips");
|
||||
subtest.end();
|
||||
});
|
||||
|
||||
t.test("class AssignmentUpdatedEvent", subtest => {
|
||||
testRoundTripJsonSerialisable(messages.AssignmentUpdatedEvent, testMatrix(
|
||||
[[], [assignment]], // updates
|
||||
[[], [sampleAssignment]], // updates
|
||||
));
|
||||
subtest.pass("round trips");
|
||||
subtest.end();
|
||||
});
|
||||
|
||||
t.test("class RoleMetaUpdateRequest", subtest => {
|
||||
testRoundTripJsonSerialisable(messages.RoleMetaUpdateRequest, testMatrix(
|
||||
[new messages.RoleMetaRecord(7, 3), fullMeta], // meta
|
||||
));
|
||||
subtest.pass("round trips");
|
||||
subtest.end();
|
||||
});
|
||||
|
||||
t.test("class AssignmentUpdateRequest", subtest => {
|
||||
testRoundTripJsonSerialisable(messages.AssignmentUpdateRequest, testMatrix(
|
||||
["alice"], // name
|
||||
[[], [5]], // assign
|
||||
|
||||
Reference in New Issue
Block a user