stash/pkg/utils/url_test.go
WithoutPants f26766033e
Performer urls (#4958)
* Populate URLs from legacy fields
* Return nil properly in xpath/json scrapers
* Improve migration logging
2024-06-18 13:41:05 +10:00

47 lines
883 B
Go

package utils
import "testing"
func TestURLFromHandle(t *testing.T) {
type args struct {
input string
siteURL string
}
tests := []struct {
name string
args args
want string
}{
{
name: "input is already a URL https",
args: args{
input: "https://foo.com",
siteURL: "https://bar.com",
},
want: "https://foo.com",
},
{
name: "input is already a URL http",
args: args{
input: "http://foo.com",
siteURL: "https://bar.com",
},
want: "http://foo.com",
},
{
name: "input is not a URL",
args: args{
input: "foo",
siteURL: "https://foo.com",
},
want: "https://foo.com/foo",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := URLFromHandle(tt.args.input, tt.args.siteURL); got != tt.want {
t.Errorf("URLFromHandle() = %v, want %v", got, tt.want)
}
})
}
}