Debian Codegraph @

plumbing/transport/url_test.go

raw symbols SCIP
1 package transportscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/transport`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
5 "net/urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/"
6 "runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/"
7 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
8 "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/"
9
10 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/"
11 "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/"
12
13 "github.com/go-git/go-git/v6/plumbing/protocol/capabilityscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/"
14 )
15
16 func TestParseURLscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/transport`/TestParseURL().(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#) {
17 t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().()
18 type tt struct {
19 input string
20 want string
21 wantErr string
22 }
23
24 tests := []tt{
25 {
26 input: "http://git:[email protected]:8080/user/repository.git?foo#bar",
27 want: "http://git:[email protected]:8080/user/repository.git?foo#bar",
28 },
29 {
30 input: "https://git:[email protected]/user/repository.git?foo#bar",
31 want: "https://git:[email protected]/user/repository.git?foo#bar",
32 },
33 {
34 input: "http://git:[email protected]/user/repository.git?foo#bar",
35 want: "http://git:[email protected]/user/repository.git?foo#bar",
36 },
37 {
38 input: fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("http://%s:%[email protected]/user/repository.git",
39 urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/.PathEscapescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/PathEscape().("[email protected]"),
40 urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/.PathEscapescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/PathEscape().(" !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"),
41 ),
42 want: "http://person%40mail.com:%20%21%22%23$%25&%27%28%29%2A+,-.%2F%3A;%3C=%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%[email protected]/user/repository.git",
43 },
44 {
45 input: "http://[::1]:8080/foo.git",
46 want: "http://[::1]:8080/foo.git",
47 },
48 {
49 input: "ssh://git:[email protected]/user/repository.git?foo#bar",
50 want: "ssh://git:[email protected]/user/repository.git?foo#bar",
51 },
52 {
53 input: "ssh://[email protected]/user/repository.git",
54 want: "ssh://[email protected]/user/repository.git",
55 },
56 {
57 input: "ssh://github.com/user/repository.git",
58 want: "ssh://github.com/user/repository.git",
59 },
60 {
61 input: "ssh://[email protected]:777/user/repository.git",
62 want: "ssh://[email protected]:777/user/repository.git",
63 },
64 {
65 input: "[email protected]:user/repository.git",
66 want: "ssh://[email protected]/user/repository.git",
67 },
68 {
69 input: "[email protected]:9999/user/repository.git",
70 want: "ssh://[email protected]/9999/user/repository.git",
71 },
72 {
73 input: "[email protected]:8080:9999/user/repository.git",
74 want: "ssh://[email protected]:8080/9999/user/repository.git",
75 },
76 {
77 input: "git://github.com/user/repository.git?foo#bar",
78 want: "git://github.com/user/repository.git?foo#bar",
79 },
80 }
81
82 for _, tc := range tests {
83 t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tc.input, func(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#) {
84 t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().()
85
86 ep, err := ParseURLscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/transport`/ParseURL().(tc.input)
87 if tc.wantErr != "" {
88 requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorContainsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorContains().(t, err, tc.wantErr)
89 } else {
90 requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err)
91 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, tc.want, ep.Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().())
92 }
93 })
94 }
95 }
96
97 func TestParseURLFilescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/transport`/TestParseURLFile().(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#) {
98 t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().()
99 type tt struct {
100 input string
101 want string
102 wantErr string
103 }
104
105 tests := []tt{
106 {
107 input: "/foo.git",
108 want: "file:///foo.git",
109 },
110 {
111 input: "foo.git",
112 want: "file://foo.git",
113 },
114 {
115 input: "C:\\foo.git",
116 want: "file://C:\\foo.git",
117 },
118 {
119 input: "C:\\\\foo.git",
120 want: "file://C:\\\\foo.git",
121 },
122 {
123 input: "file:///foo.git",
124 want: "file:///foo.git",
125 },
126 {
127 input: "file:///path/to/repo",
128 want: "file:///path/to/repo",
129 },
130 {
131 input: "file://C:/path/to/repo",
132 want: "file://C:/path/to/repo",
133 },
134 {
135 input: "file://C:\\path\\to\\repo",
136 want: "file://C:\\path\\to\\repo",
137 },
138 {
139 input: "http://\\",
140 wantErr: "invalid character",
141 },
142 }
143
144 if runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/.GOOSscip-go gomod github.com/golang/go/src go1.25.0 runtime/GOOS. == "windows" {
145 tests = append(tests, []tt{{
146 input: "file:///C:/path/to/repo",
147 want: "file://C:/path/to/repo",
148 }, {
149 input: "file:///c:\\foo.git",
150 want: "file://c:\\foo.git",
151 }}...)
152 }
153
154 for _, tc := range tests {
155 t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tc.input, func(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#) {
156 t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().()
157
158 ep, err := ParseURLscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/transport`/ParseURL().(tc.input)
159 if tc.wantErr != "" {
160 requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorContainsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorContains().(t, err, tc.wantErr)
161 } else {
162 requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err)
163 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, stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/TrimPrefix().(tc.want, "file://"), ep.Pathscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#Path.)
164 }
165 })
166 }
167 }
168
169 func TestFilterUnsupportedCapabilitiesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/transport`/TestFilterUnsupportedCapabilities().(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#) {
170 t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().()
171 l := &capabilityscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/.Listscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/List#{}
172 l.Setscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/List#Set().(capabilityscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/.MultiACKscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/MultiACK.)
173 l.Setscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/List#Set().(capabilityscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/.MultiACKDetailedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/MultiACKDetailed.)
174
175 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Falsescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/False().(t, l.Supportsscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/List#Supports().(capabilityscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/.ThinPackscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/protocol/capability`/ThinPack.))
176 }
177
178 func FuzzParseURLscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/transport`/FuzzParseURL().(f *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Fscip-go gomod github.com/golang/go/src go1.25.0 testing/F#) {
179 f.Fuzzscip-go gomod github.com/golang/go/src go1.25.0 testing/F#Fuzz().(func(_ *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#, input string) {
180 ParseURLscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/transport`/ParseURL().(input)
181 })
182 }