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


Golang cli.StringSliceFlag類代碼示例

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


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

示例1: TestStringSliceFlagHelpOutput

func TestStringSliceFlagHelpOutput(t *testing.T) {

	for _, test := range stringSliceFlagTests {
		flag := cli.StringSliceFlag{Name: test.name, Value: test.value}
		output := flag.String()

		if output != test.expected {
			t.Errorf("%q does not match %q", output, test.expected)
		}
	}
}
開發者ID:mitsuse,項目名稱:tasklog,代碼行數:11,代碼來源:flag_test.go

示例2: TestStringSliceFlagWithEnvVarHelpOutput

func TestStringSliceFlagWithEnvVarHelpOutput(t *testing.T) {

	os.Setenv("APP_QWWX", "11,4")
	for _, test := range stringSliceFlagTests {
		flag := cli.StringSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_QWWX"}
		output := flag.String()

		if !strings.HasSuffix(output, " [$APP_QWWX]") {
			t.Errorf("%q does not end with [$APP_QWWX]", output)
		}
	}
}
開發者ID:mitsuse,項目名稱:tasklog,代碼行數:12,代碼來源:flag_test.go

示例3: TestDeployBefore

func TestDeployBefore(t *testing.T) {
	set := createFlagSetWithMandatoryFlags()
	set.String("memory", "512", "")
	envSlice := new(cli.StringSlice)
	envSlice.Set("deploy.go")

	envFlag := cli.StringSliceFlag{
		Name:  "env-file",
		Value: envSlice,
	}
	envFlag.Apply(set)
	ctx := cli.NewContext(nil, set, nil)
	err := deployBefore(ctx)
	assert.Nil(t, err, "Should pass without any error")
}
開發者ID:ch3lo,項目名稱:crane,代碼行數:15,代碼來源:deploy_test.go

示例4: TestDeployCmd

func TestDeployCmd(t *testing.T) {
	stackManager = createStackManagerMock()
	set := createFlagSetWithMandatoryFlags()
	set.String("memory", "512", "")
	envFileSlice := new(cli.StringSlice)
	envFileSlice.Set("deploy.go")

	envFileFlag := cli.StringSliceFlag{
		Name:  "env-file",
		Value: envFileSlice,
	}
	envFileFlag.Apply(set)
	envSlice := new(cli.StringSlice)
	envSlice.Set("SOME_ENV_VAR")

	envFlag := cli.StringSliceFlag{
		Name:  "env",
		Value: envSlice,
	}
	envFlag.Apply(set)

	endpointFlag := createEndpointSliceFlag()
	endpointFlag.Apply(set)
	ctx := cli.NewContext(nil, set, nil)

	deployCmd(ctx)
}
開發者ID:ch3lo,項目名稱:crane,代碼行數:27,代碼來源:deploy_test.go

示例5: TestDeployBeforeError

func TestDeployBeforeError(t *testing.T) {
	set := flag.NewFlagSet("test", 0)
	ctx := cli.NewContext(nil, set, nil)
	err := deployBefore(ctx)
	assert.NotNil(t, err, "Should throw error service-id empty")

	set.String("service-id", "MyServiceId", "")
	ctx = cli.NewContext(nil, set, nil)
	err = deployBefore(ctx)
	assert.NotNil(t, err, "Should throw error image empty")

	set.String("image", "someImage", "")
	ctx = cli.NewContext(nil, set, nil)
	err = deployBefore(ctx)
	assert.NotNil(t, err, "Should throw error tag empty")

	set.String("tag", "someTag", "")
	set.String("memory", "some memory", "")
	ctx = cli.NewContext(nil, set, nil)
	err = deployBefore(ctx)
	assert.NotNil(t, err, "Should throw error memory empty")

	set = createFlagSetWithMandatoryFlags()
	set.String("memory", "512", "")
	envSlice := new(cli.StringSlice)
	envSlice.Set("/tmp/bla.txt")

	envFlag := cli.StringSliceFlag{
		Name:  "env-file",
		Value: envSlice,
	}
	envFlag.Apply(set)
	ctx = cli.NewContext(nil, set, nil)
	err = deployBefore(ctx)
	assert.NotNil(t, err, "Should throw error file does not exist")
}
開發者ID:ch3lo,項目名稱:crane,代碼行數:36,代碼來源:deploy_test.go


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