1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon/logger/loggerutils/log_option_helpers_test.go
Jussi Nummelin 3cf82ff1ab Added flag to ignore fluentd connect error on container start
Signed-off-by: Jussi Nummelin <jussi.nummelin@gmail.com>

Changed buffer size to 1M and removed unnecessary fmt call

Signed-off-by: Jussi Nummelin <jussi.nummelin@gmail.com>

Updated docs for the new fluentd opts

Signed-off-by: Jussi Nummelin <jussi.nummelin@gmail.com>
2016-01-27 09:05:44 +02:00

51 lines
1.2 KiB
Go

package loggerutils
import (
"testing"
"github.com/docker/docker/daemon/logger"
)
func TestParseDefaultIgnoreFlag(t *testing.T) {
ctx := buildContext(map[string]string{})
flag, e := ParseFailOnStartupErrorFlag(ctx)
assertFlag(t, e, flag, true)
}
func TestParseIgnoreFlagWhenFalse(t *testing.T) {
ctx := buildContext(map[string]string{"fail-on-startup-error": "false"})
flag, e := ParseFailOnStartupErrorFlag(ctx)
assertFlag(t, e, flag, false)
}
func TestParseIgnoreFlagWhenTrue(t *testing.T) {
ctx := buildContext(map[string]string{"fail-on-startup-error": "true"})
flag, e := ParseFailOnStartupErrorFlag(ctx)
assertFlag(t, e, flag, true)
}
func TestParseIgnoreFlagWithError(t *testing.T) {
ctx := buildContext(map[string]string{"fail-on-startup-error": "maybe :)"})
flag, e := ParseFailOnStartupErrorFlag(ctx)
if e == nil {
t.Fatalf("Error should have happened")
}
assertFlag(t, nil, flag, true)
}
// Helpers
func buildConfig(cfg map[string]string) logger.Context {
return logger.Context{
Config: cfg,
}
}
func assertFlag(t *testing.T, e error, flag bool, expected bool) {
if e != nil {
t.Fatalf("Error parsing ignore connect error flag: %q", e)
}
if flag != expected {
t.Fatalf("Wrong flag: %t, should be %t", flag, expected)
}
}