From 8eb213483d2f808bf57236180414da0bfc09d1eb Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Thu, 18 Jul 2019 13:40:10 +0100 Subject: [PATCH] config: Add parseCmdlineOption test Add a unit test for the `parseCmdlineOption()` function. Signed-off-by: James O. D. Hunt --- config_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/config_test.go b/config_test.go index e378479360..acb7a06bcb 100644 --- a/config_test.go +++ b/config_test.go @@ -333,3 +333,36 @@ func TestParseCmdlineOptionsVsock(t *testing.T) { assert.Equal(commCh, d.expectedCommCh) } } + +func TestParseCmdlineOptionDebugConsole(t *testing.T) { + assert := assert.New(t) + + a := &agentConfig{} + + type testData struct { + option string + expectDebugConsoleEnabled bool + } + + data := []testData{ + {"", false}, + {"debug_console", false}, + {"debug_console=true", false}, + {"debug_console=1", false}, + + {"agent.debug_console", true}, + } + + for i, d := range data { + debugConsole = false + + err := a.parseCmdlineOption(d.option) + assert.NoError(err) + + if !d.expectDebugConsoleEnabled { + continue + } + + assert.True(debugConsole, "test %d (%+v)", i, d) + } +}