Skip to content

Commit

Permalink
Merge pull request #41 from esell/runtime-tests
Browse files Browse the repository at this point in the history
[WIP] add unit tests for runtime/core
  • Loading branch information
ziflex authored Oct 4, 2018
2 parents 689cd71 + 94f8398 commit 71ee1f3
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pkg/runtime/core/errors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package core_test

import (
"testing"

"github.com/MontFerret/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())
})
}

0 comments on commit 71ee1f3

Please sign in to comment.