Skip to content

Commit cb91de1

Browse files
committed
Rename AddCommandContext to TestCommandContext
1 parent 107f2ac commit cb91de1

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

cmd/commander/commander.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ test commander.yaml --filter=filter1 --filter=filter2
7676
},
7777
},
7878
Action: func(c *cli.Context) error {
79-
return app.TestCommand(c.Args().First(), app.NewAddContextFromCli(c))
79+
return app.TestCommand(c.Args().First(), app.NewTestContextFromCli(c))
8080
},
8181
}
8282
}

pkg/app/app.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ const (
1111
CommanderFile = "commander.yaml"
1212
)
1313

14-
//AddCommandContext holds all flags for the add command
15-
type AddCommandContext struct {
14+
//TestCommandContext holds all flags for the add command
15+
type TestCommandContext struct {
1616
Verbose bool
1717
NoColor bool
1818
Dir bool
1919
Concurrent int
2020
Filters []string
2121
}
2222

23-
//NewAddContextFromCli is a constructor which creates the context
24-
func NewAddContextFromCli(c *cli.Context) AddCommandContext {
25-
return AddCommandContext{
23+
//NewTestContextFromCli is a constructor which creates the context
24+
func NewTestContextFromCli(c *cli.Context) TestCommandContext {
25+
return TestCommandContext{
2626
Verbose: c.Bool("verbose"),
2727
NoColor: c.Bool("no-color"),
2828
Dir: c.Bool("dir"),

pkg/app/app_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"testing"
88
)
99

10-
func TestNewAddCommandContextFromCli(t *testing.T) {
10+
func TestNewTestCommandContextFromCli(t *testing.T) {
1111
set := flag.NewFlagSet("verbose", 0)
1212
set.Bool("verbose", true, "")
1313
set.Bool("no-color", true, "")
@@ -16,7 +16,7 @@ func TestNewAddCommandContextFromCli(t *testing.T) {
1616
context := &cli.Context{}
1717
ctx := cli.NewContext(nil, set, context)
1818

19-
r := NewAddContextFromCli(ctx)
19+
r := NewTestContextFromCli(ctx)
2020

2121
assert.True(t, r.Verbose)
2222
assert.True(t, r.NoColor)

pkg/app/test_command.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var out output.OutputWriter
1818
// testPath is the path to the test suite config, it can be a dir or file
1919
// ctx holds the command flags. If directory scanning is enabled with --dir it is
2020
// not supported to filter tests, therefore testFilterTitle is an empty string
21-
func TestCommand(testPath string, ctx AddCommandContext) error {
21+
func TestCommand(testPath string, ctx TestCommandContext) error {
2222
if ctx.Verbose {
2323
log.SetOutput(os.Stdout)
2424
}
@@ -65,8 +65,8 @@ func testDir(directory string, filters runtime.Filters) (runtime.Result, error)
6565
continue // skip dirs
6666
}
6767

68-
path := path.Join(directory, f.Name())
69-
newResult, err := testFile(path, f.Name(), filters)
68+
p := path.Join(directory, f.Name())
69+
newResult, err := testFile(p, f.Name(), filters)
7070
if err != nil {
7171
return result, err
7272
}

pkg/app/test_command_linux_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ tests:
2020

2121
assert.Nil(t, err)
2222

23-
got := TestCommand(TestSuiteFile, AddCommandContext{})
23+
got := TestCommand(TestSuiteFile, TestCommandContext{})
2424
assert.Nil(t, got)
2525
}
2626

@@ -34,7 +34,7 @@ tests:
3434

3535
assert.Nil(t, err)
3636

37-
got := TestCommand(TestSuiteFile, AddCommandContext{})
37+
got := TestCommand(TestSuiteFile, TestCommandContext{})
3838
assert.Equal(t, "Test suite failed, use --verbose for more detailed output", got.Error())
3939

4040
}
@@ -53,7 +53,7 @@ tests:
5353

5454
assert.Nil(t, err)
5555

56-
context := AddCommandContext{}
56+
context := TestCommandContext{}
5757
context.Filters = runtime.Filters{"my title"}
5858
got := TestCommand(TestSuiteFile, context)
5959
assert.Nil(t, got)

pkg/app/test_command_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ import (
1616

1717
func Test_TestCommand_Verbose(t *testing.T) {
1818
out := captureOutput(func() {
19-
TestCommand("commander.yaml", AddCommandContext{Verbose: true})
19+
TestCommand("commander.yaml", TestCommandContext{Verbose: true})
2020
log.Println("test test test")
2121
})
2222

2323
assert.Contains(t, out, "test test test")
2424
}
2525

2626
func Test_TestCommand_DefaultFile(t *testing.T) {
27-
err := TestCommand("", AddCommandContext{Verbose: true})
27+
err := TestCommand("", TestCommandContext{Verbose: true})
2828
assert.Contains(t, err.Error(), "commander.yaml")
2929
}
3030

3131
func Test_TestCommand(t *testing.T) {
32-
err := TestCommand("commander.yaml", AddCommandContext{})
32+
err := TestCommand("commander.yaml", TestCommandContext{})
3333

3434
if runtime.GOOS == "windows" {
3535
assert.Contains(t, err.Error(), "Error open commander.yaml:")
@@ -39,7 +39,7 @@ func Test_TestCommand(t *testing.T) {
3939
}
4040

4141
func Test_TestCommand_ShouldUseCustomFile(t *testing.T) {
42-
err := TestCommand("my-test.yaml", AddCommandContext{})
42+
err := TestCommand("my-test.yaml", TestCommandContext{})
4343

4444
if runtime.GOOS == "windows" {
4545
assert.Contains(t, err.Error(), "Error open my-test.yaml:")
@@ -49,7 +49,7 @@ func Test_TestCommand_ShouldUseCustomFile(t *testing.T) {
4949
}
5050

5151
func Test_TestCommand_File_WithDir(t *testing.T) {
52-
err := TestCommand("../../examples", AddCommandContext{})
52+
err := TestCommand("../../examples", TestCommandContext{})
5353

5454
if runtime.GOOS == "windows" {
5555
assert.Contains(t, err.Error(), "is a directory")
@@ -59,7 +59,7 @@ func Test_TestCommand_File_WithDir(t *testing.T) {
5959
}
6060

6161
func Test_TestCommand_Dir(t *testing.T) {
62-
err := TestCommand("../../examples", AddCommandContext{Dir: true})
62+
err := TestCommand("../../examples", TestCommandContext{Dir: true})
6363

6464
if runtime.GOOS == "windows" {
6565
assert.Contains(t, err.Error(), "Test suite failed, use --verbose for more detailed output")

0 commit comments

Comments
 (0)