sharedpullerstate_test.go 862 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package model
  7. import (
  8. "testing"
  9. "github.com/syncthing/syncthing/lib/fs"
  10. "github.com/syncthing/syncthing/lib/rand"
  11. "github.com/syncthing/syncthing/lib/sync"
  12. )
  13. // Test creating temporary file inside read-only directory
  14. func TestReadOnlyDir(t *testing.T) {
  15. ffs := fs.NewFilesystem(fs.FilesystemTypeFake, rand.String(32))
  16. ffs.Mkdir("testdir", 0o555)
  17. s := sharedPullerState{
  18. fs: ffs,
  19. tempName: "testdir/.temp_name",
  20. mut: sync.NewRWMutex(),
  21. }
  22. fd, err := s.tempFile()
  23. if err != nil {
  24. t.Fatal(err)
  25. }
  26. if fd == nil {
  27. t.Fatal("Unexpected nil fd")
  28. }
  29. s.fail(nil)
  30. s.finalClose()
  31. }