1
- package envbuilder_test
1
+ package git_test
2
2
3
3
import (
4
4
"context"
@@ -12,9 +12,10 @@ import (
12
12
"regexp"
13
13
"testing"
14
14
15
+ "github.com/coder/envbuilder/git"
16
+
15
17
"github.com/coder/envbuilder/options"
16
18
17
- "github.com/coder/envbuilder"
18
19
"github.com/coder/envbuilder/internal/log"
19
20
"github.com/coder/envbuilder/testutil/gittest"
20
21
"github.com/coder/envbuilder/testutil/mwtest"
@@ -90,7 +91,7 @@ func TestCloneRepo(t *testing.T) {
90
91
clientFS := memfs .New ()
91
92
// A repo already exists!
92
93
_ = gittest .NewRepo (t , clientFS )
93
- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
94
+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
94
95
Path : "/" ,
95
96
RepoURL : srv .URL ,
96
97
Storage : clientFS ,
@@ -108,7 +109,7 @@ func TestCloneRepo(t *testing.T) {
108
109
srv := httptest .NewServer (authMW (gittest .NewServer (srvFS )))
109
110
clientFS := memfs .New ()
110
111
111
- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
112
+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
112
113
Path : "/workspace" ,
113
114
RepoURL : srv .URL ,
114
115
Storage : clientFS ,
@@ -145,7 +146,7 @@ func TestCloneRepo(t *testing.T) {
145
146
authURL .User = url .UserPassword (tc .username , tc .password )
146
147
clientFS := memfs .New ()
147
148
148
- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
149
+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
149
150
Path : "/workspace" ,
150
151
RepoURL : authURL .String (),
151
152
Storage : clientFS ,
@@ -184,7 +185,7 @@ func TestCloneRepoSSH(t *testing.T) {
184
185
gitURL := tr .String ()
185
186
clientFS := memfs .New ()
186
187
187
- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
188
+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
188
189
Path : "/workspace" ,
189
190
RepoURL : gitURL ,
190
191
Storage : clientFS ,
@@ -216,7 +217,7 @@ func TestCloneRepoSSH(t *testing.T) {
216
217
clientFS := memfs .New ()
217
218
218
219
anotherKey := randKeygen (t )
219
- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
220
+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
220
221
Path : "/workspace" ,
221
222
RepoURL : gitURL ,
222
223
Storage : clientFS ,
@@ -246,7 +247,7 @@ func TestCloneRepoSSH(t *testing.T) {
246
247
gitURL := tr .String ()
247
248
clientFS := memfs .New ()
248
249
249
- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
250
+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
250
251
Path : "/workspace" ,
251
252
RepoURL : gitURL ,
252
253
Storage : clientFS ,
@@ -270,7 +271,7 @@ func TestSetupRepoAuth(t *testing.T) {
270
271
opts := & options.Options {
271
272
Logger : testLog (t ),
272
273
}
273
- auth := envbuilder .SetupRepoAuth (opts )
274
+ auth := git .SetupRepoAuth (opts )
274
275
require .Nil (t , auth )
275
276
})
276
277
@@ -279,7 +280,7 @@ func TestSetupRepoAuth(t *testing.T) {
279
280
GitURL : "http://host.tld/repo" ,
280
281
Logger : testLog (t ),
281
282
}
282
- auth := envbuilder .SetupRepoAuth (opts )
283
+ auth := git .SetupRepoAuth (opts )
283
284
require .Nil (t , auth )
284
285
})
285
286
@@ -290,7 +291,7 @@ func TestSetupRepoAuth(t *testing.T) {
290
291
GitPassword : "pass" ,
291
292
Logger : testLog (t ),
292
293
}
293
- auth := envbuilder .SetupRepoAuth (opts )
294
+ auth := git .SetupRepoAuth (opts )
294
295
ba , ok := auth .(* githttp.BasicAuth )
295
296
require .True (t , ok )
296
297
require .Equal (t , opts .GitUsername , ba .Username )
@@ -304,7 +305,7 @@ func TestSetupRepoAuth(t *testing.T) {
304
305
GitPassword : "pass" ,
305
306
Logger : testLog (t ),
306
307
}
307
- auth := envbuilder .SetupRepoAuth (opts )
308
+ auth := git .SetupRepoAuth (opts )
308
309
ba , ok := auth .(* githttp.BasicAuth )
309
310
require .True (t , ok )
310
311
require .Equal (t , opts .GitUsername , ba .Username )
@@ -318,7 +319,7 @@ func TestSetupRepoAuth(t *testing.T) {
318
319
GitSSHPrivateKeyPath : kPath ,
319
320
Logger : testLog (t ),
320
321
}
321
- auth := envbuilder .SetupRepoAuth (opts )
322
+ auth := git .SetupRepoAuth (opts )
322
323
_ , ok := auth .(* gitssh.PublicKeys )
323
324
require .True (t , ok )
324
325
})
@@ -330,7 +331,7 @@ func TestSetupRepoAuth(t *testing.T) {
330
331
GitSSHPrivateKeyPath : kPath ,
331
332
Logger : testLog (t ),
332
333
}
333
- auth := envbuilder .SetupRepoAuth (opts )
334
+ auth := git .SetupRepoAuth (opts )
334
335
_ , ok := auth .(* gitssh.PublicKeys )
335
336
require .True (t , ok )
336
337
})
@@ -343,7 +344,7 @@ func TestSetupRepoAuth(t *testing.T) {
343
344
GitSSHPrivateKeyPath : kPath ,
344
345
Logger : testLog (t ),
345
346
}
346
- auth := envbuilder .SetupRepoAuth (opts )
347
+ auth := git .SetupRepoAuth (opts )
347
348
_ , ok := auth .(* gitssh.PublicKeys )
348
349
require .True (t , ok )
349
350
})
@@ -356,7 +357,7 @@ func TestSetupRepoAuth(t *testing.T) {
356
357
GitUsername : "user" ,
357
358
Logger : testLog (t ),
358
359
}
359
- auth := envbuilder .SetupRepoAuth (opts )
360
+ auth := git .SetupRepoAuth (opts )
360
361
_ , ok := auth .(* gitssh.PublicKeys )
361
362
require .True (t , ok )
362
363
})
@@ -368,7 +369,7 @@ func TestSetupRepoAuth(t *testing.T) {
368
369
GitSSHPrivateKeyPath : kPath ,
369
370
Logger : testLog (t ),
370
371
}
371
- auth := envbuilder .SetupRepoAuth (opts )
372
+ auth := git .SetupRepoAuth (opts )
372
373
pk , ok := auth .(* gitssh.PublicKeys )
373
374
require .True (t , ok )
374
375
require .NotNil (t , pk .Signer )
@@ -382,7 +383,7 @@ func TestSetupRepoAuth(t *testing.T) {
382
383
GitURL :
"ssh://[email protected] :repo/path" ,
383
384
Logger : testLog (t ),
384
385
}
385
- auth := envbuilder .SetupRepoAuth (opts )
386
+ auth := git .SetupRepoAuth (opts )
386
387
require .Nil (t , auth ) // TODO: actually test SSH_AUTH_SOCK
387
388
})
388
389
}
0 commit comments