diff options
Diffstat (limited to 'pkg/utils')
-rw-r--r-- | pkg/utils/dummies.go | 14 | ||||
-rw-r--r-- | pkg/utils/errors.go | 14 |
2 files changed, 28 insertions, 0 deletions
diff --git a/pkg/utils/dummies.go b/pkg/utils/dummies.go new file mode 100644 index 000000000..ab6d041dd --- /dev/null +++ b/pkg/utils/dummies.go @@ -0,0 +1,14 @@ +package utils + +import ( + "io/ioutil" + + "github.com/sirupsen/logrus" +) + +// NewDummyLog creates a new dummy Log for testing +func NewDummyLog() *logrus.Entry { + log := logrus.New() + log.Out = ioutil.Discard + return log.WithField("test", "test") +} diff --git a/pkg/utils/errors.go b/pkg/utils/errors.go new file mode 100644 index 000000000..cd3cb686c --- /dev/null +++ b/pkg/utils/errors.go @@ -0,0 +1,14 @@ +package utils + +import "github.com/go-errors/errors" + +// WrapError wraps an error for the sake of showing a stack trace at the top level +// the go-errors package, for some reason, does not return nil when you try to wrap +// a non-error, so we're just doing it here +func WrapError(err error) error { + if err == nil { + return err + } + + return errors.Wrap(err, 0) +} |