1
0

sharedpullerstate_test.go 788 B

123456789101112131415161718192021222324252627282930313233343536
  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. )
  12. // Test creating temporary file inside read-only directory
  13. func TestReadOnlyDir(t *testing.T) {
  14. ffs := fs.NewFilesystem(fs.FilesystemTypeFake, rand.String(32))
  15. ffs.Mkdir("testdir", 0o555)
  16. s := sharedPullerState{
  17. fs: ffs,
  18. tempName: "testdir/.temp_name",
  19. }
  20. fd, err := s.tempFile()
  21. if err != nil {
  22. t.Fatal(err)
  23. }
  24. if fd == nil {
  25. t.Fatal("Unexpected nil fd")
  26. }
  27. s.fail(nil)
  28. s.finalClose()
  29. }