This commit is contained in:
BuckarooBanzay 2023-03-28 15:47:53 +02:00 committed by Athozus
parent dff068d75b
commit e8c7fde4c3
No known key found for this signature in database
GPG key ID: B50895022E8484BF
8 changed files with 95 additions and 20 deletions

39
storage.spec.lua Normal file
View file

@ -0,0 +1,39 @@
mtt.register("storage", function(callback)
-- sanity checks
local playername = "player1"
local entry = mail.get_storage_entry(playername)
assert(entry)
-- create
local contact = {
name = "other-player",
note = "my-note"
}
mail.update_contact(playername, contact)
-- read
local contacts = mail.get_contacts(playername)
assert(#contacts == 1)
assert(contacts[1].note == contact.note)
assert(contacts[1].name == contact.name)
-- update
mail.update_contact(playername, {
name = contact.name,
note = "xy"
})
-- read updated
contacts = mail.get_contacts(playername)
assert(#contacts == 1)
assert(contacts[1].note == "xy")
assert(contacts[1].name == contact.name)
-- delete
mail.delete_contact(playername, contact.name)
contacts = mail.get_contacts(playername)
assert(#contacts == 0)
callback()
end)