1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 01:57:02 +00:00

chore: create Lua test helper (#532)

* Create lua test helper

Signed-off-by: James Hillyerd <james@hillyerd.com>

* Assert labels

Signed-off-by: James Hillyerd <james@hillyerd.com>

---------

Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
James Hillyerd
2024-09-29 11:46:01 -07:00
committed by GitHub
parent b1b7e4b07c
commit 5284171dc5
6 changed files with 135 additions and 117 deletions

View File

@@ -4,9 +4,9 @@ import (
"net/mail"
"testing"
"github.com/inbucket/inbucket/v3/pkg/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
lua "github.com/yuin/gopher-lua"
)
func TestMailAddressGetters(t *testing.T) {
@@ -26,8 +26,9 @@ func TestMailAddressGetters(t *testing.T) {
assert(got == want, string.format("got address %q, want %q", got, want))
`
ls := lua.NewState()
ls, _ := test.NewLuaState()
registerMailAddressType(ls)
ls.SetGlobal("addr", wrapMailAddress(ls, want))
require.NoError(t, ls.DoString(script))
}
@@ -44,9 +45,10 @@ func TestMailAddressSetters(t *testing.T) {
addr.address = "ri@example.com"
`
got := &mail.Address{}
ls := lua.NewState()
ls, _ := test.NewLuaState()
registerMailAddressType(ls)
got := &mail.Address{}
ls.SetGlobal("addr", wrapMailAddress(ls, got))
require.NoError(t, ls.DoString(script))