mirror of
https://github.com/rancher/os.git
synced 2025-09-02 07:15:41 +00:00
Use a map to configure Docker arguments
This commit is contained in:
48
config/docker_config_test.go
Normal file
48
config/docker_config_test.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func testContains(t *testing.T, s string, substrs ...string) {
|
||||
for _, substr := range substrs {
|
||||
if !strings.Contains(s, substr) {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateEngineOptsString(t *testing.T) {
|
||||
if len(generateEngineOptsSlice(EngineOpts{})) != 0 {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
testContains(t, fmt.Sprint(generateEngineOptsSlice(EngineOpts{
|
||||
Bridge: "bridge",
|
||||
})), "--bridge bridge")
|
||||
|
||||
testContains(t, fmt.Sprint(generateEngineOptsSlice(EngineOpts{
|
||||
SelinuxEnabled: &[]bool{true}[0],
|
||||
})), "--selinux-enabled")
|
||||
testContains(t, fmt.Sprint(generateEngineOptsSlice(EngineOpts{
|
||||
SelinuxEnabled: &[]bool{false}[0],
|
||||
})), "--selinux-enabled=false")
|
||||
|
||||
testContains(t, fmt.Sprint(generateEngineOptsSlice(EngineOpts{
|
||||
LogOpts: map[string]string{
|
||||
"max-size": "25m",
|
||||
"max-file": "2",
|
||||
},
|
||||
})), "--log-opt max-size=25m", "--log-opt max-file=2")
|
||||
|
||||
testContains(t, fmt.Sprint(generateEngineOptsSlice(EngineOpts{
|
||||
Bridge: "bridge",
|
||||
SelinuxEnabled: &[]bool{true}[0],
|
||||
LogOpts: map[string]string{
|
||||
"max-size": "25m",
|
||||
"max-file": "2",
|
||||
},
|
||||
})), "--bridge bridge", "--selinux-enabled", "--log-opt max-size=25m", "--log-opt max-file=2")
|
||||
}
|
Reference in New Issue
Block a user