mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-10 00:43:14 +00:00
## About The Pull Request Basically every single CI Run is throwing the following warning: ```txt code/modules/unit_tests/lootpanel.dm:24:warning (unused_var): new_box: variable defined but not used ``` You may find an example here: https://github.com/tgstation/tgstation/actions/runs/8698627681/job/23855921813#step:9:24 This is pretty silly but I don't really know why we even have this variable (I assume there's something far more complicated underneath the surface based on what the unit test is asserting), but assuming it is important let's just insert a do-nothing procedure to get rid of the compiler warning while ensuring the unit test is actually operating as it should. I also don't really like the fact that this is a warning instead of an error but let's tackle this problem one step at a time by at least getting rid of the compiler warning in a quick advance PR while I dwell on this issue (is there a way to get the Dreamchecker linter to look at the unit test files? it's caught perfectly fine in the langserver) --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
36 lines
1.6 KiB
Plaintext
36 lines
1.6 KiB
Plaintext
/datum/unit_test/lootpanel
|
|
abstract_type = /datum/unit_test/lootpanel
|
|
|
|
/datum/unit_test/lootpanel/contents/Run()
|
|
var/datum/client_interface/mock_client = new()
|
|
var/datum/lootpanel/panel = new(mock_client)
|
|
var/mob/living/carbon/human/labrat = allocate(/mob/living/carbon/human/consistent)
|
|
mock_client.mob = labrat
|
|
var/turf/one_over = locate(run_loc_floor_bottom_left.x + 1, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)
|
|
var/obj/item/storage/toolbox/box = allocate(/obj/item/storage/toolbox, one_over)
|
|
|
|
panel.open(one_over)
|
|
TEST_ASSERT_EQUAL(length(panel.contents), 2, "Contents should populate on open")
|
|
TEST_ASSERT_EQUAL(length(panel.to_image), 2, "to_image should've populated (unit testing)")
|
|
TEST_ASSERT_EQUAL(panel.contents[1].item, one_over, "First item should be the source turf")
|
|
|
|
var/datum/search_object/searchable = panel.contents[2]
|
|
TEST_ASSERT_EQUAL(searchable.item, box, "Second item should be the box")
|
|
|
|
qdel(box)
|
|
TEST_ASSERT_EQUAL(length(panel.contents), 1, "Contents should update on searchobj deleted")
|
|
TEST_ASSERT_EQUAL(length(panel.to_image), 1, "to_image should update on searchobj deleted")
|
|
|
|
allocate(/obj/item/storage/toolbox, one_over)
|
|
TEST_ASSERT_EQUAL(length(panel.contents), 1, "Contents shouldn't update, we're dumb")
|
|
TEST_ASSERT_EQUAL(length(panel.to_image), 1, "to_image shouldn't update, we're dumb")
|
|
|
|
panel.populate_contents() // this also calls reset_contents bc length(contents)
|
|
TEST_ASSERT_EQUAL(length(panel.contents), 2, "Contents should repopulate with the new toolbox")
|
|
|
|
panel.populate_contents()
|
|
TEST_ASSERT_EQUAL(length(panel.contents), 2, "Panel shouldnt dupe searchables if reopened")
|
|
|
|
mock_client.mob = null
|
|
|