1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 06:11:12 +00:00
Files
os/config/docker_config_test.go
Olli Janatuinen f87c220f1b v2.0.0-beta7
- Docker 24.0.5
- Kernel 5.10.188
- System-docker 17.06.108
- System container images compresses with zstd instead of xz
- Added WSL2 support
- Include Hyper-V, ProxmoxVE and VMware tools to ISO
- Include apparmor tools to console
- Enable apparmor by default
- Remove experimental selinux support
- Include chroot command to initrd
2023-08-06 12:55:50 +00:00

62 lines
1.3 KiB
Go

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()
}
if len(generateEngineOptsSlice(EngineOpts{
Host: []string{
"",
},
})) != 0 {
t.Fail()
}
if len(generateEngineOptsSlice(EngineOpts{
LogOpts: map[string]string{
"max-file": "",
},
})) != 0 {
t.Fail()
}
testContains(t, fmt.Sprint(generateEngineOptsSlice(EngineOpts{
Bridge: "bridge",
})), "--bridge bridge")
testContains(t, fmt.Sprint(generateEngineOptsSlice(EngineOpts{
Host: []string{
"unix:///var/run/system-docker.sock",
"unix:///var/run/docker.sock",
},
})), "--host unix:///var/run/system-docker.sock", "--host unix:///var/run/docker.sock")
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",
LogOpts: map[string]string{
"max-size": "25m",
"max-file": "2",
},
})), "--bridge bridge", "--log-opt max-size=25m", "--log-opt max-file=2")
}