From 8c809cd29a721a083c82930ac472fe5d40454a38 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Tue, 7 Jun 2016 07:53:00 +0200 Subject: [PATCH] Add additional test for mdadm_linux collector --- collector/fixtures/proc/mdstat_invalid | 5 +++++ collector/mdadm_linux_test.go | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 collector/fixtures/proc/mdstat_invalid diff --git a/collector/fixtures/proc/mdstat_invalid b/collector/fixtures/proc/mdstat_invalid new file mode 100644 index 00000000..c60c77be --- /dev/null +++ b/collector/fixtures/proc/mdstat_invalid @@ -0,0 +1,5 @@ +Personalities : [invalid] +md3 : invalid + 314159265 blocks 64k chunks + +unused devices: diff --git a/collector/mdadm_linux_test.go b/collector/mdadm_linux_test.go index f86a4e0e..ee74af03 100644 --- a/collector/mdadm_linux_test.go +++ b/collector/mdadm_linux_test.go @@ -46,3 +46,11 @@ func TestMdadm(t *testing.T) { t.Errorf("expected number of parsed md-device to be %d, but was %d", len(refs), len(mdStates)) } } + +func TestInvalidMdstat(t *testing.T) { + _, err := parseMdstat("fixtures/proc/mdstat_invalid") + + if err == nil { + t.Fatalf("parsing of invalid reference file did not find any errors") + } +}