50 lines
1002 B
Go
50 lines
1002 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestExp(t *testing.T) {
|
|
arr := []struct {
|
|
Url string
|
|
Match bool
|
|
}{
|
|
{
|
|
Url: "https://github.com/hunshcn/project/archive/master.zip",
|
|
Match: true,
|
|
},
|
|
{
|
|
Url: "https://github.com/hunshcn/project/archive/v0.1.0.tar.gz",
|
|
Match: true,
|
|
},
|
|
{
|
|
Url: "https://github.com/hunshcn/project/releases/download/v0.1.0/example.zip",
|
|
Match: true,
|
|
},
|
|
{
|
|
Url: "https://github.com/hunshcn/project/blob/master/filename",
|
|
Match: true,
|
|
},
|
|
{
|
|
Url: "https://github.com/hunshcn/project/blob/1111111111111111111111111111/filename",
|
|
Match: true,
|
|
},
|
|
{
|
|
Url: "https://raw.githubusercontent.com/stilleshan/ServerStatus/master/Dockerfile",
|
|
Match: true,
|
|
},
|
|
{
|
|
Url: "https://baidu.com",
|
|
Match: false,
|
|
},
|
|
{
|
|
Url: "https://git.aweoo.com/fghwett/notepad.git",
|
|
Match: false,
|
|
},
|
|
}
|
|
|
|
for _, v := range arr {
|
|
if v.Match != checkUrl(v.Url) {
|
|
t.Errorf("%s is not match, except: %t", v.Url, v.Match)
|
|
}
|
|
}
|
|
}
|