git-lfs/config/url_config_test.go

33 lines
968 B
Go
Raw Normal View History

package config
import (
"testing"
"github.com/stretchr/testify/assert"
)
2017-04-12 19:35:15 +00:00
func TestURLConfig(t *testing.T) {
u := NewURLConfig(EnvironmentOf(MapFetcher(map[string][]string{
"http.key": []string{"root"},
"http.https://host.com.key": []string{"host"},
"http.https://user@host.com/a.key": []string{"user-a"},
"http.https://user@host.com.key": []string{"user"},
"http.https://host.com/a.key": []string{"host-a"},
"http.https://host.com:8080.key": []string{"port"},
})))
tests := map[string]string{
"https://root.com/a/b/c": "root",
"https://host.com/": "host",
"https://host.com/a/b/c": "host-a",
"https://user:pass@host.com/a/b/c": "user-a",
"https://user:pass@host.com/z/b/c": "user",
"https://host.com:8080/a": "port",
}
for rawurl, expected := range tests {
2017-04-12 19:35:15 +00:00
value, _ := u.Get("http", "key", rawurl)
assert.Equal(t, expected, value, rawurl)
}
}