package adapter import "testing" func TestDingtalkConfigWebhookURL(t *testing.T) { tests := []struct { name string cfg dingtalkConfig wantURL string }{ { name: "access token only", cfg: dingtalkConfig{AccessToken: "tok-abc"}, wantURL: "https://oapi.dingtalk.com/robot/send?access_token=tok-abc", }, { name: "access token takes precedence over legacy url", cfg: dingtalkConfig{AccessToken: "tok-abc", WebhookURL: "https://legacy.example/webhook"}, wantURL: "https://oapi.dingtalk.com/robot/send?access_token=tok-abc", }, { name: "fallback to legacy url", cfg: dingtalkConfig{WebhookURL: "https://legacy.example/webhook"}, wantURL: "https://legacy.example/webhook", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := tt.cfg.webhookURL(); got != tt.wantURL { t.Fatalf("webhookURL() = %q, want %q", got, tt.wantURL) } }) } }