Fix scanner usage without error handling

This commit is contained in:
Tobias Schmidt 2017-02-28 14:31:35 -04:00
commit 084e585c2a
11 changed files with 33 additions and 38 deletions

View file

@ -13,28 +13,19 @@
package collector
import (
"os"
"testing"
)
import "testing"
func TestFileFDStats(t *testing.T) {
file, err := os.Open("fixtures/proc/sys/fs/file-nr")
if err != nil {
t.Fatal(err)
}
defer file.Close()
fileFDStats, err := parseFileFDStats(file, fileName)
fileFDStats, err := parseFileFDStats("fixtures/proc/sys/fs/file-nr")
if err != nil {
t.Fatal(err)
}
if want, got := "1024", fileFDStats["allocated"]; want != got {
t.Errorf("want filefd allocated %s, got %s", want, got)
t.Errorf("want filefd allocated %q, got %q", want, got)
}
if want, got := "1631329", fileFDStats["maximum"]; want != got {
t.Errorf("want filefd maximum %s, got %s", want, got)
t.Errorf("want filefd maximum %q, got %q", want, got)
}
}