Skip to content

Commit

Permalink
fix linting errors in /assert package
Browse files Browse the repository at this point in the history
  • Loading branch information
mvrahden authored and boyan-soubachov committed Aug 24, 2021
1 parent edff5a0 commit ab6dc32
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
14 changes: 7 additions & 7 deletions assert/assertion_compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func TestGreater(t *testing.T) {
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, Greater(out, currCase.less, currCase.greater))
Contains(t, string(out.buf.Bytes()), currCase.msg)
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Greater")
}
}
Expand Down Expand Up @@ -191,7 +191,7 @@ func TestGreaterOrEqual(t *testing.T) {
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, GreaterOrEqual(out, currCase.less, currCase.greater))
Contains(t, string(out.buf.Bytes()), currCase.msg)
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.GreaterOrEqual")
}
}
Expand Down Expand Up @@ -232,7 +232,7 @@ func TestLess(t *testing.T) {
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, Less(out, currCase.greater, currCase.less))
Contains(t, string(out.buf.Bytes()), currCase.msg)
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Less")
}
}
Expand Down Expand Up @@ -273,7 +273,7 @@ func TestLessOrEqual(t *testing.T) {
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, LessOrEqual(out, currCase.greater, currCase.less))
Contains(t, string(out.buf.Bytes()), currCase.msg)
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.LessOrEqual")
}
}
Expand Down Expand Up @@ -312,7 +312,7 @@ func TestPositive(t *testing.T) {
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, Positive(out, currCase.e))
Contains(t, string(out.buf.Bytes()), currCase.msg)
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Positive")
}
}
Expand Down Expand Up @@ -351,7 +351,7 @@ func TestNegative(t *testing.T) {
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, Negative(out, currCase.e))
Contains(t, string(out.buf.Bytes()), currCase.msg)
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Negative")
}
}
Expand Down Expand Up @@ -386,7 +386,7 @@ func Test_compareTwoValuesNotComparableValues(t *testing.T) {
}{
{v1: CompareStruct{}, v2: CompareStruct{}},
{v1: map[string]int{}, v2: map[string]int{}},
{v1: make([]int, 5, 5), v2: make([]int, 5, 5)},
{v1: make([]int, 5), v2: make([]int, 5)},
} {
compareResult := compareTwoValues(mockT, currCase.v1, currCase.v2, []CompareType{compareLess, compareEqual, compareGreater}, "testFailMessage")
False(t, compareResult)
Expand Down
8 changes: 4 additions & 4 deletions assert/assertion_order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestIsIncreasing(t *testing.T) {
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, IsIncreasing(out, currCase.collection))
Contains(t, string(out.buf.Bytes()), currCase.msg)
Contains(t, out.buf.String(), currCase.msg)
}
}

Expand Down Expand Up @@ -91,7 +91,7 @@ func TestIsNonIncreasing(t *testing.T) {
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, IsNonIncreasing(out, currCase.collection))
Contains(t, string(out.buf.Bytes()), currCase.msg)
Contains(t, out.buf.String(), currCase.msg)
}
}

Expand Down Expand Up @@ -136,7 +136,7 @@ func TestIsDecreasing(t *testing.T) {
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, IsDecreasing(out, currCase.collection))
Contains(t, string(out.buf.Bytes()), currCase.msg)
Contains(t, out.buf.String(), currCase.msg)
}
}

Expand Down Expand Up @@ -181,6 +181,6 @@ func TestIsNonDecreasing(t *testing.T) {
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, IsNonDecreasing(out, currCase.collection))
Contains(t, string(out.buf.Bytes()), currCase.msg)
Contains(t, out.buf.String(), currCase.msg)
}
}
10 changes: 5 additions & 5 deletions assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{})
h.Helper()
}
if subset == nil {
return Fail(t, fmt.Sprintf("nil is the empty set which is a subset of every set"), msgAndArgs...)
return Fail(t, "nil is the empty set which is a subset of every set", msgAndArgs...)
}

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

if !aok || !bok {
return Fail(t, fmt.Sprintf("Parameters must be numerical"), msgAndArgs...)
return Fail(t, "Parameters must be numerical", msgAndArgs...)
}

if math.IsNaN(af) && math.IsNaN(bf) {
return true
}

if math.IsNaN(af) {
return Fail(t, fmt.Sprintf("Expected must not be NaN"), msgAndArgs...)
return Fail(t, "Expected must not be NaN", msgAndArgs...)
}

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

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

actualSlice := reflect.ValueOf(actual)
Expand Down
5 changes: 2 additions & 3 deletions assert/assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1575,8 +1575,7 @@ func testAutogeneratedFunction() {
t := struct {
io.Closer
}{}
var c io.Closer
c = t
c := t
c.Close()
}

Expand Down Expand Up @@ -2224,7 +2223,7 @@ func ExampleValueAssertionFunc() {

dumbParse := func(input string) interface{} {
var x interface{}
json.Unmarshal([]byte(input), &x)
_ = json.Unmarshal([]byte(input), &x)
return x
}

Expand Down
2 changes: 1 addition & 1 deletion assert/http_assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestHTTPStatusesWrapper(t *testing.T) {

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

func TestHTTPRequestWithNoParams(t *testing.T) {
Expand Down

0 comments on commit ab6dc32

Please sign in to comment.