func TestServicebroker(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config) RegisterFailHandler(Fail) RunSpecs(t, "Servicebroker Suite") }
func TestPluginRepo(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config) RegisterFailHandler(Fail) RunSpecs(t, "PluginRepo Suite") }
func setupDependencies() (deps *cliDependencies) { deps = new(cliDependencies) deps.termUI = terminal.NewUI(os.Stdin) deps.manifestRepo = manifest.NewManifestDiskRepository() deps.configRepo = configuration.NewRepositoryFromFilepath(configuration.DefaultFilePath(), func(err error) { if err != nil { deps.termUI.Failed(fmt.Sprintf("Config error: %s", err)) } }) i18n.T = i18n.Init(deps.configRepo) terminal.UserAskedForColors = deps.configRepo.ColorEnabled() terminal.InitColorSupport() if os.Getenv("CF_TRACE") != "" { trace.Logger = trace.NewLogger(os.Getenv("CF_TRACE")) } else { trace.Logger = trace.NewLogger(deps.configRepo.Trace()) } deps.gateways = map[string]net.Gateway{ "auth": net.NewUAAGateway(deps.configRepo), "cloud-controller": net.NewCloudControllerGateway(deps.configRepo, time.Now), "uaa": net.NewUAAGateway(deps.configRepo), } deps.apiRepoLocator = api.NewRepositoryLocator(deps.configRepo, deps.gateways) return }
func TestEnvironmentvariablegroup(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config, &detection.JibberJabberDetector{}) RegisterFailHandler(Fail) RunSpecs(t, "Environmentvariablegroup Suite") }
func TestEnvironmentVariableGroups(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config) RegisterFailHandler(Fail) RunSpecs(t, "EnvironmentVariableGroups Suite") }
func TestFeatureflag(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config) RegisterFailHandler(Fail) RunSpecs(t, "FeatureFlag Suite") }
func TestCommandFactory(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config) RegisterFailHandler(Fail) RunSpecs(t, "Command Factory Suite") }
func TestSecurityGroupSpaces(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config) RegisterFailHandler(Fail) RunSpecs(t, "SecurityGroupSpaces Suite") }
func TestCopyApplicationSource(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config, &detection.JibberJabberDetector{}) RegisterFailHandler(Fail) RunSpecs(t, "CopyApplicationSource Suite") }
func TestServicekey(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config, &detection.JibberJabberDetector{}) RegisterFailHandler(Fail) RunSpecs(t, "Servicekey Suite") }
func TestAuthentication(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config) RegisterFailHandler(Fail) RunSpecs(t, "Authentication Suite") }
func TestPluginRepo(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config, &detection.JibberJabberDetector{}) _ = plugin_repo.RepoPlugins{} RegisterFailHandler(Fail) RunSpecs(t, "PluginRepo Suite") }
func TestApp(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config, &detection.JibberJabberDetector{}) RegisterFailHandler(Fail) plugin_builder.BuildTestBinary(filepath.Join("..", "..", "fixtures", "plugins"), "test_1") plugin_builder.BuildTestBinary(filepath.Join("..", "..", "fixtures", "plugins"), "test_2") RunSpecs(t, "App Suite") }
func TestCommands(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config, &detection.JibberJabberDetector{}) _ = commands.Api{} RegisterFailHandler(Fail) RunSpecs(t, "Commands Suite") }
func TestBuildpack(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config, &detection.JibberJabberDetector{}) //make a reference to something in cf/commands/domain, so all init() in the directory will run _ = buildpack.ListBuildpacks{} RegisterFailHandler(Fail) RunSpecs(t, "Buildpack Suite") }
func initI18nFunc() bool { errorHandler := func(err error) { if err != nil { fmt.Println(FailureColor("FAILED")) fmt.Println("Error read/writing config: ", err.Error()) os.Exit(1) } } i18n.T = i18n.Init(core_config.NewRepositoryFromFilepath(config_helpers.DefaultFilePath(), errorHandler)) return true }
func NewCreateQuota(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) CreateQuota { t, err := i18n.Init("quota", i18n.GetResourcesPath()) if err != nil { ui.Failed(err.Error()) } return CreateQuota{ ui: ui, config: config, quotaRepo: quotaRepo, T: t, } }
func NewListQuotas(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) (cmd *ListQuotas) { t, err := i18n.Init("quota", i18n.GetResourcesPath()) if err != nil { ui.Failed(err.Error()) } return &ListQuotas{ ui: ui, config: config, quotaRepo: quotaRepo, T: t, } }
func TestApp(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config, &detection.JibberJabberDetector{}) //make a reference to something in cf/commands/domain, so all init() in the directory will run _ = domain.CreateDomain{} _ = buildpack.ListBuildpacks{} _ = organization.ListOrgs{} RegisterFailHandler(Fail) plugin_builder.BuildTestBinary(filepath.Join("..", "..", "fixtures", "plugins"), "test_1") plugin_builder.BuildTestBinary(filepath.Join("..", "..", "fixtures", "plugins"), "test_2") RunSpecs(t, "App Suite") }
func TestPlugin(t *testing.T) { config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config, &detection.JibberJabberDetector{}) RegisterFailHandler(Fail) plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_help") plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_push") plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_push_short_name") plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_1") plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_2") plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "empty_plugin") plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "alias_conflicts") RunSpecs(t, "Plugin Suite") }
func init() { T = i18n.Init(filepath.Join("cf", "ui_helpers"), i18n.GetResourcesPath()) }
func init() { T = i18n.Init(filepath.Join("cf", "commands", "securitygroup"), i18n.GetResourcesPath()) }
"github.com/cloudfoundry/cli/cf/errors" "github.com/cloudfoundry/cli/cf/terminal" "github.com/cloudfoundry/cli/cf/trace" "net" "net/http" "net/http/httputil" "net/url" "regexp" "strings" "time" "github.com/cloudfoundry/cli/cf/i18n" ) var ( t = i18n.Init("cf/net", i18n.GetResourcesPath()) PRIVATE_DATA_PLACEHOLDER = t("[PRIVATE DATA HIDDEN]") ) func newHttpClient(trustedCerts []tls.Certificate, disableSSL bool) *http.Client { tr := &http.Transport{ TLSClientConfig: NewTLSConfig(trustedCerts, disableSSL), Proxy: http.ProxyFromEnvironment, } return &http.Client{ Transport: tr, CheckRedirect: PrepareRedirect, } }
func init() { T = i18n.Init("cf/api/authentication", i18n.GetResourcesPath()) }
) BeforeEach(func() { i18n.Resources_path = filepath.Join("cf", "i18n", "test_fixtures") configRepo = testconfig.NewRepositoryWithDefaults() detector = &fakes.FakeDetector{} }) Describe("When a user has a locale configuration set", func() { Context("creates a valid T function", func() { BeforeEach(func() { configRepo.SetLocale("en_US") }) It("returns a usable T function for simple strings", func() { T := i18n.Init(configRepo, detector) Ω(T).ShouldNot(BeNil()) translation := T("Hello world!") Ω("Hello world!").Should(Equal(translation)) }) It("returns a usable T function for complex strings (interpolated)", func() { T := i18n.Init(configRepo, detector) Ω(T).ShouldNot(BeNil()) translation := T("Deleting domain {{.DomainName}} as {{.Username}}...", map[string]interface{}{"DomainName": "foo.com", "Username": "******"}) Ω("Deleting domain foo.com as Anand...").Should(Equal(translation)) }) }) })
func init() { T = i18n.Init("cf/net", i18n.GetResourcesPath()) }
}) }) It("treats 'yes' as an affirmative confirmation when default language is not en_US", func() { oldLang := os.Getenv("LC_ALL") defer os.Setenv("LC_ALL", oldLang) oldT := i18n.T defer func() { i18n.T = oldT }() os.Setenv("LC_ALL", "fr_FR") config := configuration.NewRepositoryWithDefaults() i18n.T = i18n.Init(config) io_helpers.SimulateStdin("yes\n", func(reader io.Reader) { out := io_helpers.CaptureOutput(func() { ui := NewUI(reader, os.Stdout, NewTeePrinter(os.Stdout), fakeLogger) Expect(ui.Confirm("Hello World?")).To(BeTrue()) }) Expect(out).To(ContainSubstrings([]string{"Hello World?"})) }) }) It("treats 'yes' as an affirmative confirmation", func() { io_helpers.SimulateStdin("yes\n", func(reader io.Reader) { out := io_helpers.CaptureOutput(func() { ui := NewUI(reader, os.Stdout, NewTeePrinter(os.Stdout), fakeLogger) Expect(ui.Confirm("Hello World?")).To(BeTrue())
var _ = Describe("i18n.Init() function", func() { var ( oldResourcesPath string configRepo configuration.ReadWriter T go_i18n.TranslateFunc ) BeforeEach(func() { configRepo = testconfig.NewRepositoryWithDefaults() oldResourcesPath = i18n.GetResourcesPath() i18n.Resources_path = filepath.Join("cf", "i18n", "test_fixtures") }) JustBeforeEach(func() { T = i18n.Init(configRepo) }) Describe("When a user has a locale configuration set", func() { It("panics when the translation files cannot be loaded", func() { i18n.Resources_path = filepath.Join("should", "not", "be_valid") configRepo.SetLocale("en_us") init := func() { i18n.Init(configRepo) } Ω(init).Should(Panic(), "loading translations from an invalid path should panic") }) It("Panics if the locale is not valid", func() { configRepo.SetLocale("abc_def") init := func() { i18n.Init(configRepo) }
oldResourcesPath string configRepo core_config.ReadWriter detector detection.Detector T go_i18n.TranslateFunc ) BeforeEach(func() { configRepo = testconfig.NewRepositoryWithDefaults() oldResourcesPath = i18n.GetResourcesPath() i18n.Resources_path = filepath.Join("cf", "i18n", "test_fixtures") detector = &detection.JibberJabberDetector{} }) JustBeforeEach(func() { T = i18n.Init(configRepo, detector) }) Describe("When a user has a locale configuration set", func() { It("panics when the translation files cannot be loaded", func() { i18n.Resources_path = filepath.Join("should", "not", "be_valid") configRepo.SetLocale("en_us") init := func() { i18n.Init(configRepo, detector) } Ω(init).Should(Panic(), "loading translations from an invalid path should panic") }) It("Panics if the locale is not valid", func() { configRepo.SetLocale("abc_def") init := func() { i18n.Init(configRepo, detector) }
func init() { T = i18n.Init("cf/api/strategy", i18n.GetResourcesPath()) }