Debian Codegraph @

testing/e2e/discord/embed_author_test.go

raw
1 package e2e_test
2
3 import (
4 "net/url"
5 "os"
6
7 "github.com/onsi/ginkgo/v2"
8 "github.com/onsi/gomega"
9
10 "github.com/nicholas-fedor/shoutrrr/internal/testutils"
11 "github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord"
12 "github.com/nicholas-fedor/shoutrrr/pkg/types"
13 )
14
15 var _ = ginkgo.Describe("Discord E2E Embed Author Test", func() {
16 ginkgo.When("running e2e tests", func() {
17 ginkgo.It("should send embed with author information", func() {
18 envURL := os.Getenv("SHOUTRRR_DISCORD_URL")
19 if envURL == "" {
20 ginkgo.Skip("SHOUTRRR_DISCORD_URL not set, skipping author info test")
21
22 return
23 }
24
25 serviceURL, _ := url.Parse(envURL)
26 service := &discord.Service{}
27 err := service.Initialize(serviceURL, testutils.TestLogger())
28 gomega.Expect(err).NotTo(gomega.HaveOccurred())
29
30 items := []types.MessageItem{
31 {
32 Text: "E2E Test: Embed with author information",
33 Fields: []types.Field{
34 {Key: "embed_author_name", Value: "Shoutrrr E2E Test"},
35 {
36 Key: "embed_author_url",
37 Value: "https://github.com/nicholas-fedor/shoutrrr",
38 },
39 {
40 Key: "embed_author_icon_url",
41 Value: "https://raw.githubusercontent.com/nicholas-fedor/shoutrrr/master/docs/assets/media/shoutrrr-180px.png",
42 },
43 },
44 },
45 }
46 err = service.SendItems(items, nil)
47 gomega.Expect(err).NotTo(gomega.HaveOccurred())
48 })
49 })
50 })