-
Notifications
You must be signed in to change notification settings - Fork 0
/
linenotify_test.go
49 lines (37 loc) · 1.24 KB
/
linenotify_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
package linenotify
import (
"testing"
)
const (
ID = "id"
SECRET = "secret"
CB = "http://localhost:5000/callback"
)
func TestNewWithoutSecret(t *testing.T) {
_, err := New(ID, "", "")
if err == nil {
t.Errorf("error should not nil")
}
}
func TestNew(t *testing.T) {
_, err := New(ID, SECRET, CB)
if err != nil {
t.Errorf("error should be nil, but got: %v", err)
}
}
func TestAuthUrl(t *testing.T) {
c, _ := New(ID, SECRET, CB)
url := c.AuthUrl()
expected := "https://notify-bot.line.me/oauth/authorize?client_id=id&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Fcallback&response_type=code&scope=notify&state=123"
if url != expected {
t.Errorf("expected: %s, but got: %s", expected, url)
}
}
func TestMakeTokenBody(t *testing.T) {
c, _ := New(ID, SECRET, CB)
body := c.makeTokenBody("abctoken")
expected := "client_id=id&client_secret=secret&code=abctoken&grant_type=authorization_code&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Fcallback"
if body != expected {
t.Errorf("expected: %s, but got: %s", expected, body)
}
}