-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for verifying that the static urls are valid
Fixes #150
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package util | ||
|
||
import ( | ||
"net/url" | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestURLToGitHubProject(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
subpath string | ||
}{ | ||
{"Repository root", ""}, | ||
{"Releases", "/releases"}, | ||
{"Release v3.0.0", "/releases/v3.0.0"}, | ||
{"Supported clients", "/wiki/Supported-clients"}, | ||
} | ||
|
||
const basepath = https + "://" + github + repo | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
path := basepath + tt.subpath | ||
want, err := url.Parse(path) | ||
if err != nil { | ||
t.Errorf("Failed to parse the path %s: %v", path, err) | ||
return | ||
} | ||
|
||
if got := URLToGitHubProject(tt.subpath); !reflect.DeepEqual(got, want) { | ||
t.Errorf("URLToGitHubProject() = %v, want %v", got, want) | ||
} | ||
}) | ||
} | ||
} |