@@ -38,6 +38,15 @@ func TestNetworkInspect(t *testing.T) {
38
38
testIPRange = "10.24.24.0/25"
39
39
)
40
40
41
+ testCase .Setup = func (data test.Data , helpers test.Helpers ) {
42
+ helpers .Ensure ("network" , "create" , data .Identifier ("basenet" ))
43
+ data .Set ("basenet" , data .Identifier ("basenet" ))
44
+ }
45
+
46
+ testCase .Cleanup = func (data test.Data , helpers test.Helpers ) {
47
+ helpers .Anyhow ("network" , "rm" , data .Identifier ("basenet" ))
48
+ }
49
+
41
50
testCase .SubTests = []* test.Case {
42
51
{
43
52
Description : "non existent network" ,
@@ -87,6 +96,18 @@ func TestNetworkInspect(t *testing.T) {
87
96
assert .Equal (t , dc [0 ].Name , "bridge" )
88
97
}),
89
98
},
99
+ {
100
+ Description : "nat" ,
101
+ Require : test .Windows ,
102
+ Command : test .Command ("network" , "inspect" , "nat" ),
103
+ Expected : test .Expects (0 , nil , func (stdout string , info string , t * testing.T ) {
104
+ var dc []dockercompat.Network
105
+ err := json .Unmarshal ([]byte (stdout ), & dc )
106
+ assert .NilError (t , err , "Unable to unmarshal output\n " + info )
107
+ assert .Equal (t , 1 , len (dc ), "Unexpectedly got multiple results\n " + info )
108
+ assert .Equal (t , dc [0 ].Name , "nat" )
109
+ }),
110
+ },
90
111
{
91
112
Description : "custom" ,
92
113
Setup : func (data test.Data , helpers test.Helpers ) {
@@ -106,9 +127,8 @@ func TestNetworkInspect(t *testing.T) {
106
127
},
107
128
{
108
129
Description : "match exact id" ,
109
- Require : test .Not (test .Windows ),
110
130
Command : func (data test.Data , helpers test.Helpers ) test.TestableCommand {
111
- id := strings .TrimSpace (helpers .Capture ("network" , "inspect" , "bridge" , "--format" , "{{ .Id }}" ))
131
+ id := strings .TrimSpace (helpers .Capture ("network" , "inspect" , data . Get ( "basenet" ) , "--format" , "{{ .Id }}" ))
112
132
return helpers .Command ("network" , "inspect" , id )
113
133
},
114
134
Expected : test .Expects (0 , nil , func (stdout string , info string , t * testing.T ) {
@@ -121,9 +141,8 @@ func TestNetworkInspect(t *testing.T) {
121
141
},
122
142
{
123
143
Description : "match part of id" ,
124
- Require : test .Not (test .Windows ),
125
144
Command : func (data test.Data , helpers test.Helpers ) test.TestableCommand {
126
- id := strings .TrimSpace (helpers .Capture ("network" , "inspect" , "bridge" , "--format" , "{{ .Id }}" ))
145
+ id := strings .TrimSpace (helpers .Capture ("network" , "inspect" , data . Get ( "basenet" ) , "--format" , "{{ .Id }}" ))
127
146
return helpers .Command ("network" , "inspect" , id [0 :25 ])
128
147
},
129
148
Expected : test .Expects (0 , nil , func (stdout string , info string , t * testing.T ) {
0 commit comments