Debian Codegraph @

serverinfo/url_test.go

raw symbols SCIP
1 package serverinfo
2
3 import (
4 "testing"
5 )
6
7 func TestInfoURL(t *testing.T) {
8 tt := []struct {
9 desc string
10 serverURL string
11 skipApps bool
12 skipUpdate bool
13 wantURL string
14 }{
15 {
16 desc: "do not skip apps and do not skip update (implicit)",
17 serverURL: "https://nextcloud.example.com",
18 wantURL: "https://nextcloud.example.com/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=false&skipUpdate=false",
19 },
20 {
21 desc: "skip apps",
22 serverURL: "https://nextcloud.example.com",
23 skipApps: true,
24 wantURL: "https://nextcloud.example.com/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true&skipUpdate=false",
25 },
26 {
27 desc: "do not skip update",
28 serverURL: "https://nextcloud.example.com",
29 skipUpdate: false,
30 wantURL: "https://nextcloud.example.com/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=false&skipUpdate=false",
31 },
32 {
33 desc: "skip update",
34 serverURL: "https://nextcloud.example.com",
35 skipUpdate: true,
36 wantURL: "https://nextcloud.example.com/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=false&skipUpdate=true",
37 },
38 {
39 desc: "do not skip update and do not skip apps (explicit)",
40 serverURL: "https://nextcloud.example.com",
41 skipApps: false,
42 skipUpdate: false,
43 wantURL: "https://nextcloud.example.com/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=false&skipUpdate=false",
44 },
45 {
46 desc: "skip update and skip apps",
47 serverURL: "https://nextcloud.example.com",
48 skipApps: true,
49 skipUpdate: true,
50 wantURL: "https://nextcloud.example.com/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true&skipUpdate=true",
51 },
52 }
53
54 for _, tc := range tt {
55 tc := tc
56 t.Run(tc.desc, func(t *testing.T) {
57 t.Parallel()
58
59 url := InfoURL(tc.serverURL, tc.skipApps, tc.skipUpdate)
60 if url != tc.wantURL {
61 t.Errorf("got url %q, want %q", url, tc.wantURL)
62 }
63 })
64 }
65 }