Skip to content

Commit

Permalink
🏁✔️ Added test file for get.go
Browse files Browse the repository at this point in the history
 Issues related:
 	-> #16

 On branch devel
 Changes to be committed:
	new file:   cmd/get_test.go
	modified:   cmd/init.go
	modified:   cmd/set_test.go
  • Loading branch information
ChacaS0 committed Mar 1, 2018
1 parent ddcfc3a commit eae24e5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
32 changes: 32 additions & 0 deletions cmd/get_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cmd

import (
"fmt"
"testing"

"github.com/spf13/viper"
)

// TestGetAge tests if a value is returned by this func
// and if the value is a string a the right one maybe?
func TestGetAge(t *testing.T) {
intAge := viper.GetInt("duration")
strAge := fmt.Sprintf("%d", intAge)

tAge := getAge()

// Same type?
if "string" != fmt.Sprintf("%T", tAge) {
t.Log()
t.Fail()
}

// Same value?
if strAge != tAge {
t.Log("[Error - getAge()]:: ")
t.Fail()
}

}

// Shouldn't need to test printAnyIfSet() nor getHelp()
3 changes: 1 addition & 2 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,8 @@ auto-mode: false
if errWrite != nil {
fmt.Println(redB("::"), color.HiRedString("Could not write the default config to $HOME/.tempest.yaml"))
fmt.Println(redB("::"), color.HiRedString(`If the problem persists, try add this to it:
{
duration: 5
}
auto-mode: false
`))
return errWrite
}
Expand Down
1 change: 1 addition & 0 deletions cmd/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ auto-mode: false
}
viper.SetConfigFile(currCfFile)

// All done
}

0 comments on commit eae24e5

Please sign in to comment.