-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
35 lines (30 loc) · 918 Bytes
/
main_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
package main
import (
"github.com/stretchr/testify/assert"
"log"
"testing"
)
const SERVER = "https://open.rocket.chat"
const USER = "rcnotification"
const PASSWORD = ""
const CHANNEL = "rocketchat-notification"
const MESSAGE = "This is a friendly test messaje"
func TestLogin(t *testing.T) {
loginData := login(USER, PASSWORD, SERVER)
assert.Equal(t, "success", loginData.Status)
assert.NotNil(t, loginData.Data)
}
func TestLoginFailed(t *testing.T) {
loginData := login(USER+"false", PASSWORD, SERVER)
assert.Equal(t, "error", loginData.Status)
}
func TestPostMessage(t *testing.T) {
loginData := login(USER, PASSWORD, SERVER)
assert.Equal(t, "success", loginData.Status)
if loginData.Status == "success" {
postMessageData := postMessage(CHANNEL, MESSAGE, loginData.Data.AuthToken, loginData.Data.UserId, SERVER)
assert.True(t, postMessageData.Success)
} else {
log.Fatal(loginData.Error)
}
}