Skip to content

Commit

Permalink
chore: Fix remaining testifylint errors (#2806)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickajacks1 authored Jan 22, 2024
1 parent 827013d commit 3c4509f
Show file tree
Hide file tree
Showing 12 changed files with 507 additions and 496 deletions.
158 changes: 80 additions & 78 deletions app_test.go

Large diffs are not rendered by default.

236 changes: 118 additions & 118 deletions bind_test.go

Large diffs are not rendered by default.

163 changes: 85 additions & 78 deletions client_test.go

Large diffs are not rendered by default.

138 changes: 70 additions & 68 deletions ctx_test.go

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ func Test_Utils_ForEachParameter(t *testing.T) {
for _, tc := range testCases {
n := 0
forEachParameter(tc.paramStr, func(p, v string) bool {
require.Equal(t, true, n < len(tc.expectedParams), "Received more parameters than expected: "+p+"="+v)
require.Less(t, n, len(tc.expectedParams), "Received more parameters than expected: "+p+"="+v)
require.Equal(t, tc.expectedParams[n][0], p, tc.description)
require.Equal(t, tc.expectedParams[n][1], v, tc.description)
n++

// Stop parsing at the first parameter called "end"
return p != "end"
})
require.Equal(t, len(tc.expectedParams), n, tc.description+": number of parameters differs")
require.Len(t, tc.expectedParams, n, tc.description+": number of parameters differs")
}
// Check that we exited on the second parameter (bar)
}
Expand Down Expand Up @@ -323,7 +323,7 @@ func Benchmark_Utils_ParamsMatch(b *testing.B) {
for n := 0; n < b.N; n++ {
match = paramsMatch(`; appLe=orange; param="foo"`, `;param=foo; apple=orange`)
}
require.Equal(b, true, match)
require.True(b, match)
}

func Test_Utils_AcceptsOfferType(t *testing.T) {
Expand Down Expand Up @@ -451,7 +451,7 @@ func Test_Utils_SortAcceptedTypes(t *testing.T) {
{spec: "application/json", quality: 0.999, specificity: 3, params: ";a=1", order: 11},
}
sortAcceptedTypes(&acceptedTypes)
require.Equal(t, acceptedTypes, []acceptedType{
require.Equal(t, []acceptedType{
{spec: "text/html", quality: 1, specificity: 3, order: 0},
{spec: "application/xml", quality: 1, specificity: 3, order: 4},
{spec: "application/pdf", quality: 1, specificity: 3, order: 5},
Expand All @@ -464,7 +464,7 @@ func Test_Utils_SortAcceptedTypes(t *testing.T) {
{spec: "application/json", quality: 0.999, specificity: 3, order: 3},
{spec: "text/*", quality: 0.5, specificity: 2, order: 1},
{spec: "*/*", quality: 0.1, specificity: 1, order: 2},
})
}, acceptedTypes)
}

// go test -v -run=^$ -bench=Benchmark_Utils_SortAcceptedTypes_Sorted -benchmem -count=4
Expand Down Expand Up @@ -498,7 +498,7 @@ func Benchmark_Utils_SortAcceptedTypes_Unsorted(b *testing.B) {
acceptedTypes[10] = acceptedType{spec: "text/plain", quality: 1, specificity: 3, order: 10}
sortAcceptedTypes(&acceptedTypes)
}
require.Equal(b, acceptedTypes, []acceptedType{
require.Equal(b, []acceptedType{
{spec: "text/html", quality: 1, specificity: 3, order: 0},
{spec: "application/xml", quality: 1, specificity: 3, order: 4},
{spec: "application/pdf", quality: 1, specificity: 3, order: 5},
Expand All @@ -510,7 +510,7 @@ func Benchmark_Utils_SortAcceptedTypes_Unsorted(b *testing.B) {
{spec: "application/json", quality: 0.999, specificity: 3, order: 3},
{spec: "text/*", quality: 0.5, specificity: 2, order: 1},
{spec: "*/*", quality: 0.1, specificity: 1, order: 2},
})
}, acceptedTypes)
}

func Test_Utils_UniqueRouteStack(t *testing.T) {
Expand Down Expand Up @@ -609,9 +609,9 @@ func Test_Utils_Parse_Address(t *testing.T) {
func Test_Utils_TestConn_Deadline(t *testing.T) {
t.Parallel()
conn := &testConn{}
require.Nil(t, conn.SetDeadline(time.Time{}))
require.Nil(t, conn.SetReadDeadline(time.Time{}))
require.Nil(t, conn.SetWriteDeadline(time.Time{}))
require.NoError(t, conn.SetDeadline(time.Time{}))
require.NoError(t, conn.SetReadDeadline(time.Time{}))
require.NoError(t, conn.SetWriteDeadline(time.Time{}))
}

func Test_Utils_IsNoCache(t *testing.T) {
Expand Down
26 changes: 13 additions & 13 deletions hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func Test_Hook_OnName(t *testing.T) {

app.Hooks().OnName(func(r Route) error {
_, err := buf.WriteString(r.Name)
require.NoError(t, nil, err)
require.NoError(t, err)

return nil
})
Expand Down Expand Up @@ -104,7 +104,7 @@ func Test_Hook_OnGroup(t *testing.T) {

app.Hooks().OnGroup(func(g Group) error {
_, err := buf.WriteString(g.Prefix)
require.NoError(t, nil, err)
require.NoError(t, err)
return nil
})

Expand Down Expand Up @@ -143,7 +143,7 @@ func Test_Hook_OnGroupName(t *testing.T) {

app.Hooks().OnGroupName(func(g Group) error {
_, err := buf.WriteString(g.name)
require.NoError(t, nil, err)
require.NoError(t, err)

return nil
})
Expand Down Expand Up @@ -189,12 +189,12 @@ func Test_Hook_OnShutdown(t *testing.T) {

app.Hooks().OnShutdown(func() error {
_, err := buf.WriteString("shutdowning")
require.NoError(t, nil, err)
require.NoError(t, err)

return nil
})

require.Nil(t, app.Shutdown())
require.NoError(t, app.Shutdown())
require.Equal(t, "shutdowning", buf.String())
}

Expand All @@ -215,9 +215,9 @@ func Test_Hook_OnListen(t *testing.T) {

go func() {
time.Sleep(1000 * time.Millisecond)
require.Equal(t, nil, app.Shutdown())
require.NoError(t, app.Shutdown())
}()
require.Equal(t, nil, app.Listen(":9000"))
require.NoError(t, app.Listen(":9000"))

require.Equal(t, "ready", buf.String())
}
Expand All @@ -231,17 +231,17 @@ func Test_Hook_OnListenPrefork(t *testing.T) {

app.Hooks().OnListen(func(listenData ListenData) error {
_, err := buf.WriteString("ready")
require.NoError(t, nil, err)
require.NoError(t, err)

return nil
})

go func() {
time.Sleep(1000 * time.Millisecond)
require.Nil(t, app.Shutdown())
require.NoError(t, app.Shutdown())
}()

require.Nil(t, app.Listen(":9000", ListenConfig{DisableStartupMessage: true, EnablePrefork: true}))
require.NoError(t, app.Listen(":9000", ListenConfig{DisableStartupMessage: true, EnablePrefork: true}))
require.Equal(t, "ready", buf.String())
}

Expand All @@ -254,15 +254,15 @@ func Test_Hook_OnHook(t *testing.T) {

go func() {
time.Sleep(1000 * time.Millisecond)
require.Nil(t, app.Shutdown())
require.NoError(t, app.Shutdown())
}()

app.Hooks().OnFork(func(pid int) error {
require.Equal(t, 1, pid)
return nil
})

require.Nil(t, app.prefork(":3000", nil, ListenConfig{DisableStartupMessage: true, EnablePrefork: true}))
require.NoError(t, app.prefork(":3000", nil, ListenConfig{DisableStartupMessage: true, EnablePrefork: true}))
}

func Test_Hook_OnMount(t *testing.T) {
Expand All @@ -274,7 +274,7 @@ func Test_Hook_OnMount(t *testing.T) {
subApp.Get("/test", testSimpleHandler)

subApp.Hooks().OnMount(func(parent *App) error {
require.Equal(t, parent.mountFields.mountPath, "")
require.Empty(t, parent.mountFields.mountPath)

return nil
})
Expand Down
12 changes: 6 additions & 6 deletions internal/storage/memory/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ func Test_Storage_Memory_Get_Expired(t *testing.T) {

result, err := testStore.Get(key)
require.NoError(t, err)
require.Equal(t, true, len(result) == 0)
require.Empty(t, result)
}

func Test_Storage_Memory_Get_NotExist(t *testing.T) {
t.Parallel()

result, err := testStore.Get("notexist")
require.NoError(t, err)
require.Equal(t, true, len(result) == 0)
require.Empty(t, result)
}

func Test_Storage_Memory_Delete(t *testing.T) {
Expand All @@ -95,7 +95,7 @@ func Test_Storage_Memory_Delete(t *testing.T) {

result, err := testStore.Get(key)
require.NoError(t, err)
require.Equal(t, true, len(result) == 0)
require.Empty(t, result)
}

func Test_Storage_Memory_Reset(t *testing.T) {
Expand All @@ -113,11 +113,11 @@ func Test_Storage_Memory_Reset(t *testing.T) {

result, err := testStore.Get("john1")
require.NoError(t, err)
require.Equal(t, true, len(result) == 0)
require.Empty(t, result)

result, err = testStore.Get("john2")
require.NoError(t, err)
require.Equal(t, true, len(result) == 0)
require.Empty(t, result)
}

func Test_Storage_Memory_Close(t *testing.T) {
Expand All @@ -127,7 +127,7 @@ func Test_Storage_Memory_Close(t *testing.T) {

func Test_Storage_Memory_Conn(t *testing.T) {
t.Parallel()
require.True(t, testStore.Conn() != nil)
require.NotNil(t, testStore.Conn())
}

// go test -v -run=^$ -bench=Benchmark_Storage_Memory -benchmem -count=4
Expand Down
Loading

0 comments on commit 3c4509f

Please sign in to comment.