2021-01-28 14:43:00 +01:00
|
|
|
package mstore_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-05-13 09:47:06 +02:00
|
|
|
"git.ewintr.nl/go-kit/test"
|
|
|
|
"git.ewintr.nl/gte/pkg/mstore"
|
2021-01-28 14:43:00 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMessageValid(t *testing.T) {
|
|
|
|
for _, tc := range []struct {
|
|
|
|
name string
|
|
|
|
message *mstore.Message
|
|
|
|
exp bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty",
|
|
|
|
message: &mstore.Message{},
|
|
|
|
},
|
|
|
|
{
|
2021-01-29 12:29:23 +01:00
|
|
|
name: "no uid",
|
|
|
|
message: &mstore.Message{
|
|
|
|
Subject: "subject",
|
|
|
|
Folder: "folder",
|
|
|
|
Body: "body",
|
|
|
|
},
|
2021-01-28 14:43:00 +01:00
|
|
|
},
|
|
|
|
{
|
2021-01-29 12:29:23 +01:00
|
|
|
name: "no folder",
|
|
|
|
message: &mstore.Message{
|
|
|
|
Uid: 1,
|
|
|
|
Subject: "subject",
|
|
|
|
Body: "body",
|
|
|
|
},
|
2021-01-28 14:43:00 +01:00
|
|
|
},
|
|
|
|
{
|
2021-01-29 12:29:23 +01:00
|
|
|
name: "no subject",
|
|
|
|
message: &mstore.Message{
|
|
|
|
Uid: 1,
|
|
|
|
Folder: "folder",
|
|
|
|
Body: "body",
|
|
|
|
},
|
2021-01-28 14:43:00 +01:00
|
|
|
},
|
|
|
|
{
|
2021-01-29 12:29:23 +01:00
|
|
|
name: "no body",
|
|
|
|
message: &mstore.Message{
|
|
|
|
Uid: 1,
|
|
|
|
Folder: "folder",
|
|
|
|
Subject: "subject",
|
|
|
|
},
|
|
|
|
exp: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "all present",
|
|
|
|
message: &mstore.Message{
|
|
|
|
Uid: 1,
|
|
|
|
Folder: "folder",
|
|
|
|
Subject: "subject",
|
|
|
|
Body: "body",
|
|
|
|
},
|
|
|
|
exp: true,
|
2021-01-28 14:43:00 +01:00
|
|
|
},
|
|
|
|
} {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
test.Equals(t, tc.exp, tc.message.Valid())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|