mirror of
https://github.com/spf13/cobra
synced 2025-05-06 05:17:21 +00:00
Merge branch 'master' into forkMaster
This commit is contained in:
commit
832cc94e04
3 changed files with 13 additions and 5 deletions
|
@ -22,9 +22,13 @@ func TestGoldenAddCmd(t *testing.T) {
|
||||||
// Initialize the project at first.
|
// Initialize the project at first.
|
||||||
initializeProject(project)
|
initializeProject(project)
|
||||||
defer os.RemoveAll(project.AbsPath())
|
defer os.RemoveAll(project.AbsPath())
|
||||||
defer viper.Set("year", nil)
|
|
||||||
|
|
||||||
viper.Set("year", 2017) // For reproducible builds
|
viper.Set("author", "NAME HERE <EMAIL ADDRESS>")
|
||||||
|
viper.Set("license", "apache")
|
||||||
|
viper.Set("year", 2017)
|
||||||
|
defer viper.Set("author", nil)
|
||||||
|
defer viper.Set("license", nil)
|
||||||
|
defer viper.Set("year", nil)
|
||||||
|
|
||||||
// Then add the "test" command.
|
// Then add the "test" command.
|
||||||
cmdName := "test"
|
cmdName := "test"
|
||||||
|
|
|
@ -18,9 +18,13 @@ func TestGoldenInitCmd(t *testing.T) {
|
||||||
projectName := "github.com/spf13/testproject"
|
projectName := "github.com/spf13/testproject"
|
||||||
project := NewProject(projectName)
|
project := NewProject(projectName)
|
||||||
defer os.RemoveAll(project.AbsPath())
|
defer os.RemoveAll(project.AbsPath())
|
||||||
defer viper.Set("year", nil)
|
|
||||||
|
|
||||||
viper.Set("year", 2017) // For reproducible builds
|
viper.Set("author", "NAME HERE <EMAIL ADDRESS>")
|
||||||
|
viper.Set("license", "apache")
|
||||||
|
viper.Set("year", 2017)
|
||||||
|
defer viper.Set("author", nil)
|
||||||
|
defer viper.Set("license", nil)
|
||||||
|
defer viper.Set("year", nil)
|
||||||
|
|
||||||
os.Args = []string{"cobra", "init", projectName}
|
os.Args = []string{"cobra", "init", projectName}
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
|
|
|
@ -78,7 +78,7 @@ func getLicense() License {
|
||||||
func copyrightLine() string {
|
func copyrightLine() string {
|
||||||
author := viper.GetString("author")
|
author := viper.GetString("author")
|
||||||
|
|
||||||
year := viper.GetString("year") // For reproducible builds
|
year := viper.GetString("year") // For tests.
|
||||||
if year == "" {
|
if year == "" {
|
||||||
year = time.Now().Format("2006")
|
year = time.Now().Format("2006")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue