github.com/hanwen/go-fuse@v1.0.0/fuse/pathfs/loopback_test.go (about)

     1  // Copyright 2018 the Go-FUSE Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package pathfs
     6  
     7  import (
     8  	"io/ioutil"
     9  	"os"
    10  	"path/filepath"
    11  	"syscall"
    12  	"testing"
    13  	"time"
    14  
    15  	"github.com/hanwen/go-fuse/fuse"
    16  	"github.com/hanwen/go-fuse/internal/testutil"
    17  )
    18  
    19  // Check that loopbackFileSystem.Utimens() works as expected
    20  func TestLoopbackFileSystemUtimens(t *testing.T) {
    21  	fs := NewLoopbackFileSystem(os.TempDir())
    22  	f, err := ioutil.TempFile("", "TestLoopbackFileSystemUtimens")
    23  	if err != nil {
    24  		t.Fatal(err)
    25  	}
    26  	path := f.Name()
    27  	name := filepath.Base(path)
    28  	f.Close()
    29  	defer syscall.Unlink(path)
    30  
    31  	utimensFn := func(atime *time.Time, mtime *time.Time) fuse.Status {
    32  		return fs.Utimens(name, atime, mtime, nil)
    33  	}
    34  	testutil.TestLoopbackUtimens(t, path, utimensFn)
    35  }