Ejemplo n.º 1
0
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)
}
Ejemplo n.º 2
0
func createEndpointSliceFlag() cli.StringSliceFlag {
	epSlice := new(cli.StringSlice)
	epSlice.Set("http://localhost:8081")

	endpointFlag := cli.StringSliceFlag{
		Name:  "endpoint, ep",
		Value: epSlice,
	}
	return endpointFlag
}
Ejemplo n.º 3
0
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")
}
Ejemplo n.º 4
0
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")
}