2021-05-13 08:15:14 +02:00
|
|
|
package msend_test
|
|
|
|
|
|
|
|
import (
|
2021-06-24 06:56:00 +02:00
|
|
|
"fmt"
|
2021-05-13 08:15:14 +02:00
|
|
|
"testing"
|
|
|
|
|
2024-09-17 07:33:26 +02:00
|
|
|
"go-mod.ewintr.nl/go-kit/test"
|
|
|
|
"go-mod.ewintr.nl/gte/pkg/msend"
|
2021-05-13 08:15:14 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMemorySend(t *testing.T) {
|
|
|
|
mem := msend.NewMemory()
|
|
|
|
test.Equals(t, []*msend.Message{}, mem.Messages)
|
|
|
|
|
|
|
|
msg1 := &msend.Message{Subject: "sub1", Body: "body1"}
|
|
|
|
test.OK(t, mem.Send(msg1))
|
|
|
|
test.Equals(t, []*msend.Message{msg1}, mem.Messages)
|
|
|
|
|
|
|
|
msg2 := &msend.Message{Subject: "sub2", Body: "body2"}
|
|
|
|
test.OK(t, mem.Send(msg2))
|
|
|
|
test.Equals(t, []*msend.Message{msg1, msg2}, mem.Messages)
|
2021-06-24 06:56:00 +02:00
|
|
|
|
|
|
|
expErr := fmt.Errorf("oh no")
|
|
|
|
mem.Err = expErr
|
|
|
|
actErr := mem.Send(msg1)
|
|
|
|
test.Equals(t, expErr, actErr)
|
2021-05-13 08:15:14 +02:00
|
|
|
}
|