Skip to content

Commit

Permalink
config: Add parseCmdlineOption test
Browse files Browse the repository at this point in the history
Add a unit test for the `parseCmdlineOption()` function.

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed Jul 18, 2019
1 parent d4f205d commit 8eb2134
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 8eb2134

Please sign in to comment.