@@ -2,34 +2,40 @@ package mpathconfig
22
33// Copyright 2019 Hewlett Packard Enterprise Development LP
44import (
5+ "fmt"
56 "testing"
67)
78
89func TestParseDeviceSection (t * testing.T ) {
910 config , err := ParseConfig ("./multipath_test.conf" )
11+ DeviceType := [2 ]string {"Nimble" , "3PARdata" }
12+
13+ for _ , deviceType := range DeviceType {
1014
11- if err != nil {
12- t .Error (
13- "Parsing multipath.conf failed " , err ,
14- )
15- } else {
16- // config found
17- section , err := config .GetDeviceSection ()
1815 if err != nil {
1916 t .Error (
20- "Parsing nimble device section failed " , err ,
17+ "Parsing multipath.conf failed " , err ,
2118 )
2219 } else {
23- // section found
24- if (section .GetProperties ())["vendor" ] != "\" Nimble\" " {
25- t .Error (
26- "Parsing options from nimble device section failed " , err ,
27- )
28- }
29- if section .GetParent ().GetName () != "devices" {
30- t .Error (
31- "Parent section is not set correctly for nimble device section " , err ,
20+ // config found
21+ section , err := config .GetDeviceSection (deviceType )
22+ if err != nil {
23+ t .Errorf (
24+ "Parsing %s device section failed: %v " , deviceType , err ,
3225 )
26+ } else {
27+ currentDevice := fmt .Sprintf ("\" %s\" " , deviceType )
28+ // section found
29+ if (section .GetProperties ())["vendor" ] != currentDevice {
30+ t .Errorf (
31+ "Parsing options from %s device section failed: %v " , deviceType , err ,
32+ )
33+ }
34+ if section .GetParent ().GetName () != "devices" {
35+ t .Errorf (
36+ "Parent section is not set correctly for %s device section: %v " , deviceType , err ,
37+ )
38+ }
3339 }
3440 }
3541 }
0 commit comments