summaryrefslogtreecommitdiff
path: root/execdriver/lxc/info_test.go
blob: edafc02511d7d35840fadf5596d48e7f29df1185 (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
package lxc

import (
	"testing"
)

func TestParseRunningInfo(t *testing.T) {
	raw := `
    state: RUNNING
    pid:    50`

	info, err := parseLxcInfo(raw)
	if err != nil {
		t.Fatal(err)
	}
	if !info.Running {
		t.Fatal("info should return a running state")
	}
	if info.Pid != 50 {
		t.Fatalf("info should have pid 50 got %d", info.Pid)
	}
}

func TestEmptyInfo(t *testing.T) {
	_, err := parseLxcInfo("")
	if err == nil {
		t.Fatal("error should not be nil")
	}
}

func TestBadInfo(t *testing.T) {
	_, err := parseLxcInfo("state")
	if err != nil {
		t.Fatal(err)
	}
}