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