Skip to content

Commit

Permalink
fixing to latest version of gogiven
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcorbyeaglen committed Mar 1, 2018
1 parent 43c0c35 commit b65798a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
17 changes: 9 additions & 8 deletions generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func TestTestOutputGenerator_Generate(testing *testing.T) {
AssertThat(testing, jsonString, is.EqualToIgnoringWhitespace(
`{
"title": "Generator Test",
"test_state": {
"test title": {
"test_state": [
{
"test_results": {
"id": "abc2124",
"failed": true,
Expand All @@ -53,7 +53,7 @@ func TestTestOutputGenerator_Generate(testing *testing.T) {
]
}
}
}
]
}`))
}

Expand Down Expand Up @@ -109,12 +109,13 @@ func fileIsConverted() {
}

func newPageData(skipped bool, failed bool) generator.PageData {
testData := make(map[string]generator.TestData)
var testData []generator.TestData

capturedIO := make(map[interface{}]interface{})
capturedIO["foob"] = "barb"
interestingGivens := make(map[interface{}]interface{})
interestingGivens["faff"] = "flap"
testData["test title"] = generator.TestData{
testData = append(testData, generator.TestData{
TestTitle: "test title",
ParsedTestContent: base.ParsedTestContent{
GivenWhenThen: []string{"given", "when", "then"},
Expand All @@ -128,9 +129,9 @@ func newPageData(skipped bool, failed bool) generator.PageData {
TestOutput: "well alrighty then",
TestID: "abc2124",
},
}
})
return generator.PageData{
TestResults: testData,
Title: "Generator Test",
TestData: testData,
Title: "Generator Test",
}
}
4 changes: 4 additions & 0 deletions jsongenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ func (outputGenerator *TestOutputGenerator) Generate(pageData generator.PageData
json.Indent(out, jsonBytes, "", "\t")
return out
}

func (outputGenerator *TestOutputGenerator) GenerateIndex(indexData []generator.IndexData) io.Reader{
return bytes.NewReader(nil) //TODO: implement some kind of index
}
7 changes: 3 additions & 4 deletions model/jsondata.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ import "github.com/corbym/gogiven/generator"
//JSONData is the JSON model for the test contemt
type JSONData struct {
Title string `json:"title"`
TestState map[string]*testState `json:"test_state"`
TestState []*testState `json:"test_state"`
}

//NewJSONData is internal and creates a new json data object for marshalling test data
func NewJSONData(pageData generator.PageData) *JSONData {
jsonPageData := new(JSONData)
jsonPageData.Title = pageData.Title
jsonPageData.TestState = make(map[string]*testState, len(pageData.TestResults))
for k, v := range pageData.TestResults {
jsonPageData.TestState[k] = newTestState(v)
for _, v := range pageData.TestData {
jsonPageData.TestState = append(jsonPageData.TestState, newTestState(v))
}
return jsonPageData
}

0 comments on commit b65798a

Please sign in to comment.