2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-09-28 07:59:27 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package filestore
|
|
|
|
|
2020-06-02 14:00:33 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
2018-09-28 07:59:27 +01:00
|
|
|
|
|
|
|
func TestDiskInfoFromPath(t *testing.T) {
|
|
|
|
info, err := diskInfoFromPath(".")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if info.AvailableSpace <= 0 {
|
|
|
|
t.Fatal("expected to have some disk space")
|
|
|
|
}
|
|
|
|
if info.ID == "" {
|
|
|
|
t.Fatal("didn't get filesystem id")
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Logf("Got: %v %v", info.ID, info.AvailableSpace)
|
|
|
|
}
|
2020-06-02 14:00:33 +01:00
|
|
|
|
|
|
|
func BenchmarkDiskInfoFromPath(b *testing.B) {
|
|
|
|
homedir, err := os.UserHomeDir()
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
b.Run(fmt.Sprintf("dir=%q", homedir), func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_, err = diskInfoFromPath(homedir)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|