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