Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanhawari committed Feb 9, 2022
1 parent 6d6f3a1 commit 8497d44
Show file tree
Hide file tree
Showing 17 changed files with 2,448 additions and 18 deletions.
3 changes: 2 additions & 1 deletion cmd/browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
func Browse(cliInput string) {
sp := constants.LoadingSpinner

systemInfo, err := stew.NewSystemInfo()
stewPath, err := stew.GetStewPath()
stew.CatchAndExit(err)
systemInfo := stew.NewSystemInfo(stewPath)

userOS := systemInfo.Os
userArch := systemInfo.Arch
Expand Down
3 changes: 2 additions & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ func Install(cliInputs []string) {
for _, cliInput := range cliInputs {
sp := constants.LoadingSpinner

systemInfo, err := stew.NewSystemInfo()
stewPath, err := stew.GetStewPath()
stew.CatchAndExit(err)
systemInfo := stew.NewSystemInfo(stewPath)

userOS := systemInfo.Os
userArch := systemInfo.Arch
Expand Down
3 changes: 2 additions & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
// List is executed when you run `stew list`
func List(cliTagsFlag bool, cliAssetsFlag bool) {

systemInfo, err := stew.NewSystemInfo()
stewPath, err := stew.GetStewPath()
stew.CatchAndExit(err)
systemInfo := stew.NewSystemInfo(stewPath)

userOS := systemInfo.Os
userArch := systemInfo.Arch
Expand Down
3 changes: 2 additions & 1 deletion cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ func Uninstall(cliFlag bool, binaryName string) {
stew.CatchAndExit(err)
}

systemInfo, err := stew.NewSystemInfo()
stewPath, err := stew.GetStewPath()
stew.CatchAndExit(err)
systemInfo := stew.NewSystemInfo(stewPath)

userOS := systemInfo.Os
userArch := systemInfo.Arch
Expand Down
3 changes: 2 additions & 1 deletion cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func Upgrade(cliFlag bool, binaryName string) {

sp := constants.LoadingSpinner

systemInfo, err := stew.NewSystemInfo()
stewPath, err := stew.GetStewPath()
stew.CatchAndExit(err)
systemInfo := stew.NewSystemInfo(stewPath)

userOS := systemInfo.Os
userArch := systemInfo.Arch
Expand Down
2 changes: 1 addition & 1 deletion constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var Regex386 = `(?i)(i?386|x86_32|amd32|x32)`
var RegexGithub = `(?i)^[A-Za-z0-9-]+\/[A-Za-z0-9_.-]+(@.+)?$`

// RegexGithubSearch is a regular express for valid GitHub search queries
var RegexGithubSearch = `(?i)^[A-Za-z0-9_.-]+$`
var RegexGithubSearch = `(?i)^[A-Za-z0-9_.-/]+$`

// RegexURL is a regular express for valid URLs
var RegexURL = `(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])`
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ require (
)

require (
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/frankban/quicktest v1.14.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/hinshun/vt10x v0.0.0-20220127042424-3ca73d0126d7 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
Expand Down
9 changes: 7 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
github.com/AlecAivazis/survey/v2 v2.3.2 h1:TqTB+aDDCLYhf9/bD2TwSO8u8jDSmMUd2SUVO4gCnU8=
github.com/AlecAivazis/survey/v2 v2.3.2/go.mod h1:TH2kPCDU3Kqq7pLbnCWwZXDBjnhZtmsCle5EiYDJ2fg=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8 h1:xzYJEypr/85nBpB11F9br+3HUrpgb+fcm5iADzXXYEw=
github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
github.com/briandowns/spinner v1.18.0 h1:SJs0maNOs4FqhBwiJ3Gr7Z1D39/rukIVGQvpNZVHVcM=
github.com/briandowns/spinner v1.18.0/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -25,8 +28,9 @@ github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/gookit/color v1.5.0 h1:1Opow3+BWDwqor78DcJkJCIwnkviFi+rrOANki9BUFw=
github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo=
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ=
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
github.com/hinshun/vt10x v0.0.0-20220127042424-3ca73d0126d7 h1:PoerlCqzob3t6b5/8mjCPkX4QSTYR4/+kB8IzqZE3ug=
github.com/hinshun/vt10x v0.0.0-20220127042424-3ca73d0126d7/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
Expand Down Expand Up @@ -75,6 +79,7 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
Expand Down
2 changes: 1 addition & 1 deletion lib/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type StewpathNotFoundError struct {
}

func (e StewpathNotFoundError) Error() string {
return fmt.Sprintf("%v Could not find the stew path at %v", constants.RedColor("Error:"), e.StewPath)
return fmt.Sprintf("%v Could not find the stew path at %v", constants.RedColor("Error:"), constants.RedColor(e.StewPath))
}

// NonZeroStatusCodeDownloadError occurs if a non-zero status code is received when trying to download a file
Expand Down
Loading

0 comments on commit 8497d44

Please sign in to comment.