Skip to content

Commit

Permalink
Makes linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ksysoev committed Nov 12, 2023
1 parent 47f4556 commit 4abb781
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions pkg/cli/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@ import (
"github.com/ksysoev/wsget/pkg/ws"
)

type mockMacro struct{}

func (m *mockMacro) Get(name string) (Executer, error) {
return nil, fmt.Errorf("macro not found: %s", name)
}

func TestCommandFactory(t *testing.T) {
tests := []struct {
name string
raw string
macro *Macro
want Executer
name string
raw string
wantErr bool
}{
{
Expand Down Expand Up @@ -123,18 +117,18 @@ func TestCommandFactory(t *testing.T) {
}

if got != nil && tt.want != nil {
switch got.(type) {
switch gotType := got.(type) {
case *CommandEdit:
if got.(*CommandEdit).content != tt.want.(*CommandEdit).content {
t.Errorf("CommandFactory() got = %v, want %v", got, tt.want)
t.Errorf("CommandFactory() type %v, got = %v, want %v", gotType, got, tt.want)
}
case *CommandSend:
if got.(*CommandSend).request != tt.want.(*CommandSend).request {
t.Errorf("CommandFactory() got = %v, want %v", got, tt.want)
t.Errorf("CommandFactory() type %v, got = %v, want %v", gotType, got, tt.want)
}
case *CommandWaitForResp:
if got.(*CommandWaitForResp).timeout != tt.want.(*CommandWaitForResp).timeout {
t.Errorf("CommandFactory() got = %v, want %v", got, tt.want)
t.Errorf("CommandFactory() type %v, got = %v, want %v", gotType, got, tt.want)
}
}
}
Expand All @@ -146,15 +140,15 @@ type mockCommand struct {
err error
}

func (c *mockCommand) Execute(exCtx *ExecutionContext) (Executer, error) {
func (c *mockCommand) Execute(_ *ExecutionContext) (Executer, error) {
return nil, c.err
}

func TestCommandSequence_Execute(t *testing.T) {
tests := []struct {
exCtx *ExecutionContext
name string
subCommands []Executer
exCtx *ExecutionContext
wantErr bool
}{
{
Expand Down Expand Up @@ -211,21 +205,23 @@ func TestCommandSequence_Execute(t *testing.T) {
func TestCommandExit_Execute(t *testing.T) {
c := &CommandExit{}
_, err := c.Execute(nil)

if err == nil {
t.Errorf("CommandExit.Execute() error = %v, wantErr %v", err, true)
}

if err.Error() != "interrupted" {
t.Errorf("CommandExit.Execute() error = %v, wantErr %v", err, "interrupted")
}
}

func TestCommandPrintMsg_Execute(t *testing.T) {
tests := []struct {
exCtx *ExecutionContext
name string
expectedOut string
msg ws.Message
exCtx *ExecutionContext
wantErr bool
expectedOut string
}{
{
name: "request message",
Expand Down

0 comments on commit 4abb781

Please sign in to comment.