@@ -21,24 +21,38 @@ import (
2121 "github.com/stretchr/testify/require"
2222)
2323
24- func TestMewzCommandStringNoNetwork (t * testing.T ) {
24+ func TestMewzCommandString (t * testing.T ) {
2525 t .Parallel ()
26- m := & Mewz {}
27- result , err := m .CommandString ()
28- require .NoError (t , err )
29- assert .Equal (t , "" , result , "CommandString should return empty string when no network is configured" )
30- }
3126
32- func TestMewzCommandStringWithNetwork (t * testing.T ) {
33- t .Parallel ()
34- m := & Mewz {
35- Net : MewzNet {
36- Address : "10.0.0.2" ,
37- Mask : 24 ,
38- Gateway : "10.0.0.1" ,
27+ testCases := []struct {
28+ name string
29+ mewz * Mewz
30+ expected string
31+ }{
32+ {
33+ name : "no network configured" ,
34+ mewz : & Mewz {},
35+ expected : "" ,
36+ },
37+ {
38+ name : "with network configured" ,
39+ mewz : & Mewz {
40+ Net : MewzNet {
41+ Address : "10.0.0.2" ,
42+ Mask : 24 ,
43+ Gateway : "10.0.0.1" ,
44+ },
45+ },
46+ expected : "ip=10.0.0.2/24 gateway=10.0.0.1" ,
3947 },
4048 }
41- result , err := m .CommandString ()
42- require .NoError (t , err )
43- assert .Equal (t , "ip=10.0.0.2/24 gateway=10.0.0.1" , result )
49+
50+ for _ , tc := range testCases {
51+ t .Run (tc .name , func (t * testing.T ) {
52+ t .Parallel ()
53+ result , err := tc .mewz .CommandString ()
54+ require .NoError (t , err )
55+ assert .Equal (t , tc .expected , result )
56+ })
57+ }
4458}
0 commit comments