File: urlpart_test.go

package info (click to toggle)
golang-github-nicholas-fedor-shoutrrr 0.8.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,332 kB
  • sloc: sh: 61; makefile: 5
file content (32 lines) | stat: -rw-r--r-- 1,629 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package format_test

import (
	"github.com/onsi/ginkgo/v2"
	"github.com/onsi/gomega"

	"github.com/nicholas-fedor/shoutrrr/pkg/format"
)

var _ = ginkgo.Describe("URLPart", func() {
	ginkgo.It("should return the expected URL part for each lookup key", func() {
		gomega.Expect(format.ParseURLPart("user")).To(gomega.Equal(format.URLUser))
		gomega.Expect(format.ParseURLPart("pass")).To(gomega.Equal(format.URLPassword))
		gomega.Expect(format.ParseURLPart("password")).To(gomega.Equal(format.URLPassword))
		gomega.Expect(format.ParseURLPart("host")).To(gomega.Equal(format.URLHost))
		gomega.Expect(format.ParseURLPart("port")).To(gomega.Equal(format.URLPort))
		gomega.Expect(format.ParseURLPart("path")).To(gomega.Equal(format.URLPath))
		gomega.Expect(format.ParseURLPart("path1")).To(gomega.Equal(format.URLPath))
		gomega.Expect(format.ParseURLPart("path2")).To(gomega.Equal(format.URLPath + 1))
		gomega.Expect(format.ParseURLPart("path3")).To(gomega.Equal(format.URLPath + 2))
		gomega.Expect(format.ParseURLPart("path4")).To(gomega.Equal(format.URLPath + 3))
		gomega.Expect(format.ParseURLPart("query")).To(gomega.Equal(format.URLQuery))
		gomega.Expect(format.ParseURLPart("")).To(gomega.Equal(format.URLQuery))
	})
	ginkgo.It("should return the expected suffix for each URL part", func() {
		gomega.Expect(format.URLUser.Suffix()).To(gomega.Equal(':'))
		gomega.Expect(format.URLPassword.Suffix()).To(gomega.Equal('@'))
		gomega.Expect(format.URLHost.Suffix()).To(gomega.Equal(':'))
		gomega.Expect(format.URLPort.Suffix()).To(gomega.Equal('/'))
		gomega.Expect(format.URLPath.Suffix()).To(gomega.Equal('/'))
	})
})