MCPcopy Create free account
hub / github.com/docker/cli / TestInterpolateWithCast

Function TestInterpolateWithCast

cli/compose/interpolation/interpolation_test.go:83–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

81}
82
83func TestInterpolateWithCast(t *testing.T) {
84 config := map[string]any{
85 "foo": map[string]any{
86 "replicas": "$count",
87 },
88 }
89 toInt := func(value string) (any, error) {
90 return strconv.Atoi(value)
91 }
92 result, err := Interpolate(config, Options{
93 LookupValue: defaultMapping,
94 TypeCastMapping: map[Path]Cast{NewPath(PathMatchAll, "replicas"): toInt},
95 })
96 assert.NilError(t, err)
97 expected := map[string]any{
98 "foo": map[string]any{
99 "replicas": 5,
100 },
101 }
102 assert.Check(t, is.DeepEqual(expected, result))
103}
104
105func TestPathMatches(t *testing.T) {
106 testcases := []struct {

Callers

nothing calls this directly

Calls 2

InterpolateFunction · 0.85
NewPathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…