github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/modules/robot_notifier/notifier_test.go (about) 1 package robot_notifier_test 2 3 import ( 4 "context" 5 "testing" 6 7 . "github.com/onsi/gomega" 8 9 "github.com/machinefi/w3bstream/pkg/modules/robot_notifier" 10 "github.com/machinefi/w3bstream/pkg/modules/robot_notifier/lark" 11 "github.com/machinefi/w3bstream/pkg/types" 12 ) 13 14 func TestPush(t *testing.T) { 15 config := &types.RobotNotifierConfig{ 16 URL: "https://open.larksuite.com/open-apis/bot/v2/hook/f8d7cd45-4b45-40fe-9635-5e2f85e19155", 17 Secret: "vztL7BIOyDw10XEd9H5B6", 18 Env: "dev-staging", 19 } 20 config.Init() 21 22 ctx := types.WithRobotNotifierConfig(context.Background(), config) 23 24 body, err := lark.Build(ctx, "test_title", "warning", "message content") 25 NewWithT(t).Expect(err).To(BeNil()) 26 t.Log(string(body)) 27 28 err = robot_notifier.Push(ctx, body, lark.ResponseHook) 29 t.Log(err) 30 }