From 2f1332739e4190d47c3fb4f7663f105966d71e02 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:14:18 -0700 Subject: [PATCH] added notify_bad test --- .../commands/test/tests/init.lua | 1 + .../commands/test/tests/notify_bad.test.lua | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 worldeditadditions_commands/commands/test/tests/notify_bad.test.lua diff --git a/worldeditadditions_commands/commands/test/tests/init.lua b/worldeditadditions_commands/commands/test/tests/init.lua index 0de4226..7577afb 100644 --- a/worldeditadditions_commands/commands/test/tests/init.lua +++ b/worldeditadditions_commands/commands/test/tests/init.lua @@ -2,6 +2,7 @@ local test_id_paths = { "credits.test.lua", "notify.test.lua", + "notify_bad.test.lua", -- "stacktrace.test.lua", } diff --git a/worldeditadditions_commands/commands/test/tests/notify_bad.test.lua b/worldeditadditions_commands/commands/test/tests/notify_bad.test.lua new file mode 100644 index 0000000..16afeb6 --- /dev/null +++ b/worldeditadditions_commands/commands/test/tests/notify_bad.test.lua @@ -0,0 +1,27 @@ +local Notify = worldeditadditions_core.notify +return worldeditadditions.normalize_test("notifybad", { + params = "N/A", + description = "Sends badly formed messages to player to test error handling.", + func = function(name, params_table) + local target = function(n) + if not n then n = 16 end + local ret = "" + for _ = 1, n do ret = ret .. string.char(math.random(36, 126)) end + return ret + end + local message = "This is a test..." + + Notify.warn(name, "Name is not string test:") + Notify.info(target, message) -- Name not a string + Notify.info(name, "Error should be logged to debug.text at " .. os.date('%Y-%m-%d %H:%M:%S')) + + Notify.warn(name, "Invalid name test:") + Notify.info(target(), message) -- Bad name + + Notify.warn(name, "Message is not string test:") + Notify.info(name, params_table) -- Message not a string + + Notify.warn(name, "Invalid color test:") + Notify.custom(name, "bad", message, "#FF00") -- Bad colour + end +}) \ No newline at end of file