Merge pull request #960 from codysoyland/simplify-TestCountOpenFiles

Simplify TestCountOpenFiles
This commit is contained in:
Cody Soyland 2017-11-14 15:08:04 -06:00 committed by GitHub
commit c7a2f2c254
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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")
}
}