Exemplo n.º 1
0
func TestParserEmail(t *testing.T) {
	t.Parallel()

	h := parsecli.NewTokenHarness(t)
	h.MakeEmptyRoot()
	defer h.Stop()

	ensure.Nil(t, parsecli.CreateConfigWithContent(filepath.Join(h.Env.Root, parsecli.ParseLocal), "{}"))
	ensure.Nil(t,
		parsecli.CreateConfigWithContent(
			filepath.Join(h.Env.Root, parsecli.ParseProject),
			`{"project_type": 1}`,
		),
	)

	var c configureCmd
	ensure.Nil(t, c.parserEmail(h.Env, []string{"email2"}))
	ensure.DeepEqual(
		t,
		h.Out.String(),
		`Successfully configured email for current project to: "email2"
`,
	)

	ensure.Err(t, c.parserEmail(h.Env, nil), regexp.MustCompile("Invalid args:"))
	ensure.Err(t, c.parserEmail(h.Env, []string{"a", "b"}), regexp.MustCompile("Invalid args:"))
}
Exemplo n.º 2
0
func writeHerokuConfigs(e *parsecli.Env) error {
	err := parsecli.CreateConfigWithContent(
		filepath.Join(e.Root, parsecli.ParseProject),
		fmt.Sprintf(
			`{"project_type": %d}`,
			parsecli.HerokuFormat,
		),
	)
	if err != nil {
		return err
	}
	return parsecli.CreateConfigWithContent(
		filepath.Join(e.Root, parsecli.ParseLocal),
		"{}",
	)
}