mirror of https://github.com/databricks/cli.git
Update test
This commit is contained in:
parent
414c9fba1f
commit
5a9847b03d
|
@ -1,26 +1,27 @@
|
||||||
package dyn
|
package dyn_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/databricks/cli/libs/dyn"
|
||||||
|
assert "github.com/databricks/cli/libs/dyn/dynassert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestVisitCallbackPathCopy(t *testing.T) {
|
func TestVisitCallbackPathCopy(t *testing.T) {
|
||||||
vin := V(map[string]Value{
|
vin := dyn.V(map[string]dyn.Value{
|
||||||
"foo": V(42),
|
"foo": dyn.V(42),
|
||||||
"bar": V(43),
|
"bar": dyn.V(43),
|
||||||
})
|
})
|
||||||
|
|
||||||
var paths []Path
|
var paths []dyn.Path
|
||||||
|
|
||||||
// The callback should receive a copy of the path.
|
// The callback should receive a copy of the path.
|
||||||
// If the same underlying value is used, all collected paths will be the same.
|
// If the same underlying value is used, all collected paths will be the same.
|
||||||
_, _ = visit(vin, EmptyPath, NewPattern(AnyKey()), visitOptions{
|
// This test uses `MapByPattern` to collect all paths in the map.
|
||||||
fn: func(p Path, v Value) (Value, error) {
|
// Visit itself doesn't have public functions and we exclusively use black-box testing for this package.
|
||||||
paths = append(paths, p)
|
_, _ = dyn.MapByPattern(vin, dyn.NewPattern(dyn.AnyKey()), func(p dyn.Path, v dyn.Value) (dyn.Value, error) {
|
||||||
return v, nil
|
paths = append(paths, p)
|
||||||
},
|
return v, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
// Verify that the paths retained their original values.
|
// Verify that the paths retained their original values.
|
||||||
|
|
Loading…
Reference in New Issue