-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkMode.purs
More file actions
50 lines (39 loc) · 1.48 KB
/
NetworkMode.purs
File metadata and controls
50 lines (39 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module Test.NetworkMode (networkModeTest) where
import Prelude
import Data.Either (Either(..))
import Effect.Aff (error, throwError)
import Test.Spec (Spec, describe, it)
import Test.Spec.Assertions.String (shouldContain)
import Test.Testcontainers (setCommand, setNetworkMode, withContainer)
import Test.Testcontainers.Types (NetworkMode(..))
import Test.Utils (mkAffContainer)
networkModeTest :: Spec Unit
networkModeTest = describe "Network Mode" $ do
it "should set bridge network mode" $ do
cnt <- mkAffContainer "alpine:latest" $
setNetworkMode (NetworkMode "bridge")
<<< setCommand [ "sleep", "infinity" ]
res <- withContainer cnt $ \_ -> do
pure unit
case res of
Left e -> throwError $ error e
Right _ -> pure unit
it "should set host network mode" $ do
cnt <- mkAffContainer "alpine:latest" $
setNetworkMode (NetworkMode "host")
<<< setCommand [ "sleep", "infinity" ]
res <- withContainer cnt $ \_ -> do
pure unit
case res of
Left e -> throwError $ error e
Right _ -> pure unit
it "should detect invalid network modes" $ do
cnt <- mkAffContainer "alpine:latest" $
setNetworkMode (NetworkMode "invalid")
<<< setCommand [ "sleep", "infinity" ]
-- We should not enter here
res <- withContainer cnt $ \_ -> do
pure unit
case res of
Left e -> e `shouldContain` "network invalid not found"
Right _ -> throwError $ error "invalid network mode not detected"