collector: add bounds check and test for filesystem collector (#1133)
Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
parent
bdc0e7e678
commit
c0a55e3f80
2 changed files with 35 additions and 2 deletions
|
|
@ -16,11 +16,32 @@
|
|||
package collector
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func Test_parseFilesystemLabelsError(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
in string
|
||||
}{
|
||||
{
|
||||
name: "too few fields",
|
||||
in: "hello world",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if _, err := parseFilesystemLabels(strings.NewReader(tt.in)); err == nil {
|
||||
t.Fatal("expected an error, but none occurred")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMountPointDetails(t *testing.T) {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--path.procfs", "./fixtures/proc"}); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue