diff --git a/lagoon/environments/main_test.go b/lagoon/environments/main_test.go index 157db303..fa4608e2 100644 --- a/lagoon/environments/main_test.go +++ b/lagoon/environments/main_test.go @@ -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") + } +}