Skip to content

Commit 7321598

Browse files
committed
fix broken test
1 parent 0a658a2 commit 7321598

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

data_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"gopkg.in/mgo.v2/bson"
1414
tg "github.com/requilence/telegram-bot-api"
1515
"strings"
16+
"os"
17+
"strconv"
1618
)
1719

1820
func clearData() {
@@ -223,7 +225,11 @@ func TestContext_ServiceCache(t *testing.T) {
223225
}
224226

225227
func TestUser_IsPrivateStarted(t *testing.T) {
226-
db.C("users").Insert(userData{User: User{ID: 9999999999}, Protected: map[string]*userProtected{"servicewithbottoken": {PrivateStarted: true}}})
228+
bt := strings.Split(os.Getenv("INTEGRAM_TEST_BOT_TOKEN"), ":")
229+
botID, _ := strconv.ParseInt(bt[0], 10, 64)
230+
231+
msg := Message{ChatID: 9999999999, FromID: 9999999999, MsgID: 1, BotID: botID}
232+
db.C("messages").Insert(&msg)
227233

228234
c := &Context{db: db, Chat: Chat{ID: -9999999999}, User: User{ID: 9999999999}, ServiceName: "servicewithbottoken"}
229235
c.User.ctx = c
@@ -263,6 +269,8 @@ func TestUser_IsPrivateStarted(t *testing.T) {
263269
}
264270
}
265271
db.C("users").RemoveId(9999999999)
272+
db.C("messages").RemoveId(msg.ID)
273+
266274
}
267275

268276
func TestUser_SetCache(t *testing.T) {

0 commit comments

Comments
 (0)