Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Datree
Commits
61ed3584
Commit
61ed3584
authored
4 years ago
by
Dima Brusilovsky
Browse files
Options
Download
Email Patches
Plain Diff
fix: add tests for output flag in test command
parent
babe1347
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/test/main_test.go
+26
-0
cmd/test/main_test.go
with
26 additions
and
0 deletions
+26
-0
cmd/test/main_test.go
+
26
-
0
View file @
61ed3584
...
...
@@ -57,6 +57,12 @@ func TestTestCommand(t *testing.T) {
LocalConfig
:
localConfigManager
,
}
test_testCommand_no_flags
(
t
,
localConfigManager
,
evaluator
,
mockedEvaluateResponse
,
ctx
)
test_testCommand_json_output
(
t
,
localConfigManager
,
evaluator
,
mockedEvaluateResponse
,
ctx
)
test_testCommand_yaml_output
(
t
,
localConfigManager
,
evaluator
,
mockedEvaluateResponse
,
ctx
)
}
func
test_testCommand_no_flags
(
t
*
testing
.
T
,
localConfigManager
*
mockLocalConfigManager
,
evaluator
*
mockEvaluator
,
mockedEvaluateResponse
*
bl
.
EvaluationResults
,
ctx
*
TestCommandContext
)
{
test
(
ctx
,
"8/*"
,
TestCommandFlags
{})
localConfigManager
.
AssertCalled
(
t
,
"GetConfiguration"
)
...
...
@@ -65,3 +71,23 @@ func TestTestCommand(t *testing.T) {
evaluator
.
AssertNotCalled
(
t
,
"PrintFileParsingErrors"
)
evaluator
.
AssertCalled
(
t
,
"PrintResults"
,
mockedEvaluateResponse
,
"134kh"
,
""
)
}
func
test_testCommand_json_output
(
t
*
testing
.
T
,
localConfigManager
*
mockLocalConfigManager
,
evaluator
*
mockEvaluator
,
mockedEvaluateResponse
*
bl
.
EvaluationResults
,
ctx
*
TestCommandContext
)
{
test
(
ctx
,
"8/*"
,
TestCommandFlags
{
Output
:
"json"
})
localConfigManager
.
AssertCalled
(
t
,
"GetConfiguration"
)
expectedPath
,
_
:=
filepath
.
Abs
(
"8/*"
)
evaluator
.
AssertCalled
(
t
,
"Evaluate"
,
expectedPath
,
"134kh"
,
50
)
evaluator
.
AssertNotCalled
(
t
,
"PrintFileParsingErrors"
)
evaluator
.
AssertCalled
(
t
,
"PrintResults"
,
mockedEvaluateResponse
,
"134kh"
,
"json"
)
}
func
test_testCommand_yaml_output
(
t
*
testing
.
T
,
localConfigManager
*
mockLocalConfigManager
,
evaluator
*
mockEvaluator
,
mockedEvaluateResponse
*
bl
.
EvaluationResults
,
ctx
*
TestCommandContext
)
{
test
(
ctx
,
"8/*"
,
TestCommandFlags
{
Output
:
"yaml"
})
localConfigManager
.
AssertCalled
(
t
,
"GetConfiguration"
)
expectedPath
,
_
:=
filepath
.
Abs
(
"8/*"
)
evaluator
.
AssertCalled
(
t
,
"Evaluate"
,
expectedPath
,
"134kh"
,
50
)
evaluator
.
AssertNotCalled
(
t
,
"PrintFileParsingErrors"
)
evaluator
.
AssertCalled
(
t
,
"PrintResults"
,
mockedEvaluateResponse
,
"134kh"
,
"yaml"
)
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help