From 1abd2a5376eae7b7e919239a7a42f902b312631a Mon Sep 17 00:00:00 2001 From: David Dworken Date: Tue, 20 Sep 2022 23:46:17 -0700 Subject: [PATCH] Fix table format tests --- client/client_test.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index 134121a..4ab0108 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -317,18 +317,28 @@ echo thisisrecorded`) hostnameMatcher := `\S+` tableDividerMatcher := `\s+` pathMatcher := `~?/[a-zA-Z_0-9/-]+` - datetimeMatcher := `[a-zA-Z]{3}\s\d{2}\s\d{4}\s[0-9:]+\s[A-Z]{3}` + datetimeMatcher := `[a-zA-Z]{3}\s\d{2}\s\d{4}\s[0-9:]+\s([A-Z]{3}|[+-]\d{4})` runtimeMatcher := `[0-9.ms]+` exitCodeMatcher := `0` pipefailMatcher := `set -em?o pipefail` - line1Matcher := tableDividerMatcher + `Hostname` + tableDividerMatcher + `CWD` + tableDividerMatcher + `Timestamp` + tableDividerMatcher + `Runtime` + tableDividerMatcher + `Exit Code` + tableDividerMatcher + `Command` + tableDividerMatcher + `\n` - line2Matcher := tableDividerMatcher + hostnameMatcher + tableDividerMatcher + pathMatcher + tableDividerMatcher + datetimeMatcher + tableDividerMatcher + runtimeMatcher + tableDividerMatcher + exitCodeMatcher + tableDividerMatcher + pipefailMatcher + tableDividerMatcher + `\n` - line3Matcher := tableDividerMatcher + hostnameMatcher + tableDividerMatcher + pathMatcher + tableDividerMatcher + datetimeMatcher + tableDividerMatcher + runtimeMatcher + tableDividerMatcher + exitCodeMatcher + tableDividerMatcher + `echo thisisrecorded` + tableDividerMatcher + `\n` + line1Matcher := `Hostname` + tableDividerMatcher + `CWD` + tableDividerMatcher + `Timestamp` + tableDividerMatcher + `Runtime` + tableDividerMatcher + `Exit Code` + tableDividerMatcher + `Command\s*\n` + line2Matcher := hostnameMatcher + tableDividerMatcher + pathMatcher + tableDividerMatcher + datetimeMatcher + tableDividerMatcher + runtimeMatcher + tableDividerMatcher + exitCodeMatcher + tableDividerMatcher + pipefailMatcher + tableDividerMatcher + `\n` + line3Matcher := hostnameMatcher + tableDividerMatcher + pathMatcher + tableDividerMatcher + datetimeMatcher + tableDividerMatcher + runtimeMatcher + tableDividerMatcher + exitCodeMatcher + tableDividerMatcher + `echo thisisrecorded` + tableDividerMatcher + `\n` match, err := regexp.MatchString(line3Matcher, out) shared.Check(t, err) if !match { t.Fatalf("output is missing the row for `echo thisisrecorded`: %v", out) } + match, err = regexp.MatchString(line1Matcher, out) + shared.Check(t, err) + if !match { + t.Fatalf("output is missing the headings: %v", out) + } + match, err = regexp.MatchString(line2Matcher, out) + shared.Check(t, err) + if !match { + t.Fatalf("output is missing the pipefail: %v", out) + } match, err = regexp.MatchString(line1Matcher+line2Matcher+line3Matcher, out) shared.Check(t, err) if !match {