info_test.go 587 B

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