-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo_svc_test.go
48 lines (37 loc) · 951 Bytes
/
todo_svc_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
46
47
48
package todo_svc
import (
"context"
"reference/common"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/submodule-org/submodule.go"
)
type testSuite struct {
suite.Suite
scope submodule.Scope
svc TodoSvc
}
func (s *testSuite) SetupTest() {
s.scope = submodule.CreateScope()
s.svc = TodoSvcMod.ResolveWith(s.scope)
}
func (s *testSuite) TestCRUD() {
var todo common.Todo
var err error
todo, err = s.svc.Insert(context.Background(), common.Todo{
Content: "example",
})
assert.Nil(s.T(), err)
assert.NotNil(s.T(), todo.Id)
todo, err = s.svc.Get(context.Background(), todo.Id)
assert.Nil(s.T(), err)
assert.Equal(s.T(), "example", todo.Content)
todo, err = s.svc.Delete(context.Background(), todo.Id)
assert.Nil(s.T(), err)
todo, err = s.svc.Get(context.Background(), todo.Id)
assert.NotNil(s.T(), err)
}
func TestTodoSvc(t *testing.T) {
suite.Run(t, new(testSuite))
}