12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 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")
- }
|