mirror of https://github.com/databricks/cli.git
use dynassert
This commit is contained in:
parent
35f2d58180
commit
d25d95b70c
|
@ -4,8 +4,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/databricks/cli/libs/dyn/convert"
|
"github.com/databricks/cli/libs/dyn/convert"
|
||||||
|
"github.com/databricks/cli/libs/dyn/dynassert"
|
||||||
"github.com/databricks/databricks-sdk-go/service/jobs"
|
"github.com/databricks/databricks-sdk-go/service/jobs"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const jsonData = `
|
const jsonData = `
|
||||||
|
@ -45,11 +45,11 @@ const jsonData = `
|
||||||
|
|
||||||
func TestJsonLoader(t *testing.T) {
|
func TestJsonLoader(t *testing.T) {
|
||||||
v, err := LoadJSON([]byte(jsonData), "(inline)")
|
v, err := LoadJSON([]byte(jsonData), "(inline)")
|
||||||
assert.NoError(t, err)
|
dynassert.NoError(t, err)
|
||||||
|
|
||||||
var r jobs.ResetJob
|
var r jobs.ResetJob
|
||||||
err = convert.ToTyped(&r, v)
|
err = convert.ToTyped(&r, v)
|
||||||
assert.NoError(t, err)
|
dynassert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
const malformedMap = `
|
const malformedMap = `
|
||||||
|
@ -64,7 +64,7 @@ const malformedMap = `
|
||||||
|
|
||||||
func TestJsonLoaderMalformedMap(t *testing.T) {
|
func TestJsonLoaderMalformedMap(t *testing.T) {
|
||||||
_, err := LoadJSON([]byte(malformedMap), "(inline)")
|
_, err := LoadJSON([]byte(malformedMap), "(inline)")
|
||||||
assert.ErrorContains(t, err, "error decoding JSON at (inline):6:16: invalid character ',' after object key")
|
dynassert.ErrorContains(t, err, "error decoding JSON at (inline):6:16: invalid character ',' after object key")
|
||||||
}
|
}
|
||||||
|
|
||||||
const malformedArray = `
|
const malformedArray = `
|
||||||
|
@ -78,7 +78,7 @@ const malformedArray = `
|
||||||
|
|
||||||
func TestJsonLoaderMalformedArray(t *testing.T) {
|
func TestJsonLoaderMalformedArray(t *testing.T) {
|
||||||
_, err := LoadJSON([]byte(malformedArray), "path/to/file.json")
|
_, err := LoadJSON([]byte(malformedArray), "path/to/file.json")
|
||||||
assert.ErrorContains(t, err, "error decoding JSON at path/to/file.json:6:28: invalid character ']' looking for beginning of value")
|
dynassert.ErrorContains(t, err, "error decoding JSON at path/to/file.json:6:28: invalid character ']' looking for beginning of value")
|
||||||
}
|
}
|
||||||
|
|
||||||
const eofData = `
|
const eofData = `
|
||||||
|
@ -89,5 +89,5 @@ const eofData = `
|
||||||
|
|
||||||
func TestJsonLoaderEOF(t *testing.T) {
|
func TestJsonLoaderEOF(t *testing.T) {
|
||||||
_, err := LoadJSON([]byte(eofData), "path/to/file.json")
|
_, err := LoadJSON([]byte(eofData), "path/to/file.json")
|
||||||
assert.ErrorContains(t, err, "unexpected end of JSON input")
|
dynassert.ErrorContains(t, err, "unexpected end of JSON input")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue