MCPcopy Create free account
hub / github.com/tailscale/tailscale / createFileSystem

Function createFileSystem

drive/driveimpl/dirfs/dirfs_test.go:279–323  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

277}
278
279func createFileSystem(t *testing.T) (webdav.FileSystem, string, string, *tstest.Clock) {
280 s1, dir1 := startRemote(t)
281 s2, dir2 := startRemote(t)
282
283 // Make some files, use perms 0666 as lowest common denominator that works
284 // on both UNIX and Windows.
285 err := os.WriteFile(filepath.Join(dir1, "file1.txt"), []byte("12345"), 0666)
286 if err != nil {
287 t.Fatal(err)
288 }
289 err = os.WriteFile(filepath.Join(dir2, "file2.txt"), []byte("54321"), 0666)
290 if err != nil {
291 t.Fatal(err)
292 }
293
294 // make some directories
295 err = os.Mkdir(filepath.Join(dir1, "dir1"), 0666)
296 if err != nil {
297 t.Fatal(err)
298 }
299 err = os.Mkdir(filepath.Join(dir2, "dir2"), 0666)
300 if err != nil {
301 t.Fatal(err)
302 }
303
304 clock := tstest.NewClock(tstest.ClockOpts{Start: time.Now()})
305 fs := &FS{
306 Clock: clock,
307 StaticRoot: "domain",
308 Children: []*Child{
309 {Name: "remote1"},
310 {Name: "remote2"},
311 {Name: "remote4"},
312 },
313 }
314
315 t.Cleanup(func() {
316 defer s1.Close()
317 defer os.RemoveAll(dir1)
318 defer s2.Close()
319 defer os.RemoveAll(dir2)
320 })
321
322 return fs, dir1, dir2, clock
323}
324
325func startRemote(t *testing.T) (*httptest.Server, string) {
326 dir := t.TempDir()

Callers 5

TestStatFunction · 0.85
TestListDirFunction · 0.85
TestMkdirFunction · 0.85
TestRemoveAllFunction · 0.85
TestRenameFunction · 0.85

Calls 9

NewClockFunction · 0.92
startRemoteFunction · 0.85
MkdirMethod · 0.80
WriteFileMethod · 0.65
FatalMethod · 0.65
NowMethod · 0.65
CleanupMethod · 0.65
CloseMethod · 0.65
RemoveAllMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…