Exemplo n.º 1
0
func TestReleaseGet(t *testing.T) {
	aws := StubAwsProvider(
		describeStacksCycle,

		release1GetItemCycle,
	)
	defer aws.Close()

	defer func() {
		//TODO: remove: as we arent updating all tests we need to set current provider back to a
		//clean default one (I miss rspec before)
		provider.CurrentProvider = new(provider.TestProviderRunner)
	}()

	r, err := provider.ReleaseGet("httpd", "RVFETUHHKKD")

	assert.Nil(t, err)
	assert.EqualValues(t, &structs.Release{
		Id:       "RVFETUHHKKD",
		App:      "httpd",
		Build:    "BHINCLZYYVN",
		Env:      "foo=bar",
		Manifest: "web:\n  image: httpd\n  ports:\n  - 80:80\n",
		Created:  time.Unix(1459780542, 627770380).UTC(),
	}, r)
}
Exemplo n.º 2
0
func ReleaseGet(rw http.ResponseWriter, req *http.Request) *httperr.Error {
	vars := mux.Vars(req)
	app := vars["app"]
	release := vars["release"]

	r, err := provider.ReleaseGet(app, release)
	if awsError(err) == "ValidationError" {
		return httperr.Errorf(404, "no such app: %s", app)
	}
	if err != nil && strings.HasPrefix(err.Error(), "no such release") {
		return httperr.Errorf(404, err.Error())
	}
	if err != nil {
		return httperr.Server(err)
	}

	return RenderJson(rw, r)
}