Remove redundant assertion and replace regex matches with require

This commit is contained in:
Arshneet Singh
2019-01-23 09:33:22 -08:00
committed by Preetha Appan
parent ec49fff549
commit e6ef8b0e88
2 changed files with 2 additions and 12 deletions

View File

@@ -143,15 +143,8 @@ func TestAllocStatusCommand_Run(t *testing.T) {
t.Fatalf("expected to have 'Modified' but saw: %s", out)
}
if !strings.Contains(out, "Modified") {
t.Fatalf("expected to have 'Modified' but saw: %s", out)
}
nodeNameRegexpStr := fmt.Sprintf(`\nNode Name\s+= %s\n`, regexp.QuoteMeta(nodeName))
nodeNameRegexp := regexp.MustCompile(nodeNameRegexpStr)
if !nodeNameRegexp.MatchString(out) {
t.Fatalf("expected to have 'Node Name' but saw: %s", out)
}
require.Regexp(t, regexp.MustCompile(nodeNameRegexpStr), out)
ui.OutputWriter.Reset()

View File

@@ -155,10 +155,7 @@ func TestJobStatusCommand_Run(t *testing.T) {
nodeNameHeaderStr := "Node Name"
nodeNameHeaderIndex := strings.Index(allocationsTableStr, nodeNameHeaderStr)
nodeNameRegexpStr := fmt.Sprintf(`.*%s.*\n.{%d}%s`, nodeNameHeaderStr, nodeNameHeaderIndex, regexp.QuoteMeta(nodeName))
nodeNameRegexp := regexp.MustCompile(nodeNameRegexpStr)
if !nodeNameRegexp.MatchString(out) {
t.Fatalf("expected to have 'Node Name' but saw: %s", out)
}
require.Regexp(t, regexp.MustCompile(nodeNameRegexpStr), out)
ui.ErrorWriter.Reset()
ui.OutputWriter.Reset()