mirror of
https://github.com/mt-mods/mail.git
synced 2025-07-12 09:22:20 -04:00
tests
This commit is contained in:
parent
dff068d75b
commit
e8c7fde4c3
8 changed files with 95 additions and 20 deletions
39
storage.spec.lua
Normal file
39
storage.spec.lua
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue