mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-04 15:49:49 +00:00
51 lines
770 B
Go
51 lines
770 B
Go
package util
|
|
|
|
import "testing"
|
|
|
|
func TestParseSchema(t *testing.T) {
|
|
type args struct {
|
|
url string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want string
|
|
}{
|
|
{
|
|
name: "http",
|
|
args: args{
|
|
url: "http://www.google.com",
|
|
},
|
|
want: "HTTP",
|
|
},
|
|
{
|
|
name: "https",
|
|
args: args{
|
|
url: "https://www.google.com",
|
|
},
|
|
want: "HTTPS",
|
|
},
|
|
{
|
|
name: "file",
|
|
args: args{
|
|
url: "file:///home/bt.torrent",
|
|
},
|
|
want: "FILE",
|
|
},
|
|
{
|
|
name: "file-no-scheme",
|
|
args: args{
|
|
url: "/home/bt.torrent",
|
|
},
|
|
want: "FILE",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := ParseSchema(tt.args.url); got != tt.want {
|
|
t.Errorf("ParseSchema() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|