MCPcopy
hub / github.com/git-lfs/git-lfs / TestURLConfig

Function TestURLConfig

config/url_config_test.go:9–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestURLConfig(t *testing.T) {
10 u := NewURLConfig(EnvironmentOf(MapFetcher(map[string][]string{
11 "http.key": []string{"root", "root-2"},
12 "http.https://host.com.key": []string{"host", "host-2"},
13 "http.https://user@host.com/a.key": []string{"user-a", "user-b"},
14 "http.https://user@host.com.key": []string{"user", "user-2"},
15 "http.https://host.com/a.key": []string{"host-a", "host-b"},
16 "http.https://host.com:8080.key": []string{"port", "port-2"},
17 "http.https://host.com/repo.git.key": []string{".git"},
18 "http.https://host.com/repo.key": []string{"no .git"},
19 "http.https://host.com/repo2.key": []string{"no .git"},
20 "http.http://host.com/repo.key": []string{"http"},
21 "http.https://host.com:443/repo3.git.key": []string{"port"},
22 "http.ssh://host.com:22/repo3.git.key": []string{"ssh-port"},
23 "http.https://host.*/a.key": []string{"wild"},
24 "httpXhttps://host.*/aXkey": []string{"invalid"},
25 })))
26
27 getOne := map[string]string{
28 "https://root.com/a/b/c": "root-2",
29 "https://host.com/": "host-2",
30 "https://host.com/a/b/c": "host-b",
31 "https://user:pass@host.com/a/b/c": "user-b",
32 "https://user:pass@host.com/z/b/c": "user-2",
33 "https://host.com:8080/a": "port-2",
34 "https://host.com/repo.git/info/lfs": ".git",
35 "https://host.com/repo.git/info": ".git",
36 "https://host.com/repo.git": ".git",
37 "https://host.com/repo": "no .git",
38 "https://host.com/repo2.git/info/lfs/foo/bar": "no .git",
39 "https://host.com/repo2.git/info/lfs": "no .git",
40 "https://host.com:443/repo2.git/info/lfs": "no .git",
41 "https://host.com/repo2.git/info": "host-2", // doesn't match /.git/info/lfs\Z/
42 "https://host.com/repo2.git": "host-2", // ditto
43 "https://host.com/repo3.git/info/lfs": "port",
44 "ssh://host.com/repo3.git/info/lfs": "ssh-port",
45 "https://host.com/repo2": "no .git",
46 "http://host.com/repo": "http",
47 "http://host.com:80/repo": "http",
48 "https://host.wild/a/b/c": "wild",
49 }
50
51 for rawurl, expected := range getOne {
52 value, _ := u.Get("http", rawurl, "key")
53 assert.Equal(t, expected, value, "get one: "+rawurl)
54 }
55
56 value, _ := u.Get("http", "https://host.wild/a/b/c", "k")
57 assert.Equal(t, value, "")
58 value, _ = u.Get("ttp", "https://host.wild/a/b/c", "key")
59 assert.Equal(t, value, "")
60
61 getAll := map[string][]string{
62 "https://root.com/a/b/c": []string{"root", "root-2"},
63 "https://host.com/": []string{"host", "host-2"},
64 "https://host.com/a/b/c": []string{"host-a", "host-b"},
65 "https://user:pass@host.com/a/b/c": []string{"user-a", "user-b"},
66 "https://user:pass@host.com/z/b/c": []string{"user", "user-2"},

Callers

nothing calls this directly

Calls 6

GetMethod · 0.95
GetAllMethod · 0.95
NewURLConfigFunction · 0.85
EnvironmentOfFunction · 0.85
MapFetcherFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected