1- package envbuilder_test
1+ package git_test
22
33import (
44 "context"
@@ -12,9 +12,10 @@ import (
1212 "regexp"
1313 "testing"
1414
15+ "github.com/coder/envbuilder/git"
16+
1517 "github.com/coder/envbuilder/options"
1618
17- "github.com/coder/envbuilder"
1819 "github.com/coder/envbuilder/internal/log"
1920 "github.com/coder/envbuilder/testutil/gittest"
2021 "github.com/coder/envbuilder/testutil/mwtest"
@@ -90,7 +91,7 @@ func TestCloneRepo(t *testing.T) {
9091 clientFS := memfs .New ()
9192 // A repo already exists!
9293 _ = gittest .NewRepo (t , clientFS )
93- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
94+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
9495 Path : "/" ,
9596 RepoURL : srv .URL ,
9697 Storage : clientFS ,
@@ -108,7 +109,7 @@ func TestCloneRepo(t *testing.T) {
108109 srv := httptest .NewServer (authMW (gittest .NewServer (srvFS )))
109110 clientFS := memfs .New ()
110111
111- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
112+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
112113 Path : "/workspace" ,
113114 RepoURL : srv .URL ,
114115 Storage : clientFS ,
@@ -145,7 +146,7 @@ func TestCloneRepo(t *testing.T) {
145146 authURL .User = url .UserPassword (tc .username , tc .password )
146147 clientFS := memfs .New ()
147148
148- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
149+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
149150 Path : "/workspace" ,
150151 RepoURL : authURL .String (),
151152 Storage : clientFS ,
@@ -184,7 +185,7 @@ func TestCloneRepoSSH(t *testing.T) {
184185 gitURL := tr .String ()
185186 clientFS := memfs .New ()
186187
187- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
188+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
188189 Path : "/workspace" ,
189190 RepoURL : gitURL ,
190191 Storage : clientFS ,
@@ -216,7 +217,7 @@ func TestCloneRepoSSH(t *testing.T) {
216217 clientFS := memfs .New ()
217218
218219 anotherKey := randKeygen (t )
219- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
220+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
220221 Path : "/workspace" ,
221222 RepoURL : gitURL ,
222223 Storage : clientFS ,
@@ -246,7 +247,7 @@ func TestCloneRepoSSH(t *testing.T) {
246247 gitURL := tr .String ()
247248 clientFS := memfs .New ()
248249
249- cloned , err := envbuilder .CloneRepo (context .Background (), envbuilder .CloneRepoOptions {
250+ cloned , err := git .CloneRepo (context .Background (), git .CloneRepoOptions {
250251 Path : "/workspace" ,
251252 RepoURL : gitURL ,
252253 Storage : clientFS ,
@@ -270,7 +271,7 @@ func TestSetupRepoAuth(t *testing.T) {
270271 opts := & options.Options {
271272 Logger : testLog (t ),
272273 }
273- auth := envbuilder .SetupRepoAuth (opts )
274+ auth := git .SetupRepoAuth (opts )
274275 require .Nil (t , auth )
275276 })
276277
@@ -279,7 +280,7 @@ func TestSetupRepoAuth(t *testing.T) {
279280 GitURL : "http://host.tld/repo" ,
280281 Logger : testLog (t ),
281282 }
282- auth := envbuilder .SetupRepoAuth (opts )
283+ auth := git .SetupRepoAuth (opts )
283284 require .Nil (t , auth )
284285 })
285286
@@ -290,7 +291,7 @@ func TestSetupRepoAuth(t *testing.T) {
290291 GitPassword : "pass" ,
291292 Logger : testLog (t ),
292293 }
293- auth := envbuilder .SetupRepoAuth (opts )
294+ auth := git .SetupRepoAuth (opts )
294295 ba , ok := auth .(* githttp.BasicAuth )
295296 require .True (t , ok )
296297 require .Equal (t , opts .GitUsername , ba .Username )
@@ -304,7 +305,7 @@ func TestSetupRepoAuth(t *testing.T) {
304305 GitPassword : "pass" ,
305306 Logger : testLog (t ),
306307 }
307- auth := envbuilder .SetupRepoAuth (opts )
308+ auth := git .SetupRepoAuth (opts )
308309 ba , ok := auth .(* githttp.BasicAuth )
309310 require .True (t , ok )
310311 require .Equal (t , opts .GitUsername , ba .Username )
@@ -318,7 +319,7 @@ func TestSetupRepoAuth(t *testing.T) {
318319 GitSSHPrivateKeyPath : kPath ,
319320 Logger : testLog (t ),
320321 }
321- auth := envbuilder .SetupRepoAuth (opts )
322+ auth := git .SetupRepoAuth (opts )
322323 _ , ok := auth .(* gitssh.PublicKeys )
323324 require .True (t , ok )
324325 })
@@ -330,7 +331,7 @@ func TestSetupRepoAuth(t *testing.T) {
330331 GitSSHPrivateKeyPath : kPath ,
331332 Logger : testLog (t ),
332333 }
333- auth := envbuilder .SetupRepoAuth (opts )
334+ auth := git .SetupRepoAuth (opts )
334335 _ , ok := auth .(* gitssh.PublicKeys )
335336 require .True (t , ok )
336337 })
@@ -343,7 +344,7 @@ func TestSetupRepoAuth(t *testing.T) {
343344 GitSSHPrivateKeyPath : kPath ,
344345 Logger : testLog (t ),
345346 }
346- auth := envbuilder .SetupRepoAuth (opts )
347+ auth := git .SetupRepoAuth (opts )
347348 _ , ok := auth .(* gitssh.PublicKeys )
348349 require .True (t , ok )
349350 })
@@ -356,7 +357,7 @@ func TestSetupRepoAuth(t *testing.T) {
356357 GitUsername : "user" ,
357358 Logger : testLog (t ),
358359 }
359- auth := envbuilder .SetupRepoAuth (opts )
360+ auth := git .SetupRepoAuth (opts )
360361 _ , ok := auth .(* gitssh.PublicKeys )
361362 require .True (t , ok )
362363 })
@@ -368,7 +369,7 @@ func TestSetupRepoAuth(t *testing.T) {
368369 GitSSHPrivateKeyPath : kPath ,
369370 Logger : testLog (t ),
370371 }
371- auth := envbuilder .SetupRepoAuth (opts )
372+ auth := git .SetupRepoAuth (opts )
372373 pk , ok := auth .(* gitssh.PublicKeys )
373374 require .True (t , ok )
374375 require .NotNil (t , pk .Signer )
@@ -382,7 +383,7 @@ func TestSetupRepoAuth(t *testing.T) {
382383 GitURL : "ssh://git@host.tld:repo/path" ,
383384 Logger : testLog (t ),
384385 }
385- auth := envbuilder .SetupRepoAuth (opts )
386+ auth := git .SetupRepoAuth (opts )
386387 require .Nil (t , auth ) // TODO: actually test SSH_AUTH_SOCK
387388 })
388389}
0 commit comments