mirror of
https://github.com/google/go-jsonnet.git
synced 2025-09-28 17:01:02 +02:00
use t.Run for tests
using `t.Run` instead including the test name in error message is a more idiomatic way of testing things in go. Since this feature was added to go in 1.7 release and the travis config explicitly specifies 1.4 and 1.5 (2 and 2,5 year old releases) as test targets this change will break the CI builds, therefore this commit also proposes dropping those releases in favour of adding a newer version of go (1.8) as the test target. Signed-off-by: Sevki <s@sevki.org>
This commit is contained in:
parent
899b931c07
commit
640983c125
@ -1,8 +1,7 @@
|
||||
language: go
|
||||
sudo: false
|
||||
go:
|
||||
- 1.4
|
||||
- 1.5
|
||||
- 1.8
|
||||
- tip
|
||||
before_install:
|
||||
- go get github.com/axw/gocov/gocov
|
||||
|
33
main_test.go
33
main_test.go
@ -16,9 +16,7 @@ limitations under the License.
|
||||
|
||||
package jsonnet
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
// Just a few simple sanity tests for now. Eventually we'll share end-to-end tests with the C++
|
||||
// implementation but unsure if that should be done here or via some external framework.
|
||||
@ -52,18 +50,21 @@ var mainTests = []mainTest{
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
for _, test := range mainTests {
|
||||
vm := MakeVM()
|
||||
output, err := vm.EvaluateSnippet(test.name, test.input)
|
||||
var errString string
|
||||
if err != nil {
|
||||
errString = err.Error()
|
||||
}
|
||||
if errString != test.errString {
|
||||
t.Errorf("%s: error result does not match. got\n\t%+v\nexpected\n\t%+v",
|
||||
test.input, errString, test.errString)
|
||||
}
|
||||
if err == nil && output != test.golden {
|
||||
t.Errorf("%s: got\n\t%+v\nexpected\n\t%+v", test.name, output, test.golden)
|
||||
}
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
vm := MakeVM()
|
||||
output, err := vm.EvaluateSnippet(test.name, test.input)
|
||||
var errString string
|
||||
if err != nil {
|
||||
errString = err.Error()
|
||||
}
|
||||
|
||||
if errString != test.errString {
|
||||
t.Errorf("%s: error result does not match. got\n\t%+v\nexpected\n\t%+v",
|
||||
test.input, errString, test.errString)
|
||||
}
|
||||
if err == nil && output != test.golden {
|
||||
t.Errorf("got\n\t%+v\nexpected\n\t%+v", output, test.golden)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user