-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make app-related metrics opt-in (#111)
- Loading branch information
1 parent
8c1ed36
commit 9e80c94
Showing
9 changed files
with
177 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package serverinfo | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
const ( | ||
infoPathFormat = "%s/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=%v" | ||
) | ||
|
||
// InfoURL constructs the URL of the info endpoint from the server base URL and optional parameters. | ||
func InfoURL(serverURL string, skipApps bool) string { | ||
return fmt.Sprintf(infoPathFormat, serverURL, skipApps) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package serverinfo | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestInfoURL(t *testing.T) { | ||
tt := []struct { | ||
desc string | ||
serverURL string | ||
skipApps bool | ||
wantURL string | ||
}{ | ||
{ | ||
desc: "do not skip apps", | ||
serverURL: "https://nextcloud.example.com", | ||
wantURL: "https://nextcloud.example.com/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=false", | ||
}, | ||
{ | ||
desc: "skip apps", | ||
serverURL: "https://nextcloud.example.com", | ||
skipApps: true, | ||
wantURL: "https://nextcloud.example.com/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true", | ||
}, | ||
} | ||
|
||
for _, tc := range tt { | ||
tc := tc | ||
t.Run(tc.desc, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
url := InfoURL(tc.serverURL, tc.skipApps) | ||
if url != tc.wantURL { | ||
t.Errorf("got url %q, want %q", url, tc.wantURL) | ||
} | ||
}) | ||
} | ||
} |