github.com/gunjan5/docker@v1.8.2/daemon/execdriver/lxc/info_test.go (about)

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