Files
Bubberstation/code/modules/unit_tests/autowiki.dm
Mothblocks 3d319f6157 Autowiki - Generate wiki pages through code (#64417)
Adds a /datum/autowiki template which can be derived in order to create wiki pages and queue file uploads. This is then kickstarted by the new tgs target autowiki (using the AUTOWIKI define) in order to upload these pages.

The pages generated are, in a best case scenario, raw data. This means that wiki editors can decide what the actual theme is without ever having to touch the repository. In the future, MSO will hopefully sandbox the wiki and install Scribunto to let us separate data and style even more.

These will, when done, upload to templates, such as Template:Autowiki/VendingMachines. The actual pages (in this case "Vending Machines") will include this, and thus can write down their own prose and whatnot without ever having to touch repo.

This will also be run on a daily GitHub action, with some secrets setup to link to the account. Currently this is on a bot password (my forum account will not be leaked in the event of a collapse), but at some point I would like to create a dedicated bot account.

This PR adds a Techweb and Vending Machine autowiki. You can look at the Vending Machines one here and the Techweb one here.

I have absolutely no idea what to label this PR (other than note the unit tests I've added). Feel free to add whatever gives GBP 😉
2022-01-28 00:30:15 +00:00

36 lines
1.2 KiB
Plaintext

/// Tests that all autowikis generate something without runtiming
/datum/unit_test/autowiki
/datum/unit_test/autowiki/Run()
TEST_ASSERT(istext(generate_autowiki_output()), "generate_autowiki_output() did not finish successfully!")
/// Test that `include_template` produces reasonable results
/datum/unit_test/autowiki_include_template
/datum/unit_test/autowiki_include_template/Run()
var/datum/autowiki/autowiki_api = new
TEST_ASSERT_EQUAL( \
autowiki_api.include_template("Template"), \
"{{Template}}", \
"Basic template did not format correctly" \
)
TEST_ASSERT_EQUAL( \
autowiki_api.include_template("Template", list("name" = "Mothblocks")), \
"{{Template|name=Mothblocks}}", \
"Template with basic arguments did not format correctly" \
)
TEST_ASSERT_EQUAL( \
autowiki_api.include_template("Template", list("name" = autowiki_api.escape_value("P|peline"))), \
"{{Template|name=P{{!}}peline}}", \
"Template with escaped arguments did not format correctly" \
)
TEST_ASSERT_EQUAL( \
autowiki_api.include_template("Template", list("food" = list("fruit", "candy"))), \
"{{Template|food1=fruit|food2=candy}}", \
"Template with array arguments did not format correctly" \
)