mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Merge pull request #960 from codysoyland/simplify-TestCountOpenFiles
Simplify TestCountOpenFiles
This commit is contained in:
commit
c7a2f2c254
1 changed files with 2 additions and 19 deletions
|
|
@ -25,7 +25,6 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sort"
|
||||
|
|
@ -373,26 +372,10 @@ func tempMkdir(t *testing.T) string {
|
|||
// Ensure the file handle count is working
|
||||
func TestCountOpenFiles(t *testing.T) {
|
||||
// Windows is not supported yet
|
||||
supported := []string{"darwin", "linux", "unix", "freebsd"}
|
||||
sort.Strings(supported)
|
||||
i := sort.Search(len(supported),
|
||||
func(i int) bool { return supported[i] >= runtime.GOOS })
|
||||
if i == len(supported) {
|
||||
if runtime.GOOS == "windows" {
|
||||
return
|
||||
}
|
||||
|
||||
// Create directory store temp file
|
||||
testDir := tempMkdir(t)
|
||||
defer os.RemoveAll(testDir)
|
||||
|
||||
count := pilosa.CountOpenFiles()
|
||||
testFile := filepath.Join(testDir, "test.txt")
|
||||
_, err := os.Create(testFile)
|
||||
if err != nil {
|
||||
t.Fatalf("create test file failed: %s", err)
|
||||
}
|
||||
|
||||
if pilosa.CountOpenFiles() < count+1 {
|
||||
if pilosa.CountOpenFiles() == 0 {
|
||||
t.Error("Invalid open file handle count")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue