-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot_test.go
80 lines (52 loc) · 1.52 KB
/
bot_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
const RequestOne = "request one"
const RequestTwo = "request two"
const RequestOpen = "open request"
const RequestToBeClosed = "request to be closed"
func TestBotRequestsAddOne(t *testing.T) {
bot := &Bot{}
bot.AddRequest(RequestOne)
require.Len(t, bot.Requests, 1)
}
func TestBotRequestsAddEmpty(t *testing.T) {
bot := &Bot{}
bot.AddRequest("")
require.Len(t, bot.Requests, 0)
}
func TestBotRequestsAddMultiple(t *testing.T) {
bot := &Bot{}
bot.AddRequest(RequestOne)
bot.AddRequest(RequestTwo)
require.Len(t, bot.Requests, 2)
}
func TestBotRequestsToText(t *testing.T) {
bot := &Bot{}
bot.AddRequest(RequestOne)
bot.AddRequest(RequestTwo)
requestsText := bot.GetRequestsText()
t.Log("requestsText:", requestsText)
require.Contains(t, requestsText, RequestOne)
require.Contains(t, requestsText, RequestTwo)
}
func TestBotCloseRequest(t *testing.T) {
bot := &Bot{}
bot.AddRequest(RequestOpen)
bot.AddRequest(RequestToBeClosed)
bot.CloseRequest("1") //count from 0
requestsText := bot.GetRequestsText()
t.Log("requestsText:", requestsText)
require.Contains(t, requestsText, RequestOpen)
require.NotContains(t, requestsText, RequestToBeClosed)
}
func TestBotNoOpenRequestsText(t *testing.T) {
bot := &Bot{}
bot.AddRequest(RequestToBeClosed)
bot.CloseRequest("0") //count from 0
requestsText := bot.GetRequestsText()
t.Log("requestsText:", requestsText)
require.Contains(t, requestsText, "No active requests at the moment")
}