Skip to content

Commit c7d90f1

Browse files
committed
Remove deprecated info parameter
Signed-off-by: apostasie <[email protected]>
1 parent 1673252 commit c7d90f1

File tree

6 files changed

+25
-26
lines changed

6 files changed

+25
-26
lines changed

mod/tigron/expect/comparators.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ 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, _ string, t *testing.T) {
33+
return func(stdout string, t *testing.T) {
3434
t.Helper()
3535

3636
for _, comparator := range comparators {
37-
comparator(stdout, "", 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, more ...string) test.Comparator {
45-
return func(stdout, _ string, t *testing.T) {
45+
return func(stdout string, t *testing.T) {
4646
t.Helper()
4747

4848
assertive.Contains(assertive.WithFailLater(t), stdout, compare, "Inspecting output (contains)")
@@ -55,7 +55,7 @@ func Contains(compare string, more ...string) test.Comparator {
5555

5656
// DoesNotContain is to be used for expected.Output to ensure a comparison string is NOT found in the output.
5757
func DoesNotContain(compare string, more ...string) test.Comparator {
58-
return func(stdout, _ string, t *testing.T) {
58+
return func(stdout string, t *testing.T) {
5959
t.Helper()
6060

6161
assertive.DoesNotContain(assertive.WithFailLater(t), stdout, compare, "Inspecting output (does not contain)")
@@ -68,31 +68,31 @@ func DoesNotContain(compare string, more ...string) test.Comparator {
6868

6969
// Equals is to be used for expected.Output to ensure it is exactly the output.
7070
func Equals(compare string) test.Comparator {
71-
return func(stdout, _ string, t *testing.T) {
71+
return func(stdout string, t *testing.T) {
7272
t.Helper()
7373
assertive.IsEqual(assertive.WithFailLater(t), stdout, compare, "Inspecting output (equals)")
7474
}
7575
}
7676

7777
// Match is to be used for expected.Output to ensure we match a regexp.
7878
func Match(reg *regexp.Regexp) test.Comparator {
79-
return func(stdout, _ string, t *testing.T) {
79+
return func(stdout string, t *testing.T) {
8080
t.Helper()
8181
assertive.Match(assertive.WithFailLater(t), stdout, reg, "Inspecting output (match)")
8282
}
8383
}
8484

8585
// JSON allows to verify that the output can be marshalled into T, and optionally can be further verified by a provided
8686
// method.
87-
func JSON[T any](obj T, verifier func(T, string, tig.T)) test.Comparator {
88-
return func(stdout, _ string, t *testing.T) {
87+
func JSON[T any](obj T, verifier func(T, tig.T)) test.Comparator {
88+
return func(stdout string, t *testing.T) {
8989
t.Helper()
9090

9191
err := json.Unmarshal([]byte(stdout), &obj)
9292
assertive.ErrorIsNil(assertive.WithSilentSuccess(t), err, "Unmarshalling JSON from stdout must succeed")
9393

9494
if verifier != nil && err == nil {
95-
verifier(obj, "Inspecting output (JSON)", t)
95+
verifier(obj, t)
9696
}
9797
}
9898
}

mod/tigron/expect/comparators_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ func TestExpect(t *testing.T) {
3333
// TODO: write more tests once we can mock t in Comparator signature
3434
t.Parallel()
3535

36-
expect.Contains("b")("a b c", "contains works", t)
37-
expect.DoesNotContain("d")("a b c", "does not contain works", t)
38-
expect.Equals("a b c")("a b c", "equals work", t)
39-
expect.Match(regexp.MustCompile("[a-z ]+"))("a b c", "match works", t)
36+
expect.Contains("b")("a b c", t)
37+
expect.DoesNotContain("d")("a b c", t)
38+
expect.Equals("a b c")("a b c", t)
39+
expect.Match(regexp.MustCompile("[a-z ]+"))("a b c", t)
4040

4141
expect.All(
4242
expect.Contains("b"),
@@ -45,7 +45,7 @@ func TestExpect(t *testing.T) {
4545
expect.DoesNotContain("d", "e"),
4646
expect.Equals("a b c"),
4747
expect.Match(regexp.MustCompile("[a-z ]+")),
48-
)("a b c", "all", t)
48+
)("a b c", t)
4949

5050
type foo struct {
5151
Foo map[string]string `json:"foo"`
@@ -59,9 +59,9 @@ func TestExpect(t *testing.T) {
5959

6060
assertive.ErrorIsNil(t, err)
6161

62-
expect.JSON(&foo{}, nil)(string(data), "json, no verifier", t)
62+
expect.JSON(&foo{}, nil)(string(data), t)
6363

64-
expect.JSON(&foo{}, func(obj *foo, info string, t tig.T) {
65-
assertive.IsEqual(t, obj.Foo["foo"], "bar", info)
66-
})(string(data), "json, with verifier", t)
64+
expect.JSON(&foo{}, func(obj *foo, t tig.T) {
65+
assertive.IsEqual(t, obj.Foo["foo"], "bar")
66+
})(string(data), t)
6767
}

mod/tigron/expect/doc.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The following ready-made `test.Comparator` generators are provided:
5858
- `expect.Equals(string)`: strict equality
5959
- `expect.Match(*regexp.Regexp)`: regexp matching
6060
- `expect.All(comparators ...Comparator)`: allows to bundle together a bunch of other comparators
61-
- `expect.JSON[T any](obj T, verifier func(T, string, tig.T))`: allows to verify the output is valid JSON and optionally
61+
- `expect.JSON[T any](obj T, verifier func(T, tig.T))`: allows to verify the output is valid JSON and optionally
6262
pass `verifier(T, string, tig.T)` extra validation
6363

6464
### A complete example
@@ -93,8 +93,8 @@ func TestMyThing(t *testing.T) {
9393
expect.All(
9494
expect.Contains("out"),
9595
expect.DoesNotContain("something"),
96-
expect.JSON(&Thing{}, func(obj *Thing, info string, t tig.T) {
97-
assert.Equal(t, obj.Name, "something", info)
96+
expect.JSON(&Thing{}, func(obj *Thing, t tig.T) {
97+
assert.Equal(t, obj.Name, "something")
9898
}),
9999
),
100100
)
@@ -206,11 +206,11 @@ func TestMyThing(t *testing.T) {
206206
Errors: []error{
207207
errors.New("foobla"),
208208
},
209-
Output: func(stdout, info string, t tig.T) {
209+
Output: func(stdout string, t tig.T) {
210210
t.Helper()
211211

212212
// Retrieve the data that was set during the Setup phase.
213-
assert.Assert(t, stdout == data.Labels().Get("sometestdata"), info)
213+
assert.Assert(t, stdout == data.Labels().Get("sometestdata"))
214214
},
215215
}
216216
}

mod/tigron/test/command.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ func (gc *GenericCommand) Run(expect *Expected) {
294294
if expect.Output != nil {
295295
expect.Output(
296296
result.Stdout,
297-
"",
298297
gc.t,
299298
)
300299
}

mod/tigron/test/funct.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Butler func(data Data, helpers Helpers)
3030
// - move to tig.T
3131

3232
// A Comparator is the function signature to implement for the Output property of an Expected.
33-
type Comparator func(stdout, info string, t *testing.T)
33+
type Comparator func(stdout string, t *testing.T)
3434

3535
// A Manager is the function signature meant to produce expectations for a command.
3636
type Manager func(data Data, helpers Helpers) *Expected

mod/tigron/test/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (help *helpersInternal) Capture(args ...string) string {
6161
help.t.Helper()
6262
help.Command(args...).Run(&Expected{
6363
//nolint:thelper
64-
Output: func(stdout, _ string, _ *testing.T) {
64+
Output: func(stdout string, _ *testing.T) {
6565
ret = stdout
6666
},
6767
})

0 commit comments

Comments
 (0)