Skip to content

Commit

Permalink
Merge pull request #11 from xmidt-org/feature/minor-tests
Browse files Browse the repository at this point in the history
Feature/minor tests
  • Loading branch information
johnabass authored Oct 8, 2023
2 parents 099467c + 98f7f95 commit eaf254c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ type RunnerSuite struct {
CommonSuite
}

// TestDefaultTimer is just a smoke test to make sure the defaultTimer
// operates basically as intended.
func (suite *RunnerSuite) TestDefaultTimer() {
ch, stop := defaultTimer(100 * time.Millisecond)
suite.NotNil(ch)
suite.Require().NotNil(stop)

stop()
stop() // idempotent
}

func (suite *RunnerSuite) testRunNoRetries() {
var (
testCtx, _ = suite.testCtx()
Expand Down Expand Up @@ -176,6 +187,21 @@ func (suite *RunnerSuite) TestRun() {
suite.Run("WithRetriesAndCanceled", suite.testRunWithRetriesAndCanceled)
}

func (suite *RunnerSuite) TestOptionError() {
var (
expectedErr = errors.New("expected")
runner, actualErr = NewRunner[int](
runnerOptionFunc[int](func(r *runner[int]) error {
suite.NotNil(r)
return expectedErr
}),
)
)

suite.Nil(runner)
suite.Same(expectedErr, actualErr)
}

func TestRunner(t *testing.T) {
suite.Run(t, new(RunnerSuite))
}

0 comments on commit eaf254c

Please sign in to comment.