summaryrefslogtreecommitdiff
path: root/libvirt/utils_domain_def_test.go
blob: 3b3061c5e82a92289fe1aa085fc935e45dd2ea26 (plain)
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
package libvirt

import (
	"reflect"
	"testing"

	"github.com/davecgh/go-spew/spew"
)

func init() {
	spew.Config.Indent = "\t"
}

func TestSplitKernelCmdLine(t *testing.T) {
	e := []map[string]string{
		{"foo": "bar"},
		{
			"foo":  "bar",
			"key":  "val",
			"root": "UUID=aa52d618-a2c4-4aad-aeb7-68d9e3a2c91d"},
		{"_": "nosplash rw"}}
	r, err := splitKernelCmdLine("foo=bar foo=bar key=val root=UUID=aa52d618-a2c4-4aad-aeb7-68d9e3a2c91d nosplash rw")
	if !reflect.DeepEqual(r, e) {
		t.Fatalf("got='%s' expected='%s'", spew.Sdump(r), spew.Sdump(e))
	}
	if err != nil {
		t.Error(err)
	}
}

func TestSplitKernelEmptyCmdLine(t *testing.T) {
	var e []map[string]string
	r, err := splitKernelCmdLine("")
	if !reflect.DeepEqual(r, e) {
		t.Fatalf("got='%s' expected='%s'", spew.Sdump(r), spew.Sdump(e))
	}
	if err != nil {
		t.Error(err)
	}
}