diff options
| author | Marin Ivanov <[email protected]> | 2022-08-14 21:40:00 +0300 |
|---|---|---|
| committer | Marin Ivanov <[email protected]> | 2022-08-14 21:40:00 +0300 |
| commit | 96052ff978667c882f09374a3d8a30ba58e04fcd (patch) | |
| tree | c6aee41cca736a518add72a87c1432699442da14 | |
| parent | 265ad9870e5b1b3ea08b0f6cd6edce014fea251c (diff) | |
Add more tests for unsupported functions
| -rw-r--r-- | fs.go | 8 | ||||
| -rw-r--r-- | fs_test.go | 26 |
2 files changed, 30 insertions, 4 deletions
@@ -94,7 +94,7 @@ func (fs *Fs) Rename(oldname, newname string) error { // Stat returns a FileInfo describing the named file, or an error, if any // happens. func (fs *Fs) Stat(name string) (os.FileInfo, error) { - ctx, cancel := context.WithTimeout(context.Background(), fs.Timeout) + ctx, cancel := fs.contextWithTimeout() defer cancel() info, err := fs.client.StatObject(ctx, fs.bucket, name, minio.GetObjectOptions{}) if err != nil { @@ -105,17 +105,17 @@ func (fs *Fs) Stat(name string) (os.FileInfo, error) { // Chmod changes the mode of the named file to mode. func (fs *Fs) Chmod(name string, mode os.FileMode) error { - panic("not implemented") + return ErrUnsupported } // Chown changes the uid and gid of the named file. func (fs *Fs) Chown(name string, uid, gid int) error { - panic("not implemented") + return ErrUnsupported } // Chtimes changes the access and modification times of the named file func (fs *Fs) Chtimes(name string, atime time.Time, mtime time.Time) error { - panic("not implemented") + return ErrUnsupported } func (fs *Fs) contextWithTimeout() (context.Context, context.CancelFunc) { @@ -2,6 +2,7 @@ package s3 import ( "testing" + "time" "github.com/matryer/is" "github.com/spf13/afero" @@ -32,6 +33,31 @@ func TestFsMkdirAll(t *testing.T) { is.Equal(err, ErrUnsupported) } +func TestFsChmod(t *testing.T) { + is := is.New(t) + fs, err := newTestFs() + is.NoErr(err) + err = fs.Chmod("test", 0o644) + is.Equal(err, ErrUnsupported) +} + +func TestFsChown(t *testing.T) { + is := is.New(t) + fs, err := newTestFs() + is.NoErr(err) + err = fs.Chown("test", 1000, 1000) + is.Equal(err, ErrUnsupported) +} + +func TestFsChtimes(t *testing.T) { + is := is.New(t) + fs, err := newTestFs() + is.NoErr(err) + now := time.Now() + err = fs.Chtimes("test", now, now) + is.Equal(err, ErrUnsupported) +} + func TestFsStat(t *testing.T) { is := is.New(t) fs, err := newTestFs() |
