コード例 #1
0
func TestServicebroker(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config)

	RegisterFailHandler(Fail)
	RunSpecs(t, "Servicebroker Suite")
}
コード例 #2
0
func TestPluginRepo(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config)

	RegisterFailHandler(Fail)
	RunSpecs(t, "PluginRepo Suite")
}
コード例 #3
0
ファイル: main.go プロジェクト: matanzit/cli
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
}
コード例 #4
0
func TestEnvironmentvariablegroup(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config, &detection.JibberJabberDetector{})

	RegisterFailHandler(Fail)
	RunSpecs(t, "Environmentvariablegroup Suite")
}
コード例 #5
0
func TestEnvironmentVariableGroups(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config)

	RegisterFailHandler(Fail)
	RunSpecs(t, "EnvironmentVariableGroups Suite")
}
コード例 #6
0
func TestFeatureflag(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config)

	RegisterFailHandler(Fail)
	RunSpecs(t, "FeatureFlag Suite")
}
コード例 #7
0
func TestCommandFactory(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config)

	RegisterFailHandler(Fail)
	RunSpecs(t, "Command Factory Suite")
}
コード例 #8
0
ファイル: suite_test.go プロジェクト: Reejoshi/cli
func TestSecurityGroupSpaces(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config)

	RegisterFailHandler(Fail)
	RunSpecs(t, "SecurityGroupSpaces Suite")
}
コード例 #9
0
func TestCopyApplicationSource(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config, &detection.JibberJabberDetector{})

	RegisterFailHandler(Fail)
	RunSpecs(t, "CopyApplicationSource Suite")
}
コード例 #10
0
func TestServicekey(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config, &detection.JibberJabberDetector{})

	RegisterFailHandler(Fail)
	RunSpecs(t, "Servicekey Suite")
}
コード例 #11
0
func TestAuthentication(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config)

	RegisterFailHandler(Fail)
	RunSpecs(t, "Authentication Suite")
}
コード例 #12
0
func TestPluginRepo(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config, &detection.JibberJabberDetector{})

	_ = plugin_repo.RepoPlugins{}

	RegisterFailHandler(Fail)
	RunSpecs(t, "PluginRepo Suite")
}
コード例 #13
0
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")
}
コード例 #14
0
func TestCommands(t *testing.T) {
	config := configuration.NewRepositoryWithDefaults()
	i18n.T = i18n.Init(config, &detection.JibberJabberDetector{})

	_ = commands.Api{}

	RegisterFailHandler(Fail)
	RunSpecs(t, "Commands Suite")
}
コード例 #15
0
ファイル: buildpack_suite_test.go プロジェクト: yousk520/cli
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")
}
コード例 #16
0
ファイル: registry.go プロジェクト: vframbach/cli
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
}
コード例 #17
0
ファイル: create_quota.go プロジェクト: palakmathur/cli
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,
	}
}
コード例 #18
0
ファイル: quotas.go プロジェクト: palakmathur/cli
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,
	}
}
コード例 #19
0
ファイル: app_suite_test.go プロジェクト: yousk520/cli
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")
}
コード例 #20
0
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")
}
コード例 #21
0
ファイル: i18n_init.go プロジェクト: GABONIA/cli
func init() {
	T = i18n.Init(filepath.Join("cf", "ui_helpers"), i18n.GetResourcesPath())
}
コード例 #22
0
ファイル: i18n_init.go プロジェクト: jacopen/cli
func init() {
	T = i18n.Init(filepath.Join("cf", "commands", "securitygroup"), i18n.GetResourcesPath())
}
コード例 #23
0
ファイル: http_client.go プロジェクト: GABONIA/cli
	"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,
	}
}
コード例 #24
0
ファイル: i18n_init.go プロジェクト: jacopen/cli
func init() {
	T = i18n.Init("cf/api/authentication", i18n.GetResourcesPath())
}
コード例 #25
0
	)

	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))
			})
		})
	})
コード例 #26
0
ファイル: i18n_init.go プロジェクト: GABONIA/cli
func init() {
	T = i18n.Init("cf/net", i18n.GetResourcesPath())
}
コード例 #27
0
ファイル: ui_test.go プロジェクト: yingkitw/cli
			})
		})

		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())
コード例 #28
0
ファイル: init_unix_test.go プロジェクト: matanzit/cli
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) }
コード例 #29
0
		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) }
コード例 #30
0
ファイル: i18n_init.go プロジェクト: GABONIA/cli
func init() {
	T = i18n.Init("cf/api/strategy", i18n.GetResourcesPath())
}