當前位置: 首頁>>代碼示例>>Golang>>正文


Golang cf.Buildpack類代碼示例

本文整理匯總了Golang中cf.Buildpack的典型用法代碼示例。如果您正苦於以下問題:Golang Buildpack類的具體用法?Golang Buildpack怎麽用?Golang Buildpack使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Buildpack類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestDeleteBuildpackThatDoesNotExist

func TestDeleteBuildpackThatDoesNotExist(t *testing.T) {
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
	buildpack := cf.Buildpack{}
	buildpack.Name = "my-buildpack"
	buildpack.Guid = "my-buildpack-guid"
	buildpackRepo := &testapi.FakeBuildpackRepository{
		FindByNameNotFound:  true,
		FindByNameBuildpack: buildpack,
	}

	ui := &testterm.FakeUI{}
	ctxt := testcmd.NewContext("delete-buildpack", []string{"-f", "my-buildpack"})

	cmd := NewDeleteBuildpack(ui, buildpackRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)

	assert.Equal(t, buildpackRepo.FindByNameName, "my-buildpack")
	assert.True(t, buildpackRepo.FindByNameNotFound)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting", "my-buildpack"},
		{"OK"},
		{"my-buildpack", "does not exist"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:25,代碼來源:delete_buildpack_test.go

示例2: TestDeleteBuildpackSuccess

func TestDeleteBuildpackSuccess(t *testing.T) {
	ui := &testterm.FakeUI{Inputs: []string{"y"}}
	buildpack := cf.Buildpack{}
	buildpack.Name = "my-buildpack"
	buildpack.Guid = "my-buildpack-guid"
	buildpackRepo := &testapi.FakeBuildpackRepository{
		FindByNameBuildpack: buildpack,
	}
	cmd := NewDeleteBuildpack(ui, buildpackRepo)

	ctxt := testcmd.NewContext("delete-buildpack", []string{"my-buildpack"})
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}

	testcmd.RunCommand(cmd, ctxt, reqFactory)

	assert.Equal(t, buildpackRepo.DeleteBuildpackGuid, "my-buildpack-guid")

	testassert.SliceContains(t, ui.Prompts, testassert.Lines{
		{"delete", "my-buildpack"},
	})
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting buildpack", "my-buildpack"},
		{"OK"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:25,代碼來源:delete_buildpack_test.go

示例3: TestDeleteBuildpackDeleteError

func TestDeleteBuildpackDeleteError(t *testing.T) {
	ui := &testterm.FakeUI{Inputs: []string{"y"}}
	buildpack := cf.Buildpack{}
	buildpack.Name = "my-buildpack"
	buildpack.Guid = "my-buildpack-guid"
	buildpackRepo := &testapi.FakeBuildpackRepository{
		FindByNameBuildpack: buildpack,
		DeleteApiResponse:   net.NewApiResponseWithMessage("failed badly"),
	}

	cmd := NewDeleteBuildpack(ui, buildpackRepo)

	ctxt := testcmd.NewContext("delete-buildpack", []string{"my-buildpack"})
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}

	testcmd.RunCommand(cmd, ctxt, reqFactory)

	assert.Equal(t, buildpackRepo.DeleteBuildpackGuid, "my-buildpack-guid")

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting buildpack", "my-buildpack"},
		{"FAILED"},
		{"my-buildpack"},
		{"failed badly"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:26,代碼來源:delete_buildpack_test.go

示例4: TestBuildpackReqExecute

func TestBuildpackReqExecute(t *testing.T) {
	buildpack := cf.Buildpack{}
	buildpack.Name = "my-buildpack"
	buildpack.Guid = "my-buildpack-guid"
	buildpackRepo := &testapi.FakeBuildpackRepository{FindByNameBuildpack: buildpack}
	ui := new(testterm.FakeUI)

	buildpackReq := newBuildpackRequirement("foo", ui, buildpackRepo)
	success := buildpackReq.Execute()

	assert.True(t, success)
	assert.Equal(t, buildpackRepo.FindByNameName, "foo")
	assert.Equal(t, buildpackReq.GetBuildpack(), buildpack)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:14,代碼來源:buildpack_test.go

示例5: TestBuildpacksFindByName

func TestBuildpacksFindByName(t *testing.T) {
	req := testapi.NewCloudControllerTestRequest(findBuildpackRequest)

	ts, handler, repo := createBuildpackRepo(t, req)
	defer ts.Close()
	existingBuildpack := cf.Buildpack{}
	existingBuildpack.Guid = "buildpack1-guid"
	existingBuildpack.Name = "Buildpack1"

	buildpack, apiResponse := repo.FindByName("Buildpack1")

	assert.True(t, handler.AllRequestsCalled())
	assert.True(t, apiResponse.IsSuccessful())

	assert.Equal(t, buildpack.Name, existingBuildpack.Name)
	assert.Equal(t, buildpack.Guid, existingBuildpack.Guid)
	assert.Equal(t, *buildpack.Position, 10)
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:18,代碼來源:buildpacks_test.go

示例6: TestUpdateBuildpack

func TestUpdateBuildpack(t *testing.T) {
	req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
		Method:  "PUT",
		Path:    "/v2/buildpacks/my-cool-buildpack-guid",
		Matcher: testnet.RequestBodyMatcher(`{"name":"my-cool-buildpack","position":555,"enabled":false}`),
		Response: testnet.TestResponse{
			Status: http.StatusCreated,
			Body: `{
				    "metadata": {
				        "guid": "my-cool-buildpack-guid"
				    },
				    "entity": {
				        "name": "my-cool-buildpack",
						"position":555,
						"enabled":false
				    }
				}`},
	})

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

	position := 555
	enabled := false
	buildpack := cf.Buildpack{}
	buildpack.Name = "my-cool-buildpack"
	buildpack.Guid = "my-cool-buildpack-guid"
	buildpack.Position = &position
	buildpack.Enabled = &enabled
	updated, apiResponse := repo.Update(buildpack)

	assert.True(t, handler.AllRequestsCalled())
	assert.False(t, apiResponse.IsNotSuccessful())

	assert.Equal(t, buildpack, updated)
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:36,代碼來源:buildpacks_test.go

示例7: TestBuildpacksListBuildpacks

func TestBuildpacksListBuildpacks(t *testing.T) {
	firstRequest := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
		Method: "GET",
		Path:   "/v2/buildpacks",
		Response: testnet.TestResponse{
			Status: http.StatusOK,
			Body: `{
			  "next_url": "/v2/buildpacks?page=2",
			  "resources": [
			    {
			      "metadata": {
			        "guid": "buildpack1-guid"
			      },
			      "entity": {
			        "name": "Buildpack1",
					"position" : 1
			      }
			    }
			  ]
			}`},
	})

	secondRequest := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
		Method: "GET",
		Path:   "/v2/buildpacks?page=2",
		Response: testnet.TestResponse{
			Status: http.StatusOK,
			Body: `{
			  "resources": [
			    {
			      "metadata": {
			        "guid": "buildpack2-guid"
			      },
			      "entity": {
			        "name": "Buildpack2",
					"position" : 2
			      }
			    }
			  ]
			}`},
	})

	ts, handler, repo := createBuildpackRepo(t, firstRequest, secondRequest)
	defer ts.Close()

	stopChan := make(chan bool)
	defer close(stopChan)
	buildpacksChan, statusChan := repo.ListBuildpacks(stopChan)

	one := 1
	buildpack := cf.Buildpack{}
	buildpack.Guid = "buildpack1-guid"
	buildpack.Name = "Buildpack1"
	buildpack.Position = &one

	two := 2
	buildpack2 := cf.Buildpack{}
	buildpack2.Guid = "buildpack2-guid"
	buildpack2.Name = "Buildpack2"
	buildpack2.Position = &two

	expectedBuildpacks := []cf.Buildpack{buildpack, buildpack2}

	buildpacks := []cf.Buildpack{}
	for chunk := range buildpacksChan {
		buildpacks = append(buildpacks, chunk...)
	}
	apiResponse := <-statusChan

	assert.Equal(t, buildpacks, expectedBuildpacks)
	assert.True(t, handler.AllRequestsCalled())
	assert.True(t, apiResponse.IsSuccessful())
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:73,代碼來源:buildpacks_test.go


注:本文中的cf.Buildpack類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。