refactor: clean code
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package dingtalk
|
||||
package dingtalkbot
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package dingtalk_test
|
||||
package dingtalkbot_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/usual2970/certimate/internal/pkg/core/notifier/providers/dingtalk"
|
||||
provider "github.com/usual2970/certimate/internal/pkg/core/notifier/providers/dingtalkbot"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -16,22 +16,23 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
fAccessToken string
|
||||
fSecret string
|
||||
fWebhookUrl string
|
||||
fSecret string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "CERTIMATE_NOTIFIER_DINGTALK_"
|
||||
argsPrefix := "CERTIMATE_NOTIFIER_DINGTALKBOT_"
|
||||
|
||||
flag.StringVar(&fAccessToken, argsPrefix+"ACCESSTOKEN", "", "")
|
||||
flag.StringVar(&fWebhookUrl, argsPrefix+"WEBHOOKURL", "", "")
|
||||
flag.StringVar(&fSecret, argsPrefix+"SECRET", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./dingtalk_test.go -args \
|
||||
--CERTIMATE_NOTIFIER_DINGTALK_URL="https://example.com/your-webhook-url"
|
||||
go test -v ./dingtalkbot_test.go -args \
|
||||
--CERTIMATE_NOTIFIER_DINGTALKBOT_WEBHOOKURL="https://example.com/your-webhook-url" \
|
||||
--CERTIMATE_NOTIFIER_DINGTALKBOT_SECRET="your-secret"
|
||||
*/
|
||||
func TestNotify(t *testing.T) {
|
||||
flag.Parse()
|
||||
@@ -39,13 +40,13 @@ func TestNotify(t *testing.T) {
|
||||
t.Run("Notify", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("ACCESSTOKEN: %v", fAccessToken),
|
||||
fmt.Sprintf("WEBHOOKURL: %v", fWebhookUrl),
|
||||
fmt.Sprintf("SECRET: %v", fSecret),
|
||||
}, "\n"))
|
||||
|
||||
notifier, err := provider.NewNotifier(&provider.NotifierConfig{
|
||||
AccessToken: fAccessToken,
|
||||
Secret: fSecret,
|
||||
WebhookUrl: fWebhookUrl,
|
||||
Secret: fSecret,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
@@ -1,4 +1,4 @@
|
||||
package lark
|
||||
package larkbot
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package serverchan_test
|
||||
package larkbot_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/usual2970/certimate/internal/pkg/core/notifier/providers/wecom"
|
||||
provider "github.com/usual2970/certimate/internal/pkg/core/notifier/providers/larkbot"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -18,7 +18,7 @@ const (
|
||||
var fWebhookUrl string
|
||||
|
||||
func init() {
|
||||
argsPrefix := "CERTIMATE_NOTIFIER_WECOM_"
|
||||
argsPrefix := "CERTIMATE_NOTIFIER_LARKBOT_"
|
||||
|
||||
flag.StringVar(&fWebhookUrl, argsPrefix+"WEBHOOKURL", "", "")
|
||||
}
|
||||
@@ -26,8 +26,8 @@ func init() {
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./wecom_test.go -args \
|
||||
--CERTIMATE_NOTIFIER_WECOM_WEBHOOKURL="https://example.com/your-webhook-url" \
|
||||
go test -v ./larkbot_test.go -args \
|
||||
--CERTIMATE_NOTIFIER_LARKBOT_WEBHOOKURL="https://example.com/your-webhook-url"
|
||||
*/
|
||||
func TestNotify(t *testing.T) {
|
||||
flag.Parse()
|
||||
@@ -1,4 +1,4 @@
|
||||
package serverchan
|
||||
package wecombot
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package lark_test
|
||||
package wecombot_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/usual2970/certimate/internal/pkg/core/notifier/providers/lark"
|
||||
provider "github.com/usual2970/certimate/internal/pkg/core/notifier/providers/wecombot"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -18,7 +18,7 @@ const (
|
||||
var fWebhookUrl string
|
||||
|
||||
func init() {
|
||||
argsPrefix := "CERTIMATE_NOTIFIER_LARK_"
|
||||
argsPrefix := "CERTIMATE_NOTIFIER_WECOMBOT_"
|
||||
|
||||
flag.StringVar(&fWebhookUrl, argsPrefix+"WEBHOOKURL", "", "")
|
||||
}
|
||||
@@ -26,8 +26,8 @@ func init() {
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./lark_test.go -args \
|
||||
--CERTIMATE_NOTIFIER_LARK_WEBHOOKURL="https://example.com/your-webhook-url"
|
||||
go test -v ./wecombot_test.go -args \
|
||||
--CERTIMATE_NOTIFIER_WECOMBOT_WEBHOOKURL="https://example.com/your-webhook-url" \
|
||||
*/
|
||||
func TestNotify(t *testing.T) {
|
||||
flag.Parse()
|
||||
Reference in New Issue
Block a user