mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-16 04:12:16 +01:00
refactoring tests util methods + adding context tests
This commit is contained in:
@@ -8,13 +8,12 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/thecodingmachine/gotenberg/internal/pkg/xerror"
|
||||
"github.com/thecodingmachine/gotenberg/internal/pkg/xtime"
|
||||
"github.com/thecodingmachine/gotenberg/test/internalpkg/xerrortest"
|
||||
"github.com/thecodingmachine/gotenberg/test/internalpkg/xlogtest"
|
||||
"github.com/thecodingmachine/gotenberg/test"
|
||||
)
|
||||
|
||||
func TestMustHandleError(t *testing.T) {
|
||||
previousErr := errors.New("previous error")
|
||||
logger := xlogtest.DebugLogger()
|
||||
logger := test.DebugLogger()
|
||||
// context should not have an error.
|
||||
ctx, cancel := WithTimeout(logger, 5)
|
||||
defer cancel()
|
||||
@@ -31,13 +30,13 @@ func TestMustHandleError(t *testing.T) {
|
||||
defer cancel()
|
||||
time.Sleep(xtime.Duration(1))
|
||||
err = MustHandleError(ctx, previousErr)
|
||||
xerr := xerrortest.AssertError(t, err)
|
||||
xerr := test.AssertError(t, err)
|
||||
assert.Equal(t, xerror.TimeoutCode, xerror.Code(xerr))
|
||||
// context should have an error different
|
||||
// than context.DeadlineExceeded.
|
||||
ctx, cancel = WithTimeout(logger, 5)
|
||||
cancel()
|
||||
err = MustHandleError(ctx, previousErr)
|
||||
xerr = xerrortest.AssertError(t, err)
|
||||
xerr = test.AssertError(t, err)
|
||||
assert.Equal(t, xerror.InternalCode, xerror.Code(xerr))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user