Skip to content

Commit

Permalink
Added unit tests for the runner
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilibertDugas committed Jan 18, 2016
1 parent 0d4d70e commit 10675ee
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func init() {
}

func ExecuteGoltTest(goltTest Golts, logFile string) {
m := generateGoltMap(goltTest)
m := generateStageMap(goltTest)

var keys []int
for k := range m {
Expand All @@ -45,7 +45,7 @@ func ExecuteGoltTest(goltTest Golts, logFile string) {
logger.Finish()
}

func generateGoltMap(goltTest Golts) map[int][]GoltThreadGroup {
func generateStageMap(goltTest Golts) map[int][]GoltThreadGroup {
m := make(map[int][]GoltThreadGroup)
for _, element := range goltTest.Golt {
array := m[element.Stage]
Expand Down
29 changes: 29 additions & 0 deletions runner_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main
import (
"testing"
"time"
)

var testPlan = Golts{
Golt: []GoltThreadGroup{
GoltThreadGroup{Stage: 1, Timeout: 100},
GoltThreadGroup{Stage: 3, Timeout: 300},
GoltThreadGroup{Stage: 2, Timeout: 400},
GoltThreadGroup{Stage: 1, Timeout: 200},
},
}
func TestGenerateStageMap(t *testing.T) {
m := generateStageMap(testPlan)
if len(m[1]) != 2 || len(m[2]) != 1 || len(m[3]) != 1 {
t.Error("The stage map was not generated properly")
}
}

func TestGenerateHttpClient(t *testing.T) {
for _, entry := range testPlan.Golt {
client := generateHttpClient(entry)
if client.Timeout != time.Duration(time.Millisecond * time.Duration(entry.Timeout)) {
t.Error("The http client was not generated properly")
}
}
}

0 comments on commit 10675ee

Please sign in to comment.