Fix config parsing test

Went overboard before I realized there's only one test case.
This commit is contained in:
Michael Schurter
2017-05-30 11:39:26 -07:00
parent f6ea22302c
commit f2476cfa67

View File

@@ -3,10 +3,12 @@ package agent
import (
"path/filepath"
"reflect"
"strings"
"testing"
"time"
"github.com/hashicorp/nomad/nomad/structs/config"
"github.com/kr/pretty"
)
func TestConfig_Parse(t *testing.T) {
@@ -75,6 +77,7 @@ func TestConfig_Parse(t *testing.T) {
GCParallelDestroys: 6,
GCDiskUsageThreshold: 82,
GCInodeUsageThreshold: 91,
GCMaxAllocs: 50,
NoHostUUID: true,
},
Server: &ServerConfig{
@@ -165,22 +168,20 @@ func TestConfig_Parse(t *testing.T) {
}
for _, tc := range cases {
t.Logf("Testing parse: %s", tc.File)
t.Run(tc.File, func(t *testing.T) {
path, err := filepath.Abs(filepath.Join("./config-test-fixtures", tc.File))
if err != nil {
t.Fatalf("file: %s\n\n%s", tc.File, err)
}
path, err := filepath.Abs(filepath.Join("./config-test-fixtures", tc.File))
if err != nil {
t.Fatalf("file: %s\n\n%s", tc.File, err)
continue
}
actual, err := ParseConfigFile(path)
if (err != nil) != tc.Err {
t.Fatalf("file: %s\n\n%s", tc.File, err)
}
actual, err := ParseConfigFile(path)
if (err != nil) != tc.Err {
t.Fatalf("file: %s\n\n%s", tc.File, err)
continue
}
if !reflect.DeepEqual(actual, tc.Result) {
t.Fatalf("file: %s\n\n%#v\n\n%#v", tc.File, actual, tc.Result)
}
if !reflect.DeepEqual(actual, tc.Result) {
t.Errorf("file: %s diff: (actual vs expected)\n\n%s", tc.File, strings.Join(pretty.Diff(actual, tc.Result), "\n"))
}
})
}
}