//go:build linux package assetcache import ( "path/filepath" "testing" ) // TestStatfsReportsTheTempDir is the acceptance test for the real FS: it asks // the kernel about a real directory. func TestStatfsReportsTheTempDir(t *testing.T) { total, free, err := Statfs.Space(t.TempDir()) if err != nil { t.Fatal(err) } if total == 0 { t.Fatal("total = 0, want the filesystem's size") } if free > total { t.Fatalf("free %d > total %d", free, total) } } // TestStatfsFailsOnAMissingDirectory asks the kernel about a directory that // does not exist: the real FS returns the error and no totals. func TestStatfsFailsOnAMissingDirectory(t *testing.T) { total, free, err := Statfs.Space(filepath.Join(t.TempDir(), "missing")) if err == nil { t.Fatal("Space of a missing directory succeeded") } if total != 0 || free != 0 { t.Fatalf("Space of a missing directory = %d, %d, want 0, 0 with the error", total, free) } }