mirror of
https://github.com/google/go-jsonnet.git
synced 2025-09-29 01:11: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
|
language: go
|
||||||
sudo: false
|
sudo: false
|
||||||
go:
|
go:
|
||||||
- 1.4
|
- 1.8
|
||||||
- 1.5
|
|
||||||
- tip
|
- tip
|
||||||
before_install:
|
before_install:
|
||||||
- go get github.com/axw/gocov/gocov
|
- 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
|
package jsonnet
|
||||||
|
|
||||||
import (
|
import "testing"
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Just a few simple sanity tests for now. Eventually we'll share end-to-end tests with the C++
|
// 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.
|
// 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) {
|
func TestMain(t *testing.T) {
|
||||||
for _, test := range mainTests {
|
for _, test := range mainTests {
|
||||||
vm := MakeVM()
|
t.Run(test.name, func(t *testing.T) {
|
||||||
output, err := vm.EvaluateSnippet(test.name, test.input)
|
vm := MakeVM()
|
||||||
var errString string
|
output, err := vm.EvaluateSnippet(test.name, test.input)
|
||||||
if err != nil {
|
var errString string
|
||||||
errString = err.Error()
|
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 errString != test.errString {
|
||||||
}
|
t.Errorf("%s: error result does not match. got\n\t%+v\nexpected\n\t%+v",
|
||||||
if err == nil && output != test.golden {
|
test.input, errString, test.errString)
|
||||||
t.Errorf("%s: got\n\t%+v\nexpected\n\t%+v", test.name, output, test.golden)
|
}
|
||||||
}
|
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