MCPcopy Index your code
hub / github.com/dnote/dnote / TestGetServerDisplayURL

Function TestGetServerDisplayURL

pkg/cli/cmd/login/login_test.go:26–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestGetServerDisplayURL(t *testing.T) {
27 testCases := []struct {
28 apiEndpoint string
29 expected string
30 }{
31 {
32 apiEndpoint: "https://dnote.mydomain.com/api",
33 expected: "https://dnote.mydomain.com",
34 },
35 {
36 apiEndpoint: "https://mysubdomain.mydomain.com/dnote/api",
37 expected: "https://mysubdomain.mydomain.com",
38 },
39 {
40 apiEndpoint: "https://dnote.mysubdomain.mydomain.com/api",
41 expected: "https://dnote.mysubdomain.mydomain.com",
42 },
43 {
44 apiEndpoint: "some-string",
45 expected: "",
46 },
47 {
48 apiEndpoint: "",
49 expected: "",
50 },
51 {
52 apiEndpoint: "https://",
53 expected: "",
54 },
55 {
56 apiEndpoint: "https://abc",
57 expected: "https://abc",
58 },
59 }
60
61 for _, tc := range testCases {
62 t.Run(fmt.Sprintf("for input %s", tc.apiEndpoint), func(t *testing.T) {
63 got := getServerDisplayURL(context.DnoteCtx{APIEndpoint: tc.apiEndpoint})
64 assert.Equal(t, got, tc.expected, "result mismatch")
65 })
66 }
67}

Callers

nothing calls this directly

Calls 2

EqualFunction · 0.92
getServerDisplayURLFunction · 0.85

Tested by

no test coverage detected