File: diff_test.go

package info (click to toggle)
golang-github-zclconf-go-cty-debug 0.0~git20191215.b22d67c-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 108 kB
  • sloc: makefile: 2
file content (45 lines) | stat: -rw-r--r-- 963 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package ctydebug_test

import (
	"fmt"

	"github.com/zclconf/go-cty-debug/ctydebug"
	"github.com/zclconf/go-cty/cty"
)

func ExampleDiffValues() {
	a := cty.ObjectVal(map[string]cty.Value{
		"foo": cty.StringVal("a"),
		"bar": cty.StringVal("b"),
		"baz": cty.MapVal(map[string]cty.Value{
			"hello": cty.StringVal("world"),
		}),
	})
	b := cty.ObjectVal(map[string]cty.Value{
		"bar": cty.EmptyObjectVal,
		"baz": cty.MapVal(map[string]cty.Value{
			"hello":   cty.UnknownVal(cty.String),
			"goodbye": cty.StringVal("moon"),
		}),
	})

	fmt.Print(ctydebug.DiffValues(b, a))

	// Output:
	// {cty.Value}["bar"]
	//   got:  cty.StringVal("b")
	//   want: cty.EmptyObjectVal
	//
	// {cty.Value}["baz"]["goodbye"]
	//   got:  (no value)
	//   want: cty.StringVal("moon")
	//
	// {cty.Value}["baz"]["hello"]
	//   got:  cty.StringVal("world")
	//   want: cty.UnknownVal(cty.String)
	//
	// {cty.Value}["foo"]
	//   got:  cty.StringVal("a")
	//   want: (no value)

}