Skip to content

Commit

Permalink
Add tests for URL parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Sep 14, 2021
1 parent a53d405 commit 8524446
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions git_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import "testing"

func TestCleanupURL(t *testing.T) {
var tests = []struct {
input string
expected string
}{
{"git@github.com:muesli/gitty.git", "https://github.com/muesli/gitty"},
{"git://github.com/muesli/gitty.git", "https://github.com/muesli/gitty"},
{"http://github.com/muesli/gitty.git", "https://github.com/muesli/gitty"},
{"https://github.com/muesli/gitty", "https://github.com/muesli/gitty"},
}

for _, test := range tests {
r, err := cleanupURL(test.input)
if err != nil {
t.Errorf("Error: %s", err)
}
if r != test.expected {
t.Errorf("CleanupURL(%s) %s != %s", test.input, r, test.expected)
}
}
}

0 comments on commit 8524446

Please sign in to comment.