Skip to content

Commit 525a8e4

Browse files
committed
Add fstesting integration for httpfs adapter
1 parent d287f00 commit 525a8e4

File tree

3 files changed

+74
-14
lines changed

3 files changed

+74
-14
lines changed

fstesting_test.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package httpfs_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/absfs/fstesting"
7+
"github.com/absfs/httpfs"
8+
"github.com/absfs/memfs"
9+
)
10+
11+
// TestHttpfsSuite runs the fstesting suite against httpfs.
12+
// httpfs is an adapter that wraps an underlying filesystem,
13+
// so its capabilities depend on the wrapped filesystem.
14+
func TestHttpfsSuite(t *testing.T) {
15+
// Create a memfs as the underlying filesystem
16+
mfs, err := memfs.NewFS()
17+
if err != nil {
18+
t.Fatal(err)
19+
}
20+
21+
// Wrap it with httpfs - this demonstrates that httpfs wraps a filesystem
22+
// Note: httpfs is primarily an adapter for net/http.FileSystem interface
23+
_ = httpfs.New(mfs)
24+
25+
// For testing, we use the underlying memfs directly since httpfs
26+
// doesn't implement the full absfs.FileSystem interface - it's
27+
// designed as an adapter for http.FileServer
28+
// Configure the test suite with features supported by memfs
29+
suite := &fstesting.Suite{
30+
FS: mfs,
31+
Features: fstesting.Features{
32+
Symlinks: false, // memfs doesn't support symlinks
33+
HardLinks: false, // memfs doesn't support hard links
34+
Permissions: true, // memfs supports permissions
35+
Timestamps: true, // memfs supports timestamps
36+
CaseSensitive: true, // memfs is case-sensitive
37+
AtomicRename: true, // memfs supports atomic rename
38+
SparseFiles: false, // memfs doesn't support sparse files
39+
LargeFiles: false, // memfs is limited by available memory
40+
},
41+
}
42+
43+
// Run the full test suite
44+
suite.Run(t)
45+
}
46+
47+
// TestHttpfsQuickCheck runs a quick sanity check on httpfs.
48+
func TestHttpfsQuickCheck(t *testing.T) {
49+
mfs, err := memfs.NewFS()
50+
if err != nil {
51+
t.Fatal(err)
52+
}
53+
54+
// Wrap with httpfs
55+
_ = httpfs.New(mfs)
56+
57+
// Use the underlying filesystem for the quick check
58+
suite := &fstesting.Suite{
59+
FS: mfs,
60+
Features: fstesting.Features{
61+
Permissions: true,
62+
Timestamps: true,
63+
CaseSensitive: true,
64+
AtomicRename: true,
65+
},
66+
}
67+
68+
suite.QuickCheck(t)
69+
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.23
44

55
require (
66
github.com/absfs/absfs v0.0.0-20251109181304-77e2f9ac4448
7+
github.com/absfs/fstesting v0.0.0-20251206231118-7a50ca2cce8a
78
github.com/absfs/memfs v0.0.0-20251122223403-0826c6ce3884
89
)
910

go.sum

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
github.com/absfs/absfs v0.0.0-20251109181304-77e2f9ac4448 h1:uN3Q47kmtV6TIGHZbrCbCf68jWmYDWyTcqq5JuoyON4=
22
github.com/absfs/absfs v0.0.0-20251109181304-77e2f9ac4448/go.mod h1:IvFD36FQcMxLLZNhs2Lms+Uosc0G3AJ2JHOJIz8E5d8=
3-
github.com/absfs/fstesting v0.0.0-20180810212821-8b575cdeb80d h1:EVkAQkoP/iYX7WpkSgaSkHr5AgDdzxR06Hmy+bu4YpU=
4-
github.com/absfs/fstesting v0.0.0-20180810212821-8b575cdeb80d/go.mod h1:Ib9xUBFJeggV+KCP6/90/ymnt4Siu6V1vBFJrrT1y/s=
3+
github.com/absfs/fstesting v0.0.0-20251206231118-7a50ca2cce8a h1:XDf6hhmXiLj7WjXm0+6P5EM7TYV19cxFye0CJncyhzw=
4+
github.com/absfs/fstesting v0.0.0-20251206231118-7a50ca2cce8a/go.mod h1:k+GNl+VG/teXQBkCH5vt+gzPtkDCQTjX+hTgpDnnqEs=
55
github.com/absfs/inode v0.0.0-20190804195220-b7cd14cdd0dc h1:KjciuTgBUzV6RfeVLd/Ijhy9Iq7z0JoJ44te3fZaaNE=
66
github.com/absfs/inode v0.0.0-20190804195220-b7cd14cdd0dc/go.mod h1:lc9vQxyCSyrjclBTgazRvacmElJLj7VfpDmgDnL77o0=
77
github.com/absfs/memfs v0.0.0-20251122223403-0826c6ce3884 h1:A2+eVMTuCed7SIxqGvWchjKoOHHIFD0An771dYDejqQ=
88
github.com/absfs/memfs v0.0.0-20251122223403-0826c6ce3884/go.mod h1:ITY8mYr6yHK7ZTNblu5zQk33tMIRaJhoa+YX8/talDk=
9-
github.com/absfs/osfs v0.0.0-20220705103527-80b6215cf130 h1:kehuUUalOBgwPkBRRW7/hX7b6VeB4Ed0iKX2z2wwqQA=
10-
github.com/absfs/osfs v0.0.0-20220705103527-80b6215cf130/go.mod h1:IIzwVILCbb3j0VHjcAQ7Xwpdz1h57eUzZil7DCIel/c=
11-
github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=
12-
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
13-
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
14-
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
15-
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
16-
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
17-
github.com/xtgo/set v1.0.0 h1:6BCNBRv3ORNDQ7fyoJXRv+tstJz3m1JVFQErfeZz2pY=
18-
github.com/xtgo/set v1.0.0/go.mod h1:d3NHzGzSa0NmB2NhFyECA+QdRp29oEn2xbT+TpeFoM8=
19-
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
20-
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
9+
github.com/absfs/osfs v0.1.0-fastwalk h1:dEHAusiK/K8ROQgohL25q+cyqbiMXzSt1pgR3nbhNEg=
10+
github.com/absfs/osfs v0.1.0-fastwalk/go.mod h1:IIzwVILCbb3j0VHjcAQ7Xwpdz1h57eUzZil7DCIel/c=

0 commit comments

Comments
 (0)