mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
Remove redundant assertion and replace regex matches with require
This commit is contained in:
committed by
Preetha Appan
parent
ec49fff549
commit
e6ef8b0e88
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user