2013-12-24 01:07:43 -05:00
|
|
|
package common
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestParseVMX(t *testing.T) {
|
|
|
|
contents := `
|
|
|
|
.encoding = "UTF-8"
|
|
|
|
config.version = "8"
|
2016-08-19 07:23:07 -04:00
|
|
|
scsi0:0.virtualSSD = 1
|
2013-12-24 01:07:43 -05:00
|
|
|
`
|
|
|
|
|
|
|
|
results := ParseVMX(contents)
|
2016-08-19 07:23:07 -04:00
|
|
|
if len(results) != 3 {
|
2013-12-24 01:07:43 -05:00
|
|
|
t.Fatalf("not correct number of results: %d", len(results))
|
|
|
|
}
|
|
|
|
|
|
|
|
if results[".encoding"] != "UTF-8" {
|
|
|
|
t.Errorf("invalid .encoding: %s", results[".encoding"])
|
|
|
|
}
|
|
|
|
|
|
|
|
if results["config.version"] != "8" {
|
|
|
|
t.Errorf("invalid config.version: %s", results["config.version"])
|
|
|
|
}
|
2016-08-19 07:23:07 -04:00
|
|
|
|
|
|
|
if results["scsi0:0.virtualssd"] != "1" {
|
|
|
|
t.Errorf("invalid scsi0:0.virtualssd: %s", results["scsi0:0.virtualssd"])
|
|
|
|
}
|
2013-12-24 01:07:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestEncodeVMX(t *testing.T) {
|
|
|
|
contents := map[string]string{
|
2016-09-29 17:13:04 -04:00
|
|
|
".encoding": "UTF-8",
|
|
|
|
"config.version": "8",
|
2016-08-19 07:23:07 -04:00
|
|
|
"scsi0:0.virtualssd": "1",
|
2013-12-24 01:07:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
expected := `.encoding = "UTF-8"
|
|
|
|
config.version = "8"
|
2016-08-19 07:23:07 -04:00
|
|
|
scsi0:0.virtualSSD = 1
|
2013-12-24 01:07:43 -05:00
|
|
|
`
|
|
|
|
|
|
|
|
result := EncodeVMX(contents)
|
|
|
|
if result != expected {
|
|
|
|
t.Errorf("invalid results: %s", result)
|
|
|
|
}
|
|
|
|
}
|