本文整理匯總了Golang中github.com/nttlabs/cli/testhelpers/terminal.FakeUI類的典型用法代碼示例。如果您正苦於以下問題:Golang FakeUI類的具體用法?Golang FakeUI怎麽用?Golang FakeUI使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FakeUI類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
. "github.com/nttlabs/cli/cf/commands/servicebroker"
"github.com/nttlabs/cli/cf/configuration/core_config"
"github.com/nttlabs/cli/cf/models"
testcmd "github.com/nttlabs/cli/testhelpers/commands"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
. "github.com/nttlabs/cli/testhelpers/matchers"
testreq "github.com/nttlabs/cli/testhelpers/requirements"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("delete-service-broker command", func() {
var (
ui *testterm.FakeUI
configRepo core_config.ReadWriter
brokerRepo *testapi.FakeServiceBrokerRepo
requirementsFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
ui = &testterm.FakeUI{Inputs: []string{"y"}}
brokerRepo = &testapi.FakeServiceBrokerRepo{}
configRepo = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
})
runCommand := func(args ...string) {
cmd := NewDeleteServiceBroker(ui, configRepo, brokerRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
}
示例2:
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
"github.com/nttlabs/cli/testhelpers/maker"
testreq "github.com/nttlabs/cli/testhelpers/requirements"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/nttlabs/cli/testhelpers/matchers"
)
var _ = Describe("scale command", func() {
var (
requirementsFactory *testreq.FakeReqFactory
restarter *testcmd.FakeApplicationRestarter
appRepo *testApplication.FakeApplicationRepository
ui *testterm.FakeUI
config core_config.ReadWriter
cmd *Scale
app models.Application
)
BeforeEach(func() {
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
restarter = &testcmd.FakeApplicationRestarter{}
appRepo = &testApplication.FakeApplicationRepository{}
ui = new(testterm.FakeUI)
config = testconfig.NewRepositoryWithDefaults()
cmd = NewScale(ui, config, restarter, appRepo)
})
Describe("requirements", func() {
示例3:
testcmd "github.com/nttlabs/cli/testhelpers/commands"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
"github.com/nttlabs/cli/testhelpers/maker"
testreq "github.com/nttlabs/cli/testhelpers/requirements"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/nttlabs/cli/testhelpers/matchers"
)
var _ = Describe("delete-space command", func() {
var (
ui *testterm.FakeUI
space models.Space
config core_config.ReadWriter
spaceRepo *testapi.FakeSpaceRepository
requirementsFactory *testreq.FakeReqFactory
)
runCommand := func(args ...string) {
cmd := NewDeleteSpace(ui, config, spaceRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
return
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
spaceRepo = &testapi.FakeSpaceRepository{}
config = testconfig.NewRepositoryWithDefaults()
示例4:
"github.com/nttlabs/cli/cf/errors"
testcmd "github.com/nttlabs/cli/testhelpers/commands"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testreq "github.com/nttlabs/cli/testhelpers/requirements"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/nttlabs/cli/testhelpers/matchers"
)
var _ = Describe("migrating service instances from v1 to v2", func() {
var (
ui *testterm.FakeUI
serviceRepo *testapi.FakeServiceRepo
cmd *MigrateServiceInstances
requirementsFactory *testreq.FakeReqFactory
args []string
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
config := testconfig.NewRepository()
serviceRepo = &testapi.FakeServiceRepo{}
cmd = NewMigrateServiceInstances(ui, config, serviceRepo)
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: false}
args = []string{}
})
Describe("requirements", func() {
It("requires you to be logged in", func() {
示例5:
"github.com/nttlabs/cli/cf/models"
testcmd "github.com/nttlabs/cli/testhelpers/commands"
"github.com/nttlabs/cli/testhelpers/configuration"
testreq "github.com/nttlabs/cli/testhelpers/requirements"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/nttlabs/cli/cf/commands/spacequota"
. "github.com/nttlabs/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("delete-quota command", func() {
var (
ui *testterm.FakeUI
quotaRepo *fakes.FakeSpaceQuotaRepository
orgRepo *test_org.FakeOrganizationRepository
requirementsFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
quotaRepo = &fakes.FakeSpaceQuotaRepository{}
orgRepo = &test_org.FakeOrganizationRepository{}
requirementsFactory = &testreq.FakeReqFactory{}
org := models.Organization{}
org.Name = "my-org"
org.Guid = "my-org-guid"
orgRepo.ListOrgsReturns([]models.Organization{org}, nil)
orgRepo.FindByNameReturns(org, nil)
})
示例6:
"github.com/nttlabs/cli/cf/models"
testcmd "github.com/nttlabs/cli/testhelpers/commands"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testreq "github.com/nttlabs/cli/testhelpers/requirements"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/nttlabs/cli/testhelpers/matchers"
)
var _ = Describe("delete-domain command", func() {
var (
cmd *DeleteDomain
ui *testterm.FakeUI
configRepo core_config.ReadWriter
domainRepo *testapi.FakeDomainRepository
requirementsFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
ui = &testterm.FakeUI{
Inputs: []string{"yes"},
}
domainRepo = &testapi.FakeDomainRepository{}
requirementsFactory = &testreq.FakeReqFactory{
LoginSuccess: true,
TargetedOrgSuccess: true,
}
configRepo = testconfig.NewRepositoryWithDefaults()
示例7:
"github.com/nttlabs/cli/cf/configuration/core_config"
"github.com/nttlabs/cli/cf/models"
testcmd "github.com/nttlabs/cli/testhelpers/commands"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testreq "github.com/nttlabs/cli/testhelpers/requirements"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/nttlabs/cli/testhelpers/matchers"
)
var _ = Describe("delete-user command", func() {
var (
ui *testterm.FakeUI
configRepo core_config.ReadWriter
userRepo *testapi.FakeUserRepository
requirementsFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
ui = &testterm.FakeUI{Inputs: []string{"y"}}
userRepo = &testapi.FakeUserRepository{}
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
configRepo = testconfig.NewRepositoryWithDefaults()
token, err := testconfig.EncodeAccessToken(core_config.TokenInfo{
UserGuid: "admin-user-guid",
Username: "admin-user",
})
Expect(err).ToNot(HaveOccurred())
configRepo.SetAccessToken(token)
示例8:
testcmd "github.com/nttlabs/cli/testhelpers/commands"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/nttlabs/cli/testhelpers/matchers"
)
var _ = Describe("Login Command", func() {
var (
Flags []string
Config core_config.ReadWriter
ui *testterm.FakeUI
authRepo *testapi.FakeAuthenticationRepository
endpointRepo *testapi.FakeEndpointRepo
orgRepo *fake_organizations.FakeOrganizationRepository
spaceRepo *testapi.FakeSpaceRepository
org models.Organization
)
BeforeEach(func() {
Flags = []string{}
Config = testconfig.NewRepository()
ui = &testterm.FakeUI{}
authRepo = &testapi.FakeAuthenticationRepository{
AccessToken: "my_access_token",
RefreshToken: "my_refresh_token",
Config: Config,
}
示例9:
"github.com/nttlabs/cli/cf/configuration/core_config"
testcmd "github.com/nttlabs/cli/testhelpers/commands"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testreq "github.com/nttlabs/cli/testhelpers/requirements"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/nttlabs/cli/testhelpers/matchers"
)
var _ = Describe("create-user-provided-service command", func() {
var (
ui *testterm.FakeUI
config core_config.ReadWriter
repo *testapi.FakeUserProvidedServiceInstanceRepo
requirementsFactory *testreq.FakeReqFactory
cmd CreateUserProvidedService
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
config = testconfig.NewRepositoryWithDefaults()
repo = &testapi.FakeUserProvidedServiceInstanceRepo{}
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
cmd = NewCreateUserProvidedService(ui, config, repo)
})
Describe("login requirements", func() {
It("fails if the user is not logged in", func() {
requirementsFactory.LoginSuccess = false
示例10:
package terminal_test
import (
. "github.com/nttlabs/cli/cf/terminal"
. "github.com/nttlabs/cli/testhelpers/matchers"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Table", func() {
var (
ui *testterm.FakeUI
table Table
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
table = NewTable(ui, []string{"watashi", "no", "atama!"})
})
It("prints the header", func() {
table.Print()
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"watashi", "no", "atama!"},
))
})
It("prints format string literals as strings", func() {
table.Add("cloak %s", "and", "dagger")
table.Print()