(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func 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 | } |
nothing calls this directly
no test coverage detected