本文整理匯總了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"},
})
}
示例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"},
})
}
示例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"},
})
}
示例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)
}
示例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)
}
示例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)
}
示例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())
}