From 0c5c4ebb916fd4fdc6992208d78f3cd32fc233d4 Mon Sep 17 00:00:00 2001 From: esell Date: Thu, 4 Oct 2018 13:43:04 -0600 Subject: [PATCH 1/2] add unit tests for runtime/core - errors --- pkg/runtime/core/errors_test.go | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 pkg/runtime/core/errors_test.go diff --git a/pkg/runtime/core/errors_test.go b/pkg/runtime/core/errors_test.go new file mode 100644 index 00000000..6b483b79 --- /dev/null +++ b/pkg/runtime/core/errors_test.go @@ -0,0 +1,35 @@ +package core_test + +import ( + "testing" + + "github.com/esell/ferret/pkg/runtime/core" + "github.com/pkg/errors" + . "github.com/smartystreets/goconvey/convey" +) + +func TestSourceError(t *testing.T) { + Convey("Should match", t, func() { + sm := core.NewSourceMap("test", 1, 1) + + msg := "test at 1:1" + cause := errors.New("cause") + e := errors.Errorf("%s: %s", cause.Error(), msg) + + cse := core.SourceError(sm, cause) + So(cse, ShouldNotBeNil) + So(cse.Error(), ShouldEqual, e.Error()) + }) +} + +func TestError(t *testing.T) { + Convey("Should match", t, func() { + msg := "test message" + cause := errors.New("cause") + e := errors.Errorf("%s: %s", cause.Error(), msg) + + ce := core.Error(cause, msg) + So(ce, ShouldNotBeNil) + So(ce.Error(), ShouldEqual, e.Error()) + }) +} From 94f8398255c1c0a6f2a033adf745df13ebf21fa0 Mon Sep 17 00:00:00 2001 From: esell Date: Thu, 4 Oct 2018 13:46:34 -0600 Subject: [PATCH 2/2] fix package name in errors_test.go --- pkg/runtime/core/errors_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/runtime/core/errors_test.go b/pkg/runtime/core/errors_test.go index 6b483b79..328fe9f4 100644 --- a/pkg/runtime/core/errors_test.go +++ b/pkg/runtime/core/errors_test.go @@ -3,7 +3,7 @@ package core_test import ( "testing" - "github.com/esell/ferret/pkg/runtime/core" + "github.com/MontFerret/ferret/pkg/runtime/core" "github.com/pkg/errors" . "github.com/smartystreets/goconvey/convey" )