File: cty_funcs_test.go

package info (click to toggle)
golang-github-zclconf-go-cty-yaml 1.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 416 kB
  • sloc: makefile: 2
file content (33 lines) | stat: -rw-r--r-- 753 bytes parent folder | download | duplicates (2)
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
package yaml

import (
	"testing"

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

func TestYAMLDecodeFunc(t *testing.T) {
	// FIXME: This is not a very extensive test.
	got, err := YAMLDecodeFunc.Call([]cty.Value{
		cty.StringVal("true"),
	})
	if err != nil {
		t.Fatalf("unexpected error: %s", err)
	}
	if want := cty.True; !want.RawEquals(got) {
		t.Fatalf("wrong result\ngot:  %#v\nwant: %#v", got, want)
	}
}

func TestYAMLEncodeFunc(t *testing.T) {
	// FIXME: This is not a very extensive test.
	got, err := YAMLEncodeFunc.Call([]cty.Value{
		cty.StringVal("true"),
	})
	if err != nil {
		t.Fatalf("unexpected error: %s", err)
	}
	if want := cty.StringVal("\"true\"\n"); !want.RawEquals(got) {
		t.Fatalf("wrong result\ngot:  %#v\nwant: %#v", got, want)
	}
}