From 99838a52fe172a69fcd6d6ed6e54f9b1b36962c8 Mon Sep 17 00:00:00 2001 From: Albert Nigmatzianov Date: Sun, 30 Jul 2017 17:14:01 +0200 Subject: [PATCH] cmd: Small fixes --- cobra/cmd/add_test.go | 4 ++-- cobra/cmd/init_test.go | 4 ++-- cobra/cmd/licenses.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cobra/cmd/add_test.go b/cobra/cmd/add_test.go index 1aa5f53..8cda321 100644 --- a/cobra/cmd/add_test.go +++ b/cobra/cmd/add_test.go @@ -22,9 +22,9 @@ func TestGoldenAddCmd(t *testing.T) { // Initialize the project at first. initializeProject(project) defer os.RemoveAll(project.AbsPath()) - defer viper.Set("year", nil) - viper.Set("year", 2017) // For reproducible builds + viper.Set("year", 2017) // For reproducible builds. + defer viper.Set("year", nil) // Then add the "test" command. cmdName := "test" diff --git a/cobra/cmd/init_test.go b/cobra/cmd/init_test.go index 1ba9a54..115f5d2 100644 --- a/cobra/cmd/init_test.go +++ b/cobra/cmd/init_test.go @@ -18,9 +18,9 @@ func TestGoldenInitCmd(t *testing.T) { projectName := "github.com/spf13/testproject" project := NewProject(projectName) defer os.RemoveAll(project.AbsPath()) - defer viper.Set("year", nil) - viper.Set("year", 2017) // For reproducible builds + viper.Set("year", 2017) // For reproducible builds. + defer viper.Set("year", nil) os.Args = []string{"cobra", "init", projectName} if err := rootCmd.Execute(); err != nil { diff --git a/cobra/cmd/licenses.go b/cobra/cmd/licenses.go index 61444f6..cf2a6b7 100644 --- a/cobra/cmd/licenses.go +++ b/cobra/cmd/licenses.go @@ -78,7 +78,7 @@ func getLicense() License { func copyrightLine() string { author := viper.GetString("author") - year := viper.GetString("year") // For reproducible builds + year := viper.GetString("year") // For tests. if year == "" { year = time.Now().Format("2006") }