/
envelopes_test.go
45 lines (37 loc) · 1010 Bytes
/
envelopes_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package chatable
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type EnvelopeTestSuite struct {
suite.Suite
outgoing *Envelope
incoming *Envelope
}
func (e *EnvelopeTestSuite) SetupTest() {
env1, env2 := NewEnvelope(1, 2, "hello", MessageTypeText)
e.outgoing = env1
e.incoming = env2
}
func (e *EnvelopeTestSuite) TestIsRead() {
e.False(e.outgoing.IsRead())
e.False(e.outgoing.IsRead())
}
func (e *EnvelopeTestSuite) TestIsDeleted() {
e.False(e.outgoing.IsDeleted())
e.False(e.outgoing.IsDeleted())
}
func TestEnvelope(t *testing.T) {
suite.Run(t, new(EnvelopeTestSuite))
}
func TestNewEnvelope(t *testing.T) {
out, in := NewEnvelope(1, 2, "hello", MessageTypeText)
assert.Equal(t, out.CreatedAt, in.CreatedAt)
assert.Equal(t, out.Message, in.Message)
assert.Equal(t, out.MessageType, in.MessageType)
assert.Equal(t, out.UserID, 1)
assert.Equal(t, out.WithUserID, 2)
assert.Equal(t, in.WithUserID, 1)
assert.Equal(t, in.UserID, 2)
}