Skip to content

Commit

Permalink
Merge pull request #55 from hofstadter-io/cli-cover-tests
Browse files Browse the repository at this point in the history
CLI test setup
  • Loading branch information
verdverm committed Jun 6, 2020
2 parents 4e4c3ec + ce6feb1 commit 5dce9ba
Show file tree
Hide file tree
Showing 508 changed files with 6,121 additions and 2,832 deletions.
14 changes: 3 additions & 11 deletions .hof/shadow/Cli/cmd/hof/cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/ga"
Expand All @@ -31,9 +29,7 @@ var AddCmd = &cobra.Command{

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath())

},

Expand All @@ -56,15 +52,11 @@ func init() {
usage := AddCmd.UsageFunc()

thelp := func(cmd *cobra.Command, args []string) {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/help", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " help")
help(cmd, args)
}
tusage := func(cmd *cobra.Command) error {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/usage", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " usage")
return usage(cmd)
}
AddCmd.SetHelpFunc(thelp)
Expand Down
34 changes: 34 additions & 0 deletions .hof/shadow/Cli/cmd/hof/cmd/add_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cmd_test

import (
"testing"

"github.com/hofstadter-io/hof/lib/yagu"
"github.com/rogpeppe/go-internal/testscript"

"github.com/hofstadter-io/hof/cmd/hof/cmd"
)

func TestScriptAddCliTests(t *testing.T) {
// setup some directories

dir := "add"

workdir := ".workdir/cli/" + dir
yagu.Mkdir(workdir)

testscript.Run(t, testscript.Params{
Setup: func(env *testscript.Env) error {
// add any environment variables for your tests here

env.Vars = append(env.Vars, "HOF_TELEMETRY_DISABLED=1")

return nil
},
Funcs: map[string]func(ts *testscript.TestScript, args []string) error{
"__hof": cmd.CallTS,
},
Dir: "testscripts/cli/add",
WorkdirRoot: workdir,
})
}
14 changes: 3 additions & 11 deletions .hof/shadow/Cli/cmd/hof/cmd/auth.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cmd

import (
"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/cmd/auth"
Expand All @@ -22,9 +20,7 @@ var AuthCmd = &cobra.Command{

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath())

},
}
Expand All @@ -35,15 +31,11 @@ func init() {
usage := AuthCmd.UsageFunc()

thelp := func(cmd *cobra.Command, args []string) {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/help", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " help")
help(cmd, args)
}
tusage := func(cmd *cobra.Command) error {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/usage", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " usage")
return usage(cmd)
}
AuthCmd.SetHelpFunc(thelp)
Expand Down
14 changes: 3 additions & 11 deletions .hof/shadow/Cli/cmd/hof/cmd/auth/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/ga"
Expand All @@ -31,9 +29,7 @@ var ListCmd = &cobra.Command{

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath())

},

Expand All @@ -56,15 +52,11 @@ func init() {
usage := ListCmd.UsageFunc()

thelp := func(cmd *cobra.Command, args []string) {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/help", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " help")
help(cmd, args)
}
tusage := func(cmd *cobra.Command) error {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/usage", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " usage")
return usage(cmd)
}
ListCmd.SetHelpFunc(thelp)
Expand Down
14 changes: 3 additions & 11 deletions .hof/shadow/Cli/cmd/hof/cmd/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/ga"
Expand All @@ -31,9 +29,7 @@ var LoginCmd = &cobra.Command{

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath())

},

Expand Down Expand Up @@ -64,15 +60,11 @@ func init() {
usage := LoginCmd.UsageFunc()

thelp := func(cmd *cobra.Command, args []string) {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/help", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " help")
help(cmd, args)
}
tusage := func(cmd *cobra.Command) error {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/usage", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " usage")
return usage(cmd)
}
LoginCmd.SetHelpFunc(thelp)
Expand Down
14 changes: 3 additions & 11 deletions .hof/shadow/Cli/cmd/hof/cmd/auth/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/ga"
Expand All @@ -31,9 +29,7 @@ var LogoutCmd = &cobra.Command{

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath())

},

Expand All @@ -56,15 +52,11 @@ func init() {
usage := LogoutCmd.UsageFunc()

thelp := func(cmd *cobra.Command, args []string) {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/help", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " help")
help(cmd, args)
}
tusage := func(cmd *cobra.Command) error {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/usage", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " usage")
return usage(cmd)
}
LogoutCmd.SetHelpFunc(thelp)
Expand Down
14 changes: 3 additions & 11 deletions .hof/shadow/Cli/cmd/hof/cmd/auth/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/ga"
Expand All @@ -31,9 +29,7 @@ var TestCmd = &cobra.Command{

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath())

},

Expand All @@ -56,15 +52,11 @@ func init() {
usage := TestCmd.UsageFunc()

thelp := func(cmd *cobra.Command, args []string) {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/help", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " help")
help(cmd, args)
}
tusage := func(cmd *cobra.Command) error {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/usage", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " usage")
return usage(cmd)
}
TestCmd.SetHelpFunc(thelp)
Expand Down
34 changes: 34 additions & 0 deletions .hof/shadow/Cli/cmd/hof/cmd/auth_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cmd_test

import (
"testing"

"github.com/hofstadter-io/hof/lib/yagu"
"github.com/rogpeppe/go-internal/testscript"

"github.com/hofstadter-io/hof/cmd/hof/cmd"
)

func TestScriptAuthCliTests(t *testing.T) {
// setup some directories

dir := "auth"

workdir := ".workdir/cli/" + dir
yagu.Mkdir(workdir)

testscript.Run(t, testscript.Params{
Setup: func(env *testscript.Env) error {
// add any environment variables for your tests here

env.Vars = append(env.Vars, "HOF_TELEMETRY_DISABLED=1")

return nil
},
Funcs: map[string]func(ts *testscript.TestScript, args []string) error{
"__hof": cmd.CallTS,
},
Dir: "testscripts/cli/auth",
WorkdirRoot: workdir,
})
}
14 changes: 3 additions & 11 deletions .hof/shadow/Cli/cmd/hof/cmd/bisect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/ga"
Expand All @@ -31,9 +29,7 @@ var BisectCmd = &cobra.Command{

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath())

},

Expand All @@ -56,15 +52,11 @@ func init() {
usage := BisectCmd.UsageFunc()

thelp := func(cmd *cobra.Command, args []string) {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/help", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " help")
help(cmd, args)
}
tusage := func(cmd *cobra.Command) error {
cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c+"/usage", "<omit>", 0)
ga.SendCommandPath(cmd.CommandPath() + " usage")
return usage(cmd)
}
BisectCmd.SetHelpFunc(thelp)
Expand Down
34 changes: 34 additions & 0 deletions .hof/shadow/Cli/cmd/hof/cmd/bisect_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cmd_test

import (
"testing"

"github.com/hofstadter-io/hof/lib/yagu"
"github.com/rogpeppe/go-internal/testscript"

"github.com/hofstadter-io/hof/cmd/hof/cmd"
)

func TestScriptBisectCliTests(t *testing.T) {
// setup some directories

dir := "bisect"

workdir := ".workdir/cli/" + dir
yagu.Mkdir(workdir)

testscript.Run(t, testscript.Params{
Setup: func(env *testscript.Env) error {
// add any environment variables for your tests here

env.Vars = append(env.Vars, "HOF_TELEMETRY_DISABLED=1")

return nil
},
Funcs: map[string]func(ts *testscript.TestScript, args []string) error{
"__hof": cmd.CallTS,
},
Dir: "testscripts/cli/bisect",
WorkdirRoot: workdir,
})
}

0 comments on commit 5dce9ba

Please sign in to comment.