Skip to content

Commit

Permalink
add basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Nov 12, 2019
1 parent d2c5338 commit 3a5b3c6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lagoon/environments/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,16 @@ func checkEqual(t *testing.T, got, want interface{}, msgs ...interface{}) {
t.Errorf(buf.String(), got, want)
}
}

func TestGetEnvironmentByName(t *testing.T) {
var all = `{"autoIdle":1,"created":"2019-10-29 04:26:11","deleted":"0000-00-00 00:00:00","deployBaseRef":"Master","deployHeadRef":null,"deployTitle":null,"deployType":"branch","environmentType":"production","id":3,"monitoringUrls":null,"name":"Master","openshiftProjectName":"high-cotton-master","route":"http://highcotton.org","routes":"http://highcotton.org,https://varnish-highcotton-org-prod.us.amazee.io,https://nginx-highcotton-org-prod.us.amazee.io","updated":"2019-10-29 04:26:43"}`
var allSuccess = `{"header":["ID","EnvironmentName","EnvironmentType","DeployType","Created","Route","Routes","MonitoringURLS","AutoIdle","DeployTitle","DeployBaseRef","DeployHeadRef"],"data":[["3","Master","production","branch","2019-10-29 04:26:11","http://highcotton.org","http://highcotton.org,https://varnish-highcotton-org-prod.us.amazee.io,https://nginx-highcotton-org-prod.us.amazee.io","-","1","-","Master","-"]]}`

testResult, err := processEnvInfo([]byte(all))
if err != nil {
t.Error("Should not fail if processing succeeded", err)
}
if string(testResult) != allSuccess {
checkEqual(t, string(testResult), allSuccess, "projectInfo processing failed")
}
}

0 comments on commit 3a5b3c6

Please sign in to comment.