Beispiel #1
0
func TestFindQuotaByName(t *testing.T) {
	req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
		Method: "GET",
		Path:   "/v2/quota_definitions?q=name%3Amy-quota",
		Response: testnet.TestResponse{
			Status: http.StatusOK,
			Body: `{"resources": [
				{
				  "metadata": { "guid": "my-quota-guid" },
				  "entity": { "name": "my-remote-quota", "memory_limit": 1024 }
				}
			]}`},
	})

	ts, handler, repo := createQuotaRepo(t, req)
	defer ts.Close()

	quota, apiResponse := repo.FindByName("my-quota")
	assert.True(t, handler.AllRequestsCalled())
	assert.False(t, apiResponse.IsNotSuccessful())
	expectedQuota := cf.QuotaFields{}
	expectedQuota.Guid = "my-quota-guid"
	expectedQuota.Name = "my-remote-quota"
	expectedQuota.MemoryLimit = 1024
	assert.Equal(t, quota, expectedQuota)
}
Beispiel #2
0
func TestListQuotas(t *testing.T) {
	quota := cf.QuotaFields{}
	quota.Name = "quota-name"
	quota.MemoryLimit = 1024

	quotaRepo := &testapi.FakeQuotaRepository{FindAllQuotas: []cf.QuotaFields{quota}}
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
	ui := callListQuotas(t, reqFactory, quotaRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Getting quotas as", "my-user"},
		{"OK"},
		{"name", "memory limit"},
		{"quota-name", "1g"},
	})
}