github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/modules/robot_notifier/lark/notify_message_test.go (about) 1 package lark_test 2 3 import ( 4 "context" 5 "testing" 6 7 . "github.com/onsi/gomega" 8 9 "github.com/machinefi/w3bstream/pkg/modules/robot_notifier/lark" 10 "github.com/machinefi/w3bstream/pkg/types" 11 ) 12 13 func TestTagElementToMap(t *testing.T) { 14 text := "test_text" 15 vmap, err := lark.TagElementToMap(&lark.ElementText{Text: text}) 16 NewWithT(t).Expect(err).To(BeNil()) 17 NewWithT(t).Expect(vmap).To(Equal(map[string]interface{}{ 18 "tag": "text", 19 "text": text, 20 })) 21 } 22 23 func TestBuild(t *testing.T) { 24 config := &types.RobotNotifierConfig{ 25 URL: "https://open.larksuite.com/open-apis/bot/v2/hook/f8d7cd45-4b45-40fe-9635-5e2f85e19155", 26 Secret: "vztL7BIOyDw10XEd9H5B6", 27 Env: "prod", 28 } 29 config.Init() 30 31 ctx := types.WithRobotNotifierConfig(context.Background(), config) 32 msg, err := lark.Build(ctx, "TITLE", "warning", "message content") 33 NewWithT(t).Expect(err).To(BeNil()) 34 t.Log(string(msg)) 35 }