@@ -3,6 +3,7 @@ package console
3
3
import (
4
4
"os"
5
5
"reflect"
6
+ "runtime"
6
7
7
8
"github.com/golang/mock/gomock"
8
9
. "github.com/onsi/ginkgo"
@@ -326,26 +327,20 @@ var _ = Describe("console command", func() {
326
327
})
327
328
328
329
Context ("An container is created to run the console, prior to doing that we need to check if container distro is supported" , func () {
329
-
330
- ced := & dockerLinux {}
331
- cep := & podmanLinux {}
332
-
333
- // Consider refactoring the following function as it isn't being used
334
- It ("Check for the existance of a invalid container engine" , func () {
335
- vld , err := validateContainerEngine ("Foo Bar" )
336
- Expect (vld ).To (BeFalse ())
337
- Expect (err ).To (MatchError (ContainSubstring ("container engine can only be one of" )))
338
- })
339
-
340
- // For some strange reason reflect of cei returns a pointer
341
-
342
330
It ("In the case we explicitly specify Podman, the code should return support for Podman" , func () {
343
331
oldpath := createPathPodman ()
344
332
o := consoleOptions {}
345
333
o .containerEngineFlag = PODMAN
346
334
cei , err := o .getContainerEngineImpl ()
347
335
Expect (err ).To (BeNil ())
348
- Expect (reflect .TypeOf (cei ) == reflect .TypeOf (cep )).To (BeTrue ())
336
+
337
+ if runtime .GOOS == LINUX {
338
+ Expect (reflect .TypeOf (cei ) == reflect .TypeOf (& podmanLinux {})).To (BeTrue ())
339
+ }
340
+ if runtime .GOOS == MACOS {
341
+ Expect (reflect .TypeOf (cei ) == reflect .TypeOf (& podmanMac {})).To (BeTrue ())
342
+ }
343
+
349
344
removePath (oldpath )
350
345
})
351
346
@@ -355,28 +350,21 @@ var _ = Describe("console command", func() {
355
350
o .containerEngineFlag = DOCKER
356
351
cei1 , err1 := o .getContainerEngineImpl ()
357
352
Expect (err1 ).To (BeNil ())
358
- Expect (reflect .TypeOf (cei1 ) == reflect .TypeOf (ced )).To (BeTrue ())
359
- removePath (oldpath )
360
- })
361
353
362
- It ("Test if environment varible could be read by the code to identify what container engine to use" , func () {
363
- oldpath := createPathPodman ()
364
- o := consoleOptions {}
365
- os .Setenv ("CONTAINER_ENGINE" , PODMAN )
366
- o .containerEngineFlag = ""
367
- cei2 , err2 := o .getContainerEngineImpl ()
368
- Expect (err2 ).To (BeNil ())
369
- Expect (reflect .TypeOf (cei2 ) == reflect .TypeOf (cep )).To (BeTrue ())
354
+ if runtime .GOOS == LINUX {
355
+ Expect (reflect .TypeOf (cei1 ) == reflect .TypeOf (& dockerLinux {})).To (BeTrue ())
356
+ }
357
+ if runtime .GOOS == MACOS {
358
+ Expect (reflect .TypeOf (cei1 ) == reflect .TypeOf (& dockerMac {})).To (BeTrue ())
359
+ }
370
360
removePath (oldpath )
371
361
})
372
362
373
- It ("Test the situation where the environment varible is something else " , func () {
363
+ It ("Test the situation where the environment variable is not a supported value " , func () {
374
364
o := consoleOptions {}
375
365
o .containerEngineFlag = "FOO"
376
- os .Setenv ("BACKPLANE_DEFAULT_OPEN_BROWSER" , "FALSE" )
377
366
_ , err4 := o .getContainerEngineImpl ()
378
367
Expect (err4 ).To (MatchError (ContainSubstring ("container engine can only be one of podman|docker" )))
379
- os .Setenv ("BACKPLANE_DEFAULT_OPEN_BROWSER" , "" )
380
368
})
381
369
})
382
370
0 commit comments