Skip to content

Commit

Permalink
test: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
szkiba committed Jul 9, 2024
1 parent fef8ae3 commit 84e4429
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
26 changes: 26 additions & 0 deletions cmd/k6exec/error_internal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"errors"
"testing"

"github.com/stretchr/testify/require"
)

type testError struct {

Check failure on line 10 in cmd/k6exec/error_internal_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
}

func (*testError) Error() string {
return "test error"
}

func (*testError) Format(_ int, _ bool) string {
return "formatted test error"
}

func Test_formatError(t *testing.T) {
t.Parallel()

require.Equal(t, errors.ErrUnsupported.Error(), formatError(errors.ErrUnsupported))
require.Equal(t, "formatted test error", formatError(new(testError)))
}
10 changes: 10 additions & 0 deletions cmd/k6exec/main_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"runtime"
"testing"

sloglogrus "github.com/samber/slog-logrus/v2"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)

Expand All @@ -24,3 +26,11 @@ func Test_newCmd(t *testing.T) { //nolint:paralleltest

require.NoError(t, cmd.Execute())
}

func Test_initLogging(t *testing.T) {

Check failure on line 30 in cmd/k6exec/main_internal_test.go

View workflow job for this annotation

GitHub Actions / lint

Function Test_initLogging missing the call to method parallel
lvar := initLogging(appname)

require.NotNil(t, lvar)
require.Equal(t, logrus.DebugLevel, logrus.GetLevel())
require.IsType(t, new(sloglogrus.LogrusHandler), slog.Default().Handler())
}

0 comments on commit 84e4429

Please sign in to comment.