Exemplo n.º 1
0
func (s *OptionsSuite) TestEmptyPipelineOptionsEmptyDir() {
	tmpDir, err := ioutil.TempDir("", "empty-directory")
	s.Nil(err)
	defer os.RemoveAll(tmpDir)

	basename := filepath.Base(tmpDir)
	currentUser, err := user.Current()
	s.Nil(err)
	username := currentUser.Username

	// Target the path
	args := defaultArgs(tmpDir)
	test := func(c *cli.Context) {
		opts, err := core.NewPipelineOptions(util.NewCLISettings(c), emptyEnv())
		s.Nil(err)
		s.Equal(basename, opts.ApplicationID)
		s.Equal(basename, opts.ApplicationName)
		s.Equal(username, opts.ApplicationOwnerName)
		s.Equal(username, opts.ApplicationStartedByName)
		s.Equal(tmpDir, opts.ProjectPath)
		s.Equal(basename, opts.ProjectID)
		// Pretty much all the git stuff should be empty
		s.Equal("", opts.GitBranch)
		s.Equal("", opts.GitCommit)
		s.Equal("", opts.GitDomain)
		s.Equal(username, opts.GitOwner)
		s.Equal("", opts.GitRepository)
		cmd.DumpOptions(opts)
	}
	run(s, globalFlags, pipelineFlags, test, args)
}
Exemplo n.º 2
0
func (s *OptionsSuite) TestTagEscaping() {
	args := defaultArgs("--tag", "feature/foo")
	test := func(c *cli.Context) {
		opts, err := core.NewPipelineOptions(util.NewCLISettings(c), emptyEnv())
		s.Nil(err)
		s.Equal("feature_foo", opts.Tag)
	}
	run(s, globalFlags, pipelineFlags, test, args)
}
Exemplo n.º 3
0
func (s *OptionsSuite) TestWorkingDirCWD() {
	args := defaultArgs()
	cwd, err := filepath.Abs(".")
	s.Nil(err)

	test := func(c *cli.Context) {
		opts, err := core.NewPipelineOptions(util.NewCLISettings(c), emptyEnv())
		s.Nil(err)
		s.Equal(filepath.Join(cwd, ".wercker"), opts.WorkingDir)
	}

	run(s, globalFlags, pipelineFlags, test, args)
}
Exemplo n.º 4
0
func (s *OptionsSuite) TestWorkingDir() {
	tempDir, err := ioutil.TempDir("", "wercker-test-")
	s.Nil(err)
	defer os.RemoveAll(tempDir)

	args := defaultArgs("--working-dir", tempDir)

	test := func(c *cli.Context) {
		opts, err := core.NewPipelineOptions(util.NewCLISettings(c), emptyEnv())
		s.Nil(err)
		s.Equal(tempDir, opts.WorkingDir)
	}

	run(s, globalFlags, pipelineFlags, test, args)
}
Exemplo n.º 5
0
func (s *OptionsSuite) TestWorkingDirGetsSet() {
	tempDir, err := ioutil.TempDir("", "wercker-test-")
	s.Nil(err)
	defer os.RemoveAll(tempDir)

	// This ignores the _build part, we're only concerned about the working dir
	args := defaultArgs("--build-dir", filepath.Join(tempDir, "_build"))

	test := func(c *cli.Context) {
		opts, err := core.NewPipelineOptions(util.NewCLISettings(c), emptyEnv())
		s.Nil(err)
		s.Equal(tempDir, opts.WorkingDir)
	}

	run(s, globalFlags, pipelineFlags, test, args)
}