-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae0d05a
commit 95952eb
Showing
12 changed files
with
360 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package outputs | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestJsonOneline_Name(t *testing.T) { | ||
j := JsonOneline{} | ||
assert.Equal(t, "json_oneline", j.Name()) | ||
} | ||
|
||
func TestJsonOneline_Output_FAIL(t *testing.T) { | ||
duration, _ := time.ParseDuration("2s") | ||
result, exitCode := runOutput(JsonOneline{duration: duration}, getFailTestResult()) | ||
|
||
expected := `{"results":[{"duration":500,"err":null,"expected":["expected"],"found":null,"human":"","meta":null,"property":"a property","resource-id":"my resource id","resource-type":"resource type","result":1,"successful":false,"summary-line":"resource type: my resource id: a property: doesn't match, expect: [expected] found: []","test-type":0,"title":"failure"}],"summary":{"failed-count":1,"summary-line":"Count: 1, Failed: 1, Duration: 2.000s","test-count":1,"total-duration":2000000000}} | ||
` | ||
assert.Equal(t, expected, result) | ||
assert.Equal(t, 1, exitCode) | ||
} | ||
|
||
func TestJsonOneline_Output_Success(t *testing.T) { | ||
duration, _ := time.ParseDuration("2s") | ||
result, exitCode := runOutput(JsonOneline{duration: duration}, getSuccessTestResult()) | ||
|
||
expected := `{"results":[{"duration":500,"err":null,"expected":["expected"],"found":null,"human":"","meta":null,"property":"a property","resource-id":"my resource id","resource-type":"resource type","result":0,"successful":true,"summary-line":"resource type: my resource id: a property: matches expectation: [expected]","test-type":0,"title":"my title"}],"summary":{"failed-count":0,"summary-line":"Count: 1, Failed: 0, Duration: 2.000s","test-count":1,"total-duration":2000000000}} | ||
` | ||
assert.Equal(t, expected, result) | ||
assert.Equal(t, 0, exitCode) | ||
} | ||
|
||
func TestJsonOneline_Output_Skip(t *testing.T) { | ||
duration, _ := time.ParseDuration("2s") | ||
result, exitCode := runOutput(JsonOneline{duration: duration}, getSkipTestResult()) | ||
|
||
expected := `{"results":[{"duration":500,"err":null,"expected":["expected"],"found":null,"human":"","meta":null,"property":"a property","resource-id":"my resource id","resource-type":"resource type","result":2,"successful":true,"summary-line":"resource type: my resource id: a property: skipped","test-type":0,"title":"failure"}],"summary":{"failed-count":0,"summary-line":"Count: 1, Failed: 0, Duration: 2.000s","test-count":1,"total-duration":2000000000}} | ||
` | ||
assert.Equal(t, expected, result) | ||
assert.Equal(t, 0, exitCode) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package outputs | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestJunit_Name(t *testing.T) { | ||
j := JUnit{} | ||
assert.Equal(t, "junit", j.Name()) | ||
} | ||
|
||
func getDate() string { | ||
return time.Date( | ||
2019, 01, 01, 10, 30, 30, 3000, time.UTC).Format(time.RFC3339) | ||
} | ||
|
||
func TestJunit_Output_Fail(t *testing.T) { | ||
result, exitCode := runOutput(JUnit{testingTimestamp: getDate()}, getFailTestResult()) | ||
|
||
expected := `<?xml version="1.0" encoding="UTF-8"?> | ||
<testsuite name="goss" errors="0" tests="1" failures="1" skipped="0" time="0.000" testingTimestamp="2019-01-01T10:30:30Z"> | ||
<testcase name="resource type my resource id a property" time="0.000"> | ||
<system-err>resource type: my resource id: a property: doesn't match, expect: [expected] found: []</system-err> | ||
<failure>resource type: my resource id: a property: doesn't match, expect: [expected] found: []</failure> | ||
</testcase> | ||
</testsuite> | ||
` | ||
assert.Equal(t, expected, result) | ||
assert.Equal(t, 1, exitCode) | ||
} | ||
|
||
func TestJunit_Output_Success(t *testing.T) { | ||
result, exitCode := runOutput(JUnit{testingTimestamp: getDate()}, getSuccessTestResult()) | ||
|
||
expected := `<?xml version="1.0" encoding="UTF-8"?> | ||
<testsuite name="goss" errors="0" tests="1" failures="0" skipped="0" time="0.000" testingTimestamp="2019-01-01T10:30:30Z"> | ||
<testcase name="resource type my resource id a property" time="0.000"> | ||
<system-out>resource type: my resource id: a property: matches expectation: [expected]</system-out> | ||
</testcase> | ||
</testsuite> | ||
` | ||
assert.Equal(t, expected, result) | ||
assert.Equal(t, 0, exitCode) | ||
} | ||
|
||
func TestJunit_Output_Skip(t *testing.T) { | ||
result, exitCode := runOutput(JUnit{testingTimestamp: getDate()}, getSkipTestResult()) | ||
|
||
expected := `<?xml version="1.0" encoding="UTF-8"?> | ||
<testsuite name="goss" errors="0" tests="1" failures="0" skipped="1" time="0.000" testingTimestamp="2019-01-01T10:30:30Z"> | ||
<testcase name="resource type my resource id a property" time="0.000"> | ||
<skipped/><system-out>resource type: my resource id: a property: skipped</system-out> | ||
</testcase> | ||
</testsuite> | ||
` | ||
assert.Equal(t, expected, result) | ||
assert.Equal(t, 0, exitCode) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package outputs | ||
|
||
import ( | ||
"github.com/magiconair/properties/assert" | ||
"testing" | ||
) | ||
|
||
func Test_Outputers(t *testing.T) { | ||
outputer := GetOutputer("json") | ||
assert.Equal(t, "json", outputer.Name()) | ||
|
||
registeredOutputers := []string{ | ||
"documentation", | ||
"json", | ||
"json_oneline", | ||
"junit", | ||
"nagios", | ||
"rspecish", | ||
"silent", | ||
"tap", | ||
} | ||
assert.Equal(t, registeredOutputers, Outputers()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.