瀏覽代碼

comments added for test case

master
Patrick Peng Sun 9 年之前
父節點
當前提交
eee25ca5f7
共有 1 個檔案被更改,包括 4 行新增1 行删除
  1. +4
    -1
      accessToken_test.go

+ 4
- 1
accessToken_test.go 查看文件

"testing" "testing"
) )


//get accesstoken from wechat server or local cache file
func TestAccessToken(t *testing.T) { func TestAccessToken(t *testing.T) {
readConfig() readConfig()
token, err := GetAccessToken() token, err := GetAccessToken()
AssertEqual(t, token, WechatAccessToken.AccessToken, "Global accesstoken is not uptodate") AssertEqual(t, token, WechatAccessToken.AccessToken, "Global accesstoken is not uptodate")
} }


//save token to a file and read it back
func TestTokenStorage(t *testing.T) { func TestTokenStorage(t *testing.T) {
var s AuthToken var s AuthToken
s.AccessToken = "s0wf65p-KMzvYtH8qPu2qSX_EXLE2NaBgFHl7MZwedc7Kv_hdO0FG1QeUmBYJAGmQqJinPwFr67MRZwJee4rDnGVwhbuIfKs29N4ZJSXFP8fbAheuas08UuRe13UsdCtWSMcAFAGCW" s.AccessToken = "s0wf65p-KMzvYtH8qPu2qSX_EXLE2NaBgFHl7MZwedc7Kv_hdO0FG1QeUmBYJAGmQqJinPwFr67MRZwJee4rDnGVwhbuIfKs29N4ZJSXFP8fbAheuas08UuRe13UsdCtWSMcAFAGCW"
AssertEqual(t, s, token, "read token should be correct") AssertEqual(t, s, token, "read token should be correct")
} }


//read config, make sure its not empty
func TestReadConfig(t *testing.T) { func TestReadConfig(t *testing.T) {
readConfig()
SetupConfig()
if APIConfig.AppSecret == "" { if APIConfig.AppSecret == "" {
t.Error("AppSecret not available") t.Error("AppSecret not available")
} }

Loading…
取消
儲存