-
Notifications
You must be signed in to change notification settings - Fork 15
/
session_repository_test.go
46 lines (35 loc) · 1.18 KB
/
session_repository_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
package margelet_test
import (
. "github.com/smartystreets/goconvey/convey"
"gopkg.in/telegram-bot-api.v4"
"testing"
)
func TestSessionRepository(t *testing.T) {
Convey("Given session repository", t, func() {
m := getMargelet()
msg := tgbotapi.Message{Text: "Test"}
Convey("When creating new session", func() {
m.SessionRepository.Create(100, 500, "/test")
Convey("New session should be found in repo", func() {
So(m.SessionRepository.Command(100, 500), ShouldEqual, "/test")
})
})
Convey("When adding new dialog", func() {
m.SessionRepository.Add(100, 500, &msg)
Convey("It shound be found in repo", func() {
So(m.SessionRepository.Dialog(100, 500)[0].Text, ShouldEqual, "Test")
})
})
Convey("When dialogs exists", func() {
m.SessionRepository.Add(100, 500, &msg)
Convey("Trying to get dialog for non-exists session shound return empty array", func() {
m.SessionRepository.Add(100, 500, &msg)
So(m.SessionRepository.Dialog(100, 501), ShouldBeEmpty)
})
Convey("Removed session shound not be found in repo", func() {
m.SessionRepository.Remove(100, 500)
So(m.SessionRepository.Dialog(100, 500), ShouldBeEmpty)
})
})
})
}