aboutsummaryrefslogtreecommitdiff
path: root/builtin/mainmenu/tests
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2021-01-22 15:08:57 +0000
committerGitHub <noreply@github.com>2021-01-22 15:08:57 +0000
commit67aa75d444d0e5cfff2728dbbcffd6f95b2fe88b (patch)
treef3a2079a9b17056508e8197a701cf90447e4ea4b /builtin/mainmenu/tests
parent4fcd000e20a26120349184cb9d40342b7876e6b8 (diff)
downloadminetest-67aa75d444d0e5cfff2728dbbcffd6f95b2fe88b.tar.gz
minetest-67aa75d444d0e5cfff2728dbbcffd6f95b2fe88b.tar.bz2
minetest-67aa75d444d0e5cfff2728dbbcffd6f95b2fe88b.zip
Use JSON for favorites, move server list code to Lua (#10085)
Co-authored-by: sfan5 <sfan5@live.de>
Diffstat (limited to 'builtin/mainmenu/tests')
-rw-r--r--builtin/mainmenu/tests/favorites_wellformed.txt29
-rw-r--r--builtin/mainmenu/tests/serverlistmgr_spec.lua36
2 files changed, 65 insertions, 0 deletions
diff --git a/builtin/mainmenu/tests/favorites_wellformed.txt b/builtin/mainmenu/tests/favorites_wellformed.txt
new file mode 100644
index 000000000..8b87b4398
--- /dev/null
+++ b/builtin/mainmenu/tests/favorites_wellformed.txt
@@ -0,0 +1,29 @@
+[server]
+
+127.0.0.1
+30000
+
+
+[server]
+
+localhost
+30000
+
+
+[server]
+
+vps.rubenwardy.com
+30001
+
+
+[server]
+
+gundul.ddnss.de
+39155
+
+
+[server]
+VanessaE's Dreambuilder creative Server
+daconcepts.com
+30000
+VanessaE's Dreambuilder creative-mode server. Lots of mods, whitelisted buckets.
diff --git a/builtin/mainmenu/tests/serverlistmgr_spec.lua b/builtin/mainmenu/tests/serverlistmgr_spec.lua
new file mode 100644
index 000000000..148e9b794
--- /dev/null
+++ b/builtin/mainmenu/tests/serverlistmgr_spec.lua
@@ -0,0 +1,36 @@
+_G.core = {}
+_G.unpack = table.unpack
+_G.serverlistmgr = {}
+
+dofile("builtin/common/misc_helpers.lua")
+dofile("builtin/mainmenu/serverlistmgr.lua")
+
+local base = "builtin/mainmenu/tests/"
+
+describe("legacy favorites", function()
+ it("loads well-formed correctly", function()
+ local favs = serverlistmgr.read_legacy_favorites(base .. "favorites_wellformed.txt")
+
+ local expected = {
+ {
+ address = "127.0.0.1",
+ port = 30000,
+ },
+
+ { address = "localhost", port = 30000 },
+
+ { address = "vps.rubenwardy.com", port = 30001 },
+
+ { address = "gundul.ddnss.de", port = 39155 },
+
+ {
+ address = "daconcepts.com",
+ port = 30000,
+ name = "VanessaE's Dreambuilder creative Server",
+ description = "VanessaE's Dreambuilder creative-mode server. Lots of mods, whitelisted buckets."
+ },
+ }
+
+ assert.same(expected, favs)
+ end)
+end)