-
Notifications
You must be signed in to change notification settings - Fork 3
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
a1f2ce6
commit 9bb7767
Showing
7 changed files
with
71 additions
and
17 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
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 |
---|---|---|
@@ -1,9 +1,63 @@ | ||
package generator | ||
|
||
import "github.com/corbym/gogiven/base" | ||
import ( | ||
"github.com/corbym/gogiven/base" | ||
"github.com/corbym/gogiven/testdata" | ||
) | ||
|
||
type TestResult struct { | ||
TestId string | ||
Failed bool | ||
Skipped bool | ||
TestOutput string | ||
} | ||
|
||
func NewTestResult(data *base.TestMetaData) (result *TestResult) { | ||
result = &TestResult{ | ||
Skipped: data.Skipped(), | ||
TestId: data.Name(), | ||
TestOutput: data.TestOutput(), | ||
Failed: data.Failed(), | ||
} | ||
return | ||
} | ||
|
||
type TestData struct { | ||
TestResult *TestResult | ||
TestTitle string | ||
InterestingGivens testdata.InterestingGivens | ||
CapturedIO testdata.CapturedIO | ||
GivenWhenThen []string | ||
} | ||
|
||
func NewTestData(some *base.Some) (testData *TestData) { | ||
testData = &TestData{ | ||
TestResult: NewTestResult(some.TestMetaData()), | ||
InterestingGivens: some.InterestingGivens(), | ||
CapturedIO: some.CapturedIO(), | ||
GivenWhenThen: some.GivenWhenThen(), | ||
TestTitle: some.TestTitle(), | ||
} | ||
return | ||
} | ||
|
||
//PageData is the struct that populates the template with data from the test output. | ||
type PageData struct { | ||
Title string | ||
SomeMap *base.SomeMap | ||
Title string | ||
TestResults map[string]*TestData | ||
} | ||
|
||
func NewPageData(title string, someMap *base.SomeMap) (pageData *PageData) { | ||
pageData = new(PageData) | ||
pageData.Title = title | ||
pageData.TestResults = copyTestResults(someMap) | ||
return | ||
} | ||
|
||
func copyTestResults(someMap *base.SomeMap) (testData map[string]*TestData) { | ||
testData = make(map[string]*TestData) | ||
for k, v := range *someMap { | ||
testData[k] = NewTestData(v) | ||
} | ||
return | ||
} |
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