| 1 | package configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 5 | |
| 6 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/" |
| 7 | ) |
| 8 | |
| 9 | func TestURLConfigscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/TestURLConfig().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 10 | u := NewURLConfigscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/NewURLConfig().(EnvironmentOfscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/EnvironmentOf().(MapFetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/MapFetcher().(map[string][]string{ |
| 11 | "http.key": []string{"root", "root-2"}, |
| 12 | "http.https://host.com.key": []string{"host", "host-2"}, |
| 13 | "http.https://[email protected]/a.key": []string{"user-a", "user-b"}, |
| 14 | "http.https://[email protected]": []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:[email protected]/a/b/c": "user-b", |
| 32 | "https://user:[email protected]/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.Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/URLConfig#Get().("http", rawurl, "key") |
| 53 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, expected, value, "get one: "+rawurl) |
| 54 | } |
| 55 | |
| 56 | value, _ := u.Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/URLConfig#Get().("http", "https://host.wild/a/b/c", "k") |
| 57 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, value, "") |
| 58 | value, _ = u.Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/URLConfig#Get().("ttp", "https://host.wild/a/b/c", "key") |
| 59 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/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:[email protected]/a/b/c": []string{"user-a", "user-b"}, |
| 66 | "https://user:[email protected]/z/b/c": []string{"user", "user-2"}, |
| 67 | "https://host.com:8080/a": []string{"port", "port-2"}, |
| 68 | } |
| 69 | |
| 70 | for rawurl, expected := range getAll { |
| 71 | values := u.GetAllscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/URLConfig#GetAll().("http", rawurl, "key") |
| 72 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, expected, values, "get all: "+rawurl) |
| 73 | } |
| 74 | } |