pidfile_test.go 473 B

1234567891011121314151617181920212223242526
  1. package pidfile // import "github.com/docker/docker/pkg/pidfile"
  2. import (
  3. "os"
  4. "path/filepath"
  5. "testing"
  6. )
  7. func TestWrite(t *testing.T) {
  8. path := filepath.Join(t.TempDir(), "testfile")
  9. err := Write(path, 0)
  10. if err == nil {
  11. t.Fatal("writing PID < 1 should fail")
  12. }
  13. err = Write(path, os.Getpid())
  14. if err != nil {
  15. t.Fatal("Could not create test file", err)
  16. }
  17. err = Write(path, os.Getpid())
  18. if err == nil {
  19. t.Fatal("Test file creation not blocked")
  20. }
  21. }