2021-07-23 17:56:33 +00:00
|
|
|
package notify
|
2016-04-01 07:45:24 +00:00
|
|
|
|
|
|
|
import (
|
2017-01-19 09:08:12 +00:00
|
|
|
"testing"
|
|
|
|
|
2016-05-03 01:56:59 +00:00
|
|
|
"github.com/appleboy/gorush/config"
|
2022-12-03 14:44:29 +00:00
|
|
|
|
2016-04-10 04:02:44 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2016-04-01 07:45:24 +00:00
|
|
|
)
|
|
|
|
|
2016-04-02 15:51:42 +00:00
|
|
|
func TestCorrectConf(t *testing.T) {
|
2021-07-16 04:10:34 +00:00
|
|
|
cfg, _ := config.LoadConf()
|
2016-04-02 15:51:42 +00:00
|
|
|
|
2021-07-16 04:10:34 +00:00
|
|
|
cfg.Android.Enabled = true
|
|
|
|
cfg.Android.APIKey = "xxxxx"
|
2016-04-02 15:51:42 +00:00
|
|
|
|
2021-07-16 04:10:34 +00:00
|
|
|
cfg.Ios.Enabled = true
|
2022-12-20 14:03:29 +00:00
|
|
|
cfg.Ios.KeyPath = testKeyPath
|
2016-04-02 15:51:42 +00:00
|
|
|
|
2021-07-16 04:10:34 +00:00
|
|
|
err := CheckPushConf(cfg)
|
2016-04-02 15:51:42 +00:00
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
2016-07-29 00:48:24 +00:00
|
|
|
func TestSetProxyURL(t *testing.T) {
|
|
|
|
err := SetProxy("87.236.233.92:8080")
|
|
|
|
assert.Error(t, err)
|
2020-02-27 05:17:20 +00:00
|
|
|
assert.Equal(t, "parse \"87.236.233.92:8080\": invalid URI for request", err.Error())
|
2016-07-29 00:48:24 +00:00
|
|
|
|
|
|
|
err = SetProxy("a.html")
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
err = SetProxy("http://87.236.233.92:8080")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|