Skip to content

Commit 384bf14

Browse files
committed
Deprecate info in comparators
The extra info parameter makes it so that all command debugging information is printed-out for every assert. Since command debugging information will now be logged separately, this is now un-necessary. A later PR will change the API and remove the parameter entirely from test.Comparator. Signed-off-by: apostasie <[email protected]>
1 parent 23b8420 commit 384bf14

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

mod/tigron/expect/comparators.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -30,59 +30,59 @@ import (
3030

3131
// All can be used as a parameter for expected.Output to group a set of comparators.
3232
func All(comparators ...test.Comparator) test.Comparator {
33-
return func(stdout, info string, t *testing.T) {
33+
return func(stdout, _ string, t *testing.T) {
3434
t.Helper()
3535

3636
for _, comparator := range comparators {
37-
comparator(stdout, info, t)
37+
comparator(stdout, "", t)
3838
}
3939
}
4040
}
4141

4242
// Contains can be used as a parameter for expected.Output and ensures a comparison string is found contained in the
4343
// output.
4444
func Contains(compare string) test.Comparator {
45-
return func(stdout, info string, t *testing.T) {
45+
return func(stdout, _ string, t *testing.T) {
4646
t.Helper()
47-
assertive.Contains(assertive.WithFailLater(t), stdout, compare, info)
47+
assertive.Contains(assertive.WithFailLater(t), stdout, compare, "Inspecting output (contains)")
4848
}
4949
}
5050

5151
// DoesNotContain is to be used for expected.Output to ensure a comparison string is NOT found in the output.
5252
func DoesNotContain(compare string) test.Comparator {
53-
return func(stdout, info string, t *testing.T) {
53+
return func(stdout, _ string, t *testing.T) {
5454
t.Helper()
55-
assertive.DoesNotContain(assertive.WithFailLater(t), stdout, compare, info)
55+
assertive.DoesNotContain(assertive.WithFailLater(t), stdout, compare, "Inspecting output (does not contain)")
5656
}
5757
}
5858

5959
// Equals is to be used for expected.Output to ensure it is exactly the output.
6060
func Equals(compare string) test.Comparator {
61-
return func(stdout, info string, t *testing.T) {
61+
return func(stdout, _ string, t *testing.T) {
6262
t.Helper()
63-
assertive.IsEqual(assertive.WithFailLater(t), stdout, compare, info)
63+
assertive.IsEqual(assertive.WithFailLater(t), stdout, compare, "Inspecting output (equals)")
6464
}
6565
}
6666

6767
// Match is to be used for expected.Output to ensure we match a regexp.
6868
func Match(reg *regexp.Regexp) test.Comparator {
69-
return func(stdout, info string, t *testing.T) {
69+
return func(stdout, _ string, t *testing.T) {
7070
t.Helper()
71-
assertive.Match(assertive.WithFailLater(t), stdout, reg, info)
71+
assertive.Match(assertive.WithFailLater(t), stdout, reg, "Inspecting output (match)")
7272
}
7373
}
7474

7575
// JSON allows to verify that the output can be marshalled into T, and optionally can be further verified by a provided
7676
// method.
7777
func JSON[T any](obj T, verifier func(T, string, tig.T)) test.Comparator {
78-
return func(stdout, info string, t *testing.T) {
78+
return func(stdout, _ string, t *testing.T) {
7979
t.Helper()
8080

8181
err := json.Unmarshal([]byte(stdout), &obj)
82-
assertive.ErrorIsNil(assertive.WithFailLater(t), err, "failed to unmarshal JSON from stdout")
82+
assertive.ErrorIsNil(assertive.WithSilentSuccess(t), err, "Unmarshalling JSON from stdout must succeed")
8383

8484
if verifier != nil && err == nil {
85-
verifier(obj, info, t)
85+
verifier(obj, "Inspecting output (JSON)", t)
8686
}
8787
}
8888
}

0 commit comments

Comments
 (0)