| 1 | package embedfsscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/ |
| 2 | |
| 3 | import ( |
| 4 | "embedscip-go gomod github.com/golang/go/src go1.25.0 embed/" |
| 5 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 6 | "ioscip-go gomod github.com/golang/go/src go1.25.0 io/" |
| 7 | iofsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/ "io/fsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/" |
| 8 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 9 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 10 | "testing/fstestscip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/" |
| 11 | |
| 12 | "github.com/go-git/go-billy/v6scip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/" |
| 13 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/" |
| 14 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/" |
| 15 | ) |
| 16 | |
| 17 | //go:embed testdata/empty.txt |
| 18 | var singleFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/singleFile. embedscip-go gomod github.com/golang/go/src go1.25.0 embed/.FSscip-go gomod github.com/golang/go/src go1.25.0 embed/FS# |
| 19 | |
| 20 | //go:embed testdata |
| 21 | var testdataDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/testdataDir. embedscip-go gomod github.com/golang/go/src go1.25.0 embed/.FSscip-go gomod github.com/golang/go/src go1.25.0 embed/FS# |
| 22 | |
| 23 | var emptyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/empty. embedscip-go gomod github.com/golang/go/src go1.25.0 embed/.FSscip-go gomod github.com/golang/go/src go1.25.0 embed/FS# |
| 24 | |
| 25 | func TestOpenscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/TestOpen().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 26 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 27 | |
| 28 | tests := []struct { |
| 29 | name string |
| 30 | want []byte |
| 31 | wantErr bool |
| 32 | }{ |
| 33 | { |
| 34 | name: "testdata/empty.txt", |
| 35 | want: []byte(""), |
| 36 | }, |
| 37 | { |
| 38 | name: "testdata/empty2.txt", |
| 39 | want: []byte("test"), |
| 40 | }, |
| 41 | { |
| 42 | name: "non-existent", |
| 43 | wantErr: true, |
| 44 | }, |
| 45 | } |
| 46 | |
| 47 | for _, tc := range tests { |
| 48 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 49 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 50 | |
| 51 | fs := Newscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/New().(&testdataDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/testdataDir.) |
| 52 | |
| 53 | var got []byte |
| 54 | f, err := fs.Openscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Basic#Open.(tc.name) |
| 55 | if tc.wantErr { |
| 56 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 57 | } else { |
| 58 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 59 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, f) |
| 60 | |
| 61 | got, err = ioscip-go gomod github.com/golang/go/src go1.25.0 io/.ReadAllscip-go gomod github.com/golang/go/src go1.25.0 io/ReadAll().(f) |
| 62 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 63 | } |
| 64 | |
| 65 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, tc.want, got) |
| 66 | }) |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | func TestOpenFileFlagsscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/TestOpenFileFlags().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 71 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 72 | |
| 73 | tests := []struct { |
| 74 | name string |
| 75 | file string |
| 76 | flag int |
| 77 | wantErr string |
| 78 | }{ |
| 79 | { |
| 80 | name: "O_CREATE", |
| 81 | file: "testdata/empty.txt", |
| 82 | flag: osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_CREATEscip-go gomod github.com/golang/go/src go1.25.0 os/O_CREATE., |
| 83 | wantErr: "read-only filesystem", |
| 84 | }, |
| 85 | { |
| 86 | name: "O_WRONLY", |
| 87 | file: "testdata/empty.txt", |
| 88 | flag: osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_WRONLYscip-go gomod github.com/golang/go/src go1.25.0 os/O_WRONLY., |
| 89 | wantErr: "read-only filesystem", |
| 90 | }, |
| 91 | { |
| 92 | name: "O_TRUNC", |
| 93 | file: "testdata/empty.txt", |
| 94 | flag: osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_TRUNCscip-go gomod github.com/golang/go/src go1.25.0 os/O_TRUNC., |
| 95 | wantErr: "read-only filesystem", |
| 96 | }, |
| 97 | { |
| 98 | name: "O_RDWR", |
| 99 | file: "testdata/empty.txt", |
| 100 | flag: osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_RDWRscip-go gomod github.com/golang/go/src go1.25.0 os/O_RDWR., |
| 101 | wantErr: "read-only filesystem", |
| 102 | }, |
| 103 | { |
| 104 | name: "O_EXCL", |
| 105 | file: "testdata/empty.txt", |
| 106 | flag: osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_EXCLscip-go gomod github.com/golang/go/src go1.25.0 os/O_EXCL., |
| 107 | wantErr: "read-only filesystem", |
| 108 | }, |
| 109 | { |
| 110 | name: "O_RDONLY", |
| 111 | file: "testdata/empty.txt", |
| 112 | flag: osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_RDONLYscip-go gomod github.com/golang/go/src go1.25.0 os/O_RDONLY., |
| 113 | }, |
| 114 | { |
| 115 | name: "no flags", |
| 116 | file: "testdata/empty.txt", |
| 117 | }, |
| 118 | } |
| 119 | |
| 120 | for _, tc := range tests { |
| 121 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 122 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 123 | fs := Newscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/New().(&testdataDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/testdataDir.) |
| 124 | |
| 125 | _, err := fs.OpenFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Basic#OpenFile.(tc.file, tc.flag, 0o700) |
| 126 | if tc.wantErr != "" { |
| 127 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorContainsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorContains().(t, err, tc.wantErr) |
| 128 | } else { |
| 129 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 130 | } |
| 131 | }) |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | func TestStatscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/TestStat().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 136 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 137 | |
| 138 | tests := []struct { |
| 139 | name string |
| 140 | want string |
| 141 | isDir bool |
| 142 | wantErr bool |
| 143 | }{ |
| 144 | { |
| 145 | name: "testdata/empty.txt", |
| 146 | want: "empty.txt", |
| 147 | }, |
| 148 | { |
| 149 | name: "testdata/empty2.txt", |
| 150 | want: "empty2.txt", |
| 151 | }, |
| 152 | { |
| 153 | name: "non-existent", |
| 154 | wantErr: true, |
| 155 | }, |
| 156 | { |
| 157 | name: "testdata", |
| 158 | want: "testdata", |
| 159 | isDir: true, |
| 160 | }, |
| 161 | } |
| 162 | |
| 163 | for _, tc := range tests { |
| 164 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 165 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 166 | fs := Newscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/New().(&testdataDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/testdataDir.) |
| 167 | |
| 168 | fi, err := fs.Statscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Basic#Stat.(tc.name) |
| 169 | if tc.wantErr { |
| 170 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 171 | } else { |
| 172 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 173 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, fi) |
| 174 | |
| 175 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, tc.want, fi.Namescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileInfo#Name().()) |
| 176 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, tc.isDir, fi.IsDirscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileInfo#IsDir().()) |
| 177 | } |
| 178 | }) |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | func TestStatClosesOpenedFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/TestStatClosesOpenedFile().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 183 | fsys := &closeCountingFSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#{ |
| 184 | FSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#FS.: fstestscip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/.MapFSscip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/MapFS#{ |
| 185 | "file.txt": &fstestscip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/.MapFilescip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/MapFile#{Datascip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/MapFile#Data.: []byte("content")}, |
| 186 | }, |
| 187 | } |
| 188 | fs := &Embedscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/Embed#{underlyingscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/Embed#underlying.: fsys} |
| 189 | |
| 190 | _, err := fs.Statscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/Embed#Stat().("file.txt") |
| 191 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 192 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, fsys.opensscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#opens., fsys.closesscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#closes.) |
| 193 | } |
| 194 | |
| 195 | func TestOpenFileClosesInternalFilesscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/TestOpenFileClosesInternalFiles().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 196 | tests := []struct { |
| 197 | name string |
| 198 | path string |
| 199 | wantErr string |
| 200 | }{ |
| 201 | { |
| 202 | name: "file", |
| 203 | path: "file.txt", |
| 204 | }, |
| 205 | { |
| 206 | name: "directory", |
| 207 | path: "dir", |
| 208 | wantErr: "cannot open directory", |
| 209 | }, |
| 210 | } |
| 211 | |
| 212 | for _, tc := range tests { |
| 213 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 214 | fsys := &closeCountingFSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#{ |
| 215 | FSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#FS.: fstestscip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/.MapFSscip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/MapFS#{ |
| 216 | "file.txt": &fstestscip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/.MapFilescip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/MapFile#{Datascip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/MapFile#Data.: []byte("content")}, |
| 217 | "dir/file": &fstestscip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/.MapFilescip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/MapFile#{Datascip-go gomod github.com/golang/go/src go1.25.0 `testing/fstest`/MapFile#Data.: []byte("nested")}, |
| 218 | }, |
| 219 | } |
| 220 | fs := &Embedscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/Embed#{underlyingscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/Embed#underlying.: fsys} |
| 221 | |
| 222 | f, err := fs.OpenFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/Embed#OpenFile().(tc.path, osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_RDONLYscip-go gomod github.com/golang/go/src go1.25.0 os/O_RDONLY., 0) |
| 223 | if tc.wantErr != "" { |
| 224 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorContainsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorContains().(t, err, tc.wantErr) |
| 225 | } else { |
| 226 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 227 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, f.Closescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/File#Close().()) |
| 228 | } |
| 229 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, fsys.opensscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#opens., fsys.closesscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#closes.) |
| 230 | }) |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | type closeCountingFSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS# struct { |
| 235 | iofsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/.FSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#FS. |
| 236 | opensscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#opens. int |
| 237 | closesscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#closes. int |
| 238 | } |
| 239 | |
| 240 | func (fs *closeCountingFSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#) Openscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#Open().(name string) (iofsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/.Filescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/File#, error) { |
| 241 | f, err := fs.FSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#FS..Openscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FS#Open().(name) |
| 242 | if err != nil { |
| 243 | return nil, err |
| 244 | } |
| 245 | fs.opensscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#opens.++ |
| 246 | return &closeCountingFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFile#{Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFile#File.: f, fsscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFile#fs.: fs}, nil |
| 247 | } |
| 248 | |
| 249 | type closeCountingFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFile# struct { |
| 250 | iofsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/.Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFile#File. |
| 251 | fsscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFile#fs. *closeCountingFSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS# |
| 252 | } |
| 253 | |
| 254 | func (f *closeCountingFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFile#) Closescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFile#Close().() error { |
| 255 | f.fsscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFile#fs..closesscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFS#closes.++ |
| 256 | return f.Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/closeCountingFile#File..Closescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/File#Close().() |
| 257 | } |
| 258 | |
| 259 | func TestReadDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/TestReadDir().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 260 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 261 | |
| 262 | tests := []struct { |
| 263 | name string |
| 264 | path string |
| 265 | fs *embedscip-go gomod github.com/golang/go/src go1.25.0 embed/.FSscip-go gomod github.com/golang/go/src go1.25.0 embed/FS# |
| 266 | want []string |
| 267 | wantErr bool |
| 268 | }{ |
| 269 | { |
| 270 | name: "singleFile", |
| 271 | path: "testdata", |
| 272 | fs: &singleFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/singleFile., |
| 273 | want: []string{"empty.txt"}, |
| 274 | }, |
| 275 | { |
| 276 | name: "empty", |
| 277 | path: "", |
| 278 | fs: &emptyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/empty., |
| 279 | want: []string{}, |
| 280 | wantErr: true, |
| 281 | }, |
| 282 | { |
| 283 | name: "testdataDir w/ path", |
| 284 | path: "testdata", |
| 285 | fs: &testdataDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/testdataDir., |
| 286 | want: []string{"concurrent.bin", "empty.txt", "empty2.txt"}, |
| 287 | }, |
| 288 | { |
| 289 | name: "testdataDir return no dir names", |
| 290 | path: "", |
| 291 | fs: &testdataDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/testdataDir., |
| 292 | want: []string{}, |
| 293 | wantErr: true, |
| 294 | }, |
| 295 | } |
| 296 | |
| 297 | for _, tc := range tests { |
| 298 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 299 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 300 | fs := Newscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/New().(tc.fs) |
| 301 | |
| 302 | fis, err := fs.ReadDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Dir#ReadDir.(tc.path) |
| 303 | if tc.wantErr { |
| 304 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 305 | } else { |
| 306 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 307 | } |
| 308 | |
| 309 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Lenscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Len().(t, fis, len(tc.want)) |
| 310 | matched := 0 |
| 311 | |
| 312 | for _, n := range fis { |
| 313 | for _, w := range tc.want { |
| 314 | if n.Namescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/DirEntry#Name().() == w { |
| 315 | matched++ |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, len(tc.want), matched, "not all files matched") |
| 321 | }) |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | func TestUnsupportedscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/TestUnsupported().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 326 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 327 | |
| 328 | fs := Newscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/New().(&testdataDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/testdataDir.) |
| 329 | |
| 330 | _, err := fs.Createscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Basic#Create.("test") |
| 331 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorIs().(t, err, billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.ErrReadOnlyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/ErrReadOnly.) |
| 332 | |
| 333 | err = fs.Removescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Basic#Remove.("test") |
| 334 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorIs().(t, err, billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.ErrReadOnlyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/ErrReadOnly.) |
| 335 | |
| 336 | err = fs.Renamescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Basic#Rename.("test", "test") |
| 337 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorIs().(t, err, billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.ErrReadOnlyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/ErrReadOnly.) |
| 338 | |
| 339 | err = fs.MkdirAllscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Dir#MkdirAll.("test", 0o700) |
| 340 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorIs().(t, err, billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.ErrReadOnlyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/ErrReadOnly.) |
| 341 | } |
| 342 | |
| 343 | func TestFileUnsupportedscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/TestFileUnsupported().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 344 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 345 | |
| 346 | fs := Newscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/New().(&testdataDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/testdataDir.) |
| 347 | |
| 348 | f, err := fs.Openscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Basic#Open.("testdata/empty.txt") |
| 349 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 350 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, f) |
| 351 | |
| 352 | _, err = f.Writescip-go gomod github.com/golang/go/src go1.25.0 io/Writer#Write().([]byte("foo")) |
| 353 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorIs().(t, err, billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.ErrReadOnlyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/ErrReadOnly.) |
| 354 | |
| 355 | err = f.Truncatescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/File#Truncate.(0) |
| 356 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorIs().(t, err, billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.ErrReadOnlyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/ErrReadOnly.) |
| 357 | } |
| 358 | |
| 359 | func TestFileSeekscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/TestFileSeek().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 360 | fs := Newscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/New().(&testdataDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/testdataDir.) |
| 361 | |
| 362 | f, err := fs.Openscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Basic#Open.("testdata/empty2.txt") |
| 363 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 364 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, f) |
| 365 | |
| 366 | tests := []struct { |
| 367 | seekOff int64 |
| 368 | seekWhence int |
| 369 | want string |
| 370 | }{ |
| 371 | {seekOff: 3, seekWhence: ioscip-go gomod github.com/golang/go/src go1.25.0 io/.SeekStartscip-go gomod github.com/golang/go/src go1.25.0 io/SeekStart., want: ""}, |
| 372 | {seekOff: 3, seekWhence: ioscip-go gomod github.com/golang/go/src go1.25.0 io/.SeekStartscip-go gomod github.com/golang/go/src go1.25.0 io/SeekStart., want: "t"}, |
| 373 | {seekOff: 2, seekWhence: ioscip-go gomod github.com/golang/go/src go1.25.0 io/.SeekStartscip-go gomod github.com/golang/go/src go1.25.0 io/SeekStart., want: "st"}, |
| 374 | {seekOff: 1, seekWhence: ioscip-go gomod github.com/golang/go/src go1.25.0 io/.SeekStartscip-go gomod github.com/golang/go/src go1.25.0 io/SeekStart., want: "est"}, |
| 375 | {seekOff: 0, seekWhence: ioscip-go gomod github.com/golang/go/src go1.25.0 io/.SeekStartscip-go gomod github.com/golang/go/src go1.25.0 io/SeekStart., want: "test"}, |
| 376 | {seekOff: 0, seekWhence: ioscip-go gomod github.com/golang/go/src go1.25.0 io/.SeekStartscip-go gomod github.com/golang/go/src go1.25.0 io/SeekStart., want: "t"}, |
| 377 | {seekOff: 1, seekWhence: ioscip-go gomod github.com/golang/go/src go1.25.0 io/.SeekCurrentscip-go gomod github.com/golang/go/src go1.25.0 io/SeekCurrent., want: "s"}, |
| 378 | {seekOff: -2, seekWhence: ioscip-go gomod github.com/golang/go/src go1.25.0 io/.SeekEndscip-go gomod github.com/golang/go/src go1.25.0 io/SeekEnd., want: "st"}, |
| 379 | } |
| 380 | |
| 381 | for i, tc := range tests { |
| 382 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("#%d", i), func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 383 | //nolint:tparallel |
| 384 | _, err = f.Seekscip-go gomod github.com/golang/go/src go1.25.0 io/Seeker#Seek().(tc.seekOff, tc.seekWhence) |
| 385 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 386 | |
| 387 | data := make([]byte, len(tc.want)) |
| 388 | n, err := f.Readscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/File#Read().(data) |
| 389 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 390 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, len(tc.want), n) |
| 391 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, []byte(tc.want), data) |
| 392 | }) |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | func TestJoinscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/TestJoin().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 397 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 398 | |
| 399 | tests := []struct { |
| 400 | name string |
| 401 | path []string |
| 402 | want string |
| 403 | }{ |
| 404 | { |
| 405 | name: "no leading slash", |
| 406 | path: []string{"data", "foo/bar"}, |
| 407 | want: "data/foo/bar", |
| 408 | }, |
| 409 | { |
| 410 | name: "w/ leading slash", |
| 411 | path: []string{"/data", "foo/bar"}, |
| 412 | want: "/data/foo/bar", |
| 413 | }, |
| 414 | { |
| 415 | name: "..", |
| 416 | path: []string{"/data", "../bar"}, |
| 417 | want: "/bar", |
| 418 | }, |
| 419 | { |
| 420 | name: ".", |
| 421 | path: []string{"/data", "./bar"}, |
| 422 | want: "/data/bar", |
| 423 | }, |
| 424 | } |
| 425 | |
| 426 | for _, tc := range tests { |
| 427 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 428 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 429 | fs := Newscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/New().(&emptyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/empty.) |
| 430 | |
| 431 | got := fs.Joinscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Basic#Join.(tc.path...) |
| 432 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, tc.want, got) |
| 433 | }) |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | func TestCapabilitiesscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/TestCapabilities().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 438 | fs := Newscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/New().(&testdataDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/embedfs`/testdataDir.) |
| 439 | _, ok := fs.(billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.Capablescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Capable#) |
| 440 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, ok) |
| 441 | |
| 442 | want := billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.ReadCapabilityscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/ReadCapability. | billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.SeekCapabilityscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/SeekCapability. |
| 443 | got := billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.Capabilitiesscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Capabilities().(fs) |
| 444 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, want, got) |
| 445 | } |