github.com/fcwu/docker@v1.4.2-0.20150115145920-2a69ca89f0df/daemon/execdriver/lxc/info_test.go (about)

     1  package lxc
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestParseRunningInfo(t *testing.T) {
     8  	raw := `
     9      state: RUNNING
    10      pid:    50`
    11  
    12  	info, err := parseLxcInfo(raw)
    13  	if err != nil {
    14  		t.Fatal(err)
    15  	}
    16  	if !info.Running {
    17  		t.Fatal("info should return a running state")
    18  	}
    19  	if info.Pid != 50 {
    20  		t.Fatalf("info should have pid 50 got %d", info.Pid)
    21  	}
    22  }
    23  
    24  func TestEmptyInfo(t *testing.T) {
    25  	_, err := parseLxcInfo("")
    26  	if err == nil {
    27  		t.Fatal("error should not be nil")
    28  	}
    29  }
    30  
    31  func TestBadInfo(t *testing.T) {
    32  	_, err := parseLxcInfo("state")
    33  	if err != nil {
    34  		t.Fatal(err)
    35  	}
    36  }