diff --git a/cobra/cmd/add_test.go b/cobra/cmd/add_test.go index 1aa5f537..8cda321e 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 1ba9a54b..115f5d2f 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 61444f66..cf2a6b7a 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") }