Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/actions/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func Help(
err error,
) {
if len(bricksToExecute) == 0 {
err = exinfra.ErrBadArg{Reason: "Error: you should specify at least a brick for help action" +
"\nif you want to display exeiac help use --help option"}
err = exinfra.ErrBadArg{Reason: `you should specify at least one brick for the "help" action if you want to display exeiac help use the --help option.`}

return 3, err
}

Expand Down Expand Up @@ -72,5 +72,6 @@ func Help(
}

execSummary.Display()

return
}
29 changes: 29 additions & 0 deletions src/actions/help_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package actions

import (
"errors"
"reflect"
"testing"

"src/exeiac/arguments"
exinfra "src/exeiac/infra"
)

var infra *exinfra.Infra
var conf *arguments.Configuration
var bricksToExecute exinfra.Bricks

func TestHelpWhenNoBricksToExecute(t *testing.T) {
bricksToExecute = exinfra.Bricks{}
expectedStatusCode := 3

statusCode, err := Help(infra, conf, bricksToExecute)

if statusCode != expectedStatusCode {
t.Fatalf(`statusCode should be %v; is "%v"`, expectedStatusCode, statusCode)
}

if errors.Is(err, exinfra.ErrBadArg{}) {
t.Fatalf("Errors should be of type ErrBadArg, is %v", reflect.TypeOf(err))
}
}
4 changes: 2 additions & 2 deletions src/infra/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func (err ActionNotImplementedError) Error() string {

func (e ErrBadArg) Error() string {
if e.Value == "" {
return fmt.Sprintf("! Bad argument: %s", e.Reason)
return fmt.Sprintf("Error(Bad argument): %s", e.Reason)
} else {
return fmt.Sprintf("! Bad argument: %s: %s", e.Reason, e.Value)
return fmt.Sprintf("Error(Bad argument): %s: %s", e.Reason, e.Value)
}
}