Skip to content

Commit

Permalink
test: remove extra argument from check calls (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
hairyhum authored Mar 7, 2024
1 parent 67a841c commit 9dae17c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/arg_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,34 @@ func (t *ArgumentTest) setDefaultExpectedLog() {

// assertNoError makes sure there is no error.
func (t *ArgumentTest) assertNoError(c *check.C, err error) {
c.Assert(err, check.IsNil, t)
c.Assert(err, check.IsNil)
}

// assertError checks the error against ExpectedErr.
func (t *ArgumentTest) assertError(c *check.C, err error) {
actualErr := errors.Cause(err)
c.Assert(actualErr, check.Equals, t.ExpectedErr, t)
c.Assert(actualErr, check.Equals, t.ExpectedErr)
}

// assertErrorMsg checks the error message against ExpectedErrMsg.
func (t *ArgumentTest) assertErrorMsg(c *check.C, err error) {
if t.ExpectedErrMsg != "" {
c.Assert(err.Error(), check.Equals, t.ExpectedErrMsg, t)
c.Assert(err.Error(), check.Equals, t.ExpectedErrMsg)
}
}

// assertCLI asserts the builder's CLI output against ExpectedCLI.
func (t *ArgumentTest) assertCLI(c *check.C, b *safecli.Builder) {
if t.ExpectedCLI != nil {
c.Check(b.Build(), check.DeepEquals, t.ExpectedCLI, t)
c.Check(b.Build(), check.DeepEquals, t.ExpectedCLI)
}
}

// assertLog asserts the builder's log output against ExpectedLog.
func (t *ArgumentTest) assertLog(c *check.C, b *safecli.Builder) {
if t.ExpectedCLI != nil {
t.setDefaultExpectedLog()
c.Check(b.String(), check.Equals, t.ExpectedLog, t)
c.Check(b.String(), check.Equals, t.ExpectedLog)
}
}

Expand All @@ -99,6 +99,7 @@ func (t *ArgumentTest) Test(c *check.C, cmdName string) {
if t.Name == "" {
c.Fatal("Name is required")
}
c.Log(t.Name)
cmd, err := command.New(cmdName, t.Argument)
if t.ExpectedErr == nil {
t.assertNoError(c, err)
Expand Down

0 comments on commit 9dae17c

Please sign in to comment.