Skip to content

Commit ab6dc32

Browse files
mvrahdenboyan-soubachov
authored andcommitted
fix linting errors in /assert package
1 parent edff5a0 commit ab6dc32

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

assert/assertion_compare_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func TestGreater(t *testing.T) {
150150
} {
151151
out := &outputT{buf: bytes.NewBuffer(nil)}
152152
False(t, Greater(out, currCase.less, currCase.greater))
153-
Contains(t, string(out.buf.Bytes()), currCase.msg)
153+
Contains(t, out.buf.String(), currCase.msg)
154154
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Greater")
155155
}
156156
}
@@ -191,7 +191,7 @@ func TestGreaterOrEqual(t *testing.T) {
191191
} {
192192
out := &outputT{buf: bytes.NewBuffer(nil)}
193193
False(t, GreaterOrEqual(out, currCase.less, currCase.greater))
194-
Contains(t, string(out.buf.Bytes()), currCase.msg)
194+
Contains(t, out.buf.String(), currCase.msg)
195195
Contains(t, out.helpers, "github.com/stretchr/testify/assert.GreaterOrEqual")
196196
}
197197
}
@@ -232,7 +232,7 @@ func TestLess(t *testing.T) {
232232
} {
233233
out := &outputT{buf: bytes.NewBuffer(nil)}
234234
False(t, Less(out, currCase.greater, currCase.less))
235-
Contains(t, string(out.buf.Bytes()), currCase.msg)
235+
Contains(t, out.buf.String(), currCase.msg)
236236
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Less")
237237
}
238238
}
@@ -273,7 +273,7 @@ func TestLessOrEqual(t *testing.T) {
273273
} {
274274
out := &outputT{buf: bytes.NewBuffer(nil)}
275275
False(t, LessOrEqual(out, currCase.greater, currCase.less))
276-
Contains(t, string(out.buf.Bytes()), currCase.msg)
276+
Contains(t, out.buf.String(), currCase.msg)
277277
Contains(t, out.helpers, "github.com/stretchr/testify/assert.LessOrEqual")
278278
}
279279
}
@@ -312,7 +312,7 @@ func TestPositive(t *testing.T) {
312312
} {
313313
out := &outputT{buf: bytes.NewBuffer(nil)}
314314
False(t, Positive(out, currCase.e))
315-
Contains(t, string(out.buf.Bytes()), currCase.msg)
315+
Contains(t, out.buf.String(), currCase.msg)
316316
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Positive")
317317
}
318318
}
@@ -351,7 +351,7 @@ func TestNegative(t *testing.T) {
351351
} {
352352
out := &outputT{buf: bytes.NewBuffer(nil)}
353353
False(t, Negative(out, currCase.e))
354-
Contains(t, string(out.buf.Bytes()), currCase.msg)
354+
Contains(t, out.buf.String(), currCase.msg)
355355
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Negative")
356356
}
357357
}
@@ -386,7 +386,7 @@ func Test_compareTwoValuesNotComparableValues(t *testing.T) {
386386
}{
387387
{v1: CompareStruct{}, v2: CompareStruct{}},
388388
{v1: map[string]int{}, v2: map[string]int{}},
389-
{v1: make([]int, 5, 5), v2: make([]int, 5, 5)},
389+
{v1: make([]int, 5), v2: make([]int, 5)},
390390
} {
391391
compareResult := compareTwoValues(mockT, currCase.v1, currCase.v2, []CompareType{compareLess, compareEqual, compareGreater}, "testFailMessage")
392392
False(t, compareResult)

assert/assertion_order_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestIsIncreasing(t *testing.T) {
4646
} {
4747
out := &outputT{buf: bytes.NewBuffer(nil)}
4848
False(t, IsIncreasing(out, currCase.collection))
49-
Contains(t, string(out.buf.Bytes()), currCase.msg)
49+
Contains(t, out.buf.String(), currCase.msg)
5050
}
5151
}
5252

@@ -91,7 +91,7 @@ func TestIsNonIncreasing(t *testing.T) {
9191
} {
9292
out := &outputT{buf: bytes.NewBuffer(nil)}
9393
False(t, IsNonIncreasing(out, currCase.collection))
94-
Contains(t, string(out.buf.Bytes()), currCase.msg)
94+
Contains(t, out.buf.String(), currCase.msg)
9595
}
9696
}
9797

@@ -136,7 +136,7 @@ func TestIsDecreasing(t *testing.T) {
136136
} {
137137
out := &outputT{buf: bytes.NewBuffer(nil)}
138138
False(t, IsDecreasing(out, currCase.collection))
139-
Contains(t, string(out.buf.Bytes()), currCase.msg)
139+
Contains(t, out.buf.String(), currCase.msg)
140140
}
141141
}
142142

@@ -181,6 +181,6 @@ func TestIsNonDecreasing(t *testing.T) {
181181
} {
182182
out := &outputT{buf: bytes.NewBuffer(nil)}
183183
False(t, IsNonDecreasing(out, currCase.collection))
184-
Contains(t, string(out.buf.Bytes()), currCase.msg)
184+
Contains(t, out.buf.String(), currCase.msg)
185185
}
186186
}

assert/assertions.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{})
856856
h.Helper()
857857
}
858858
if subset == nil {
859-
return Fail(t, fmt.Sprintf("nil is the empty set which is a subset of every set"), msgAndArgs...)
859+
return Fail(t, "nil is the empty set which is a subset of every set", msgAndArgs...)
860860
}
861861

862862
subsetValue := reflect.ValueOf(subset)
@@ -1165,15 +1165,15 @@ func InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs
11651165
bf, bok := toFloat(actual)
11661166

11671167
if !aok || !bok {
1168-
return Fail(t, fmt.Sprintf("Parameters must be numerical"), msgAndArgs...)
1168+
return Fail(t, "Parameters must be numerical", msgAndArgs...)
11691169
}
11701170

11711171
if math.IsNaN(af) && math.IsNaN(bf) {
11721172
return true
11731173
}
11741174

11751175
if math.IsNaN(af) {
1176-
return Fail(t, fmt.Sprintf("Expected must not be NaN"), msgAndArgs...)
1176+
return Fail(t, "Expected must not be NaN", msgAndArgs...)
11771177
}
11781178

11791179
if math.IsNaN(bf) {
@@ -1196,7 +1196,7 @@ func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAn
11961196
if expected == nil || actual == nil ||
11971197
reflect.TypeOf(actual).Kind() != reflect.Slice ||
11981198
reflect.TypeOf(expected).Kind() != reflect.Slice {
1199-
return Fail(t, fmt.Sprintf("Parameters must be slice"), msgAndArgs...)
1199+
return Fail(t, "Parameters must be slice", msgAndArgs...)
12001200
}
12011201

12021202
actualSlice := reflect.ValueOf(actual)
@@ -1306,7 +1306,7 @@ func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, m
13061306
if expected == nil || actual == nil ||
13071307
reflect.TypeOf(actual).Kind() != reflect.Slice ||
13081308
reflect.TypeOf(expected).Kind() != reflect.Slice {
1309-
return Fail(t, fmt.Sprintf("Parameters must be slice"), msgAndArgs...)
1309+
return Fail(t, "Parameters must be slice", msgAndArgs...)
13101310
}
13111311

13121312
actualSlice := reflect.ValueOf(actual)

assert/assertions_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,8 +1575,7 @@ func testAutogeneratedFunction() {
15751575
t := struct {
15761576
io.Closer
15771577
}{}
1578-
var c io.Closer
1579-
c = t
1578+
c := t
15801579
c.Close()
15811580
}
15821581

@@ -2224,7 +2223,7 @@ func ExampleValueAssertionFunc() {
22242223

22252224
dumbParse := func(input string) interface{} {
22262225
var x interface{}
2227-
json.Unmarshal([]byte(input), &x)
2226+
_ = json.Unmarshal([]byte(input), &x)
22282227
return x
22292228
}
22302229

assert/http_assertions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func TestHTTPStatusesWrapper(t *testing.T) {
122122

123123
func httpHelloName(w http.ResponseWriter, r *http.Request) {
124124
name := r.FormValue("name")
125-
w.Write([]byte(fmt.Sprintf("Hello, %s!", name)))
125+
_, _ = w.Write([]byte(fmt.Sprintf("Hello, %s!", name)))
126126
}
127127

128128
func TestHTTPRequestWithNoParams(t *testing.T) {

0 commit comments

Comments
 (0)