1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-14 20:20:30 +00:00

Improve motd a hundred fold

Yes, I know this is a terrible feature. But it's been a long week and
I'm so tired.

Also fix the ordering in motd_spec. Who thought putting the month first
was reasonable?
This commit is contained in:
Jonathan Coates 2021-10-08 20:48:17 +01:00
parent 9f539dbd59
commit 045472577a
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
2 changed files with 15 additions and 7 deletions

View File

@ -5,6 +5,8 @@ elseif date.month == 12 and date.day == 24 then
print("Merry X-mas!") print("Merry X-mas!")
elseif date.month == 10 and date.day == 31 then elseif date.month == 10 and date.day == 31 then
print("OOoooOOOoooo! Spooky!") print("OOoooOOOoooo! Spooky!")
elseif date.month == 4 and date.day == 28 then
print("Ed Balls")
else else
local tMotd = {} local tMotd = {}

View File

@ -1,8 +1,8 @@
local capture = require "test_helpers".capture_program local capture = require "test_helpers".capture_program
describe("The motd program", function() describe("The motd program", function()
local function setup_date(month, day) local function setup_date(day, month)
stub(os, "date", function() return { month = month, day = day } end) stub(os, "date", function() return { day = day, month = month } end)
end end
it("displays MOTD", function() it("displays MOTD", function()
@ -16,20 +16,26 @@ describe("The motd program", function()
:matches { ok = true, output = "Hello World!\n", error = "" } :matches { ok = true, output = "Hello World!\n", error = "" }
end) end)
it("displays date-specific MOTD (1/1)", function() it("displays date-specific MOTD (1 Jan)", function()
setup_date(1, 1) setup_date(1, 1)
expect(capture(stub, "motd")) expect(capture(stub, "motd"))
:matches { ok = true, output = "Happy new year!\n", error = "" } :matches { ok = true, output = "Happy new year!\n", error = "" }
end) end)
it("displays date-specific MOTD (10/31)", function() it("displays date-specific MOTD (28 Apr)", function()
setup_date(10, 31) setup_date(28, 4)
expect(capture(stub, "motd"))
:matches { ok = true, output = "Ed Balls\n", error = "" }
end)
it("displays date-specific MOTD (31 Oct)", function()
setup_date(31, 10)
expect(capture(stub, "motd")) expect(capture(stub, "motd"))
:matches { ok = true, output = "OOoooOOOoooo! Spooky!\n", error = "" } :matches { ok = true, output = "OOoooOOOoooo! Spooky!\n", error = "" }
end) end)
it("displays date-specific MOTD (12/24)", function() it("displays date-specific MOTD (24 Dec)", function()
setup_date(12, 24) setup_date(24, 12)
expect(capture(stub, "motd")) expect(capture(stub, "motd"))
:matches { ok = true, output = "Merry X-mas!\n", error = "" } :matches { ok = true, output = "Merry X-mas!\n", error = "" }
end) end)