github.com/sneal/packer@v0.5.2/builder/vmware/common/vmx_test.go (about) 1 package common 2 3 import "testing" 4 5 func TestParseVMX(t *testing.T) { 6 contents := ` 7 .encoding = "UTF-8" 8 config.version = "8" 9 ` 10 11 results := ParseVMX(contents) 12 if len(results) != 2 { 13 t.Fatalf("not correct number of results: %d", len(results)) 14 } 15 16 if results[".encoding"] != "UTF-8" { 17 t.Errorf("invalid .encoding: %s", results[".encoding"]) 18 } 19 20 if results["config.version"] != "8" { 21 t.Errorf("invalid config.version: %s", results["config.version"]) 22 } 23 } 24 25 func TestEncodeVMX(t *testing.T) { 26 contents := map[string]string{ 27 ".encoding": "UTF-8", 28 "config.version": "8", 29 } 30 31 expected := `.encoding = "UTF-8" 32 config.version = "8" 33 ` 34 35 result := EncodeVMX(contents) 36 if result != expected { 37 t.Errorf("invalid results: %s", result) 38 } 39 }