mirror of
https://gitlab.com/TECHNOFAB/nixtest.git
synced 2026-05-04 18:29:33 +02:00
Compare commits
1 commit
8bbecf896b
...
66f5481225
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66f5481225 |
2 changed files with 16 additions and 9 deletions
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/jedib0t/go-pretty/v6/text"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/sergi/go-diff/diffmatchpatch"
|
||||
"gitlab.com/TECHNOFAB/nixtest/internal/types"
|
||||
"gitlab.com/TECHNOFAB/nixtest/internal/util"
|
||||
)
|
||||
|
|
@ -24,11 +25,17 @@ func PrintErrors(results types.Results, noColor bool) {
|
|||
fmt.Println(text.FgRed.Sprintf("⚠ Test \"%s/%s\" failed:", result.Spec.Suite, result.Spec.Name))
|
||||
message := result.ErrorMessage
|
||||
if result.Status == types.StatusFailure && message == "" {
|
||||
if noColor {
|
||||
var err error
|
||||
message, err = util.ComputeDiff(result.Expected, result.Actual)
|
||||
if err != nil {
|
||||
log.Panic().Err(err).Msg("failed to compute diff")
|
||||
}
|
||||
} else {
|
||||
dmp := diffmatchpatch.New()
|
||||
diffs := dmp.DiffMain(result.Expected, result.Actual, true)
|
||||
message = fmt.Sprintf("Diff:\n%s", dmp.DiffPrettyText(diffs))
|
||||
}
|
||||
}
|
||||
|
||||
if message == "" {
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ function assert_not_eq() {
|
|||
assert "$1 -ne $2" "$3"
|
||||
}
|
||||
function assert_contains() {
|
||||
echo -n "$1" | grep -q -- "$2" || {
|
||||
echo "Assertion failed: $3. The following does not contain $2: $1" >&2;
|
||||
echo "$1" | grep -q -- "$2" || {
|
||||
echo "Assertion failed: $3. $1 does not contain $2" >&2;
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
function assert_not_contains() {
|
||||
echo -n "$1" | grep -q -- "$2" && {
|
||||
echo "Assertion failed: $3. The following does contain $2: $1" >&2;
|
||||
echo "$1" | grep -q -- "$2" && {
|
||||
echo "Assertion failed: $3. $1 does contain $2" >&2;
|
||||
exit 1;
|
||||
} || true
|
||||
}
|
||||
}
|
||||
function assert_file_contains() {
|
||||
grep -q -- "$2" $1 || {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue