debian-mirror-gitlab/workhorse/internal/zipartifacts/errors_test.go
2021-02-22 17:27:13 +05:30

32 lines
656 B
Go

package zipartifacts
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
)
func TestExitCodeByError(t *testing.T) {
t.Run("when error has been recognized", func(t *testing.T) {
code := ExitCodeByError(ErrorCode[CodeLimitsReached])
require.Equal(t, code, CodeLimitsReached)
require.Greater(t, code, 10)
})
t.Run("when error is an unknown one", func(t *testing.T) {
code := ExitCodeByError(errors.New("unknown error"))
require.Equal(t, code, CodeUnknownError)
require.Greater(t, code, 10)
})
}
func TestErrorLabels(t *testing.T) {
for code := range ErrorCode {
_, ok := ErrorLabel[code]
require.True(t, ok)
}
}