Skip to content

Commit

Permalink
Fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed Nov 19, 2022
1 parent 8ff7295 commit 098613c
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 27 deletions.
24 changes: 20 additions & 4 deletions .golangci.yml
@@ -1,9 +1,25 @@
linters-settings:
lll:
line-length: 90

linters:
enable:
- govet
- revive
- staticcheck
- exportloopref
- lll
- misspell
- dupword
disable:
- gosimple
- unused

linters-settings:
lll:
line-length: 90

issues:
exclude-rules:
- text: error-strings
linters:
- revive
- text: indent-error-flow
linters:
- revive
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -11,8 +11,8 @@ lint:
golangci-lint run .

test:
go test
cd _examples && go test
gotest
cd _examples && gotest

gen:
go generate
Expand Down
2 changes: 1 addition & 1 deletion cookie_test.go
Expand Up @@ -79,7 +79,7 @@ func TestCookieGetters(t *testing.T) {
assert.Equal(t, "example.com", value.Domain().Raw())
assert.Equal(t, "/path", value.Path().Raw())
assert.True(t, time.Unix(1234, 0).Equal(value.Expires().Raw()))
assert.Equal(t, time.Duration(123*time.Second), value.MaxAge().Raw())
assert.Equal(t, 123*time.Second, value.MaxAge().Raw())

value.chain.assertOK(t)
}
Expand Down
2 changes: 1 addition & 1 deletion e2e_timeout_test.go
Expand Up @@ -24,7 +24,7 @@ func createTimeoutHandler() http.Handler {
mux := http.NewServeMux()

mux.HandleFunc("/sleep", func(w http.ResponseWriter, r *http.Request) {
time.Sleep(time.Duration(time.Second))
time.Sleep(time.Second)
})

mux.HandleFunc("/small", func(w http.ResponseWriter, r *http.Request) {
Expand Down
22 changes: 11 additions & 11 deletions expect.go
Expand Up @@ -66,10 +66,10 @@
//
// Assertion handling
//
// If you want to be informed about every asserion made, successfull or failed, you
// If you want to be informed about every asserion made, successful or failed, you
// can use AssertionHandler interface.
//
// Default implementation of this interface ignores successfull assertions and reports
// Default implementation of this interface ignores successful assertions and reports
// failed assertions using Formatter and Reporter objects.
//
// Custom AssertionHandler can handle all assertions (e.g. dump them in JSON format)
Expand Down Expand Up @@ -171,14 +171,14 @@ type Config struct {
// relatively big task.
Formatter Formatter

// AssertionHandler handles both successfull and failed assertions.
// AssertionHandler handles both successful and failed assertions.
// May be nil.
//
// If nil, DefaultAssertionHandler is used.
//
// Every time an assertion is made, AssertionHandler in invoked with detailed
// info about the assertion and failure. On failure, AssertionHandler is
// reponsible to format and report error.
// responsible to format and report error.
//
// DefaultAssertionHandler uses Config.Formatter to format failure and
// Config.Reporter to report it.
Expand Down Expand Up @@ -467,37 +467,37 @@ func (e *Expect) Request(method, path string, pathargs ...interface{}) *Request

// OPTIONS is a shorthand for e.Request("OPTIONS", path, pathargs...).
func (e *Expect) OPTIONS(path string, pathargs ...interface{}) *Request {
return e.Request("OPTIONS", path, pathargs...)
return e.Request(http.MethodOptions, path, pathargs...)
}

// HEAD is a shorthand for e.Request("HEAD", path, pathargs...).
func (e *Expect) HEAD(path string, pathargs ...interface{}) *Request {
return e.Request("HEAD", path, pathargs...)
return e.Request(http.MethodHead, path, pathargs...)
}

// GET is a shorthand for e.Request("GET", path, pathargs...).
func (e *Expect) GET(path string, pathargs ...interface{}) *Request {
return e.Request("GET", path, pathargs...)
return e.Request(http.MethodGet, path, pathargs...)
}

// POST is a shorthand for e.Request("POST", path, pathargs...).
func (e *Expect) POST(path string, pathargs ...interface{}) *Request {
return e.Request("POST", path, pathargs...)
return e.Request(http.MethodPost, path, pathargs...)
}

// PUT is a shorthand for e.Request("PUT", path, pathargs...).
func (e *Expect) PUT(path string, pathargs ...interface{}) *Request {
return e.Request("PUT", path, pathargs...)
return e.Request(http.MethodPut, path, pathargs...)
}

// PATCH is a shorthand for e.Request("PATCH", path, pathargs...).
func (e *Expect) PATCH(path string, pathargs ...interface{}) *Request {
return e.Request("PATCH", path, pathargs...)
return e.Request(http.MethodPatch, path, pathargs...)
}

// DELETE is a shorthand for e.Request("DELETE", path, pathargs...).
func (e *Expect) DELETE(path string, pathargs ...interface{}) *Request {
return e.Request("DELETE", path, pathargs...)
return e.Request(http.MethodDelete, path, pathargs...)
}

// Value is a shorthand for NewValue(e.config.Reporter, value).
Expand Down
12 changes: 6 additions & 6 deletions expect_test.go
Expand Up @@ -73,8 +73,8 @@ func TestExpectBuilders(t *testing.T) {
r1 := e1.Request("METHOD", "/url")
r2 := e2.Request("METHOD", "/url")

assert.Equal(t, 2, int(len(reqs1)))
assert.Equal(t, 1, int(len(reqs2)))
assert.Equal(t, 2, len(reqs1))
assert.Equal(t, 1, len(reqs2))

assert.Equal(t, r1, reqs1[0])
assert.Equal(t, r2, reqs1[1])
Expand Down Expand Up @@ -166,14 +166,14 @@ func TestExpectMatchers(t *testing.T) {
req1 := e1.Request("METHOD", "/url")
req2 := e2.Request("METHOD", "/url")

assert.Equal(t, 0, int(len(resps1)))
assert.Equal(t, 0, int(len(resps2)))
assert.Equal(t, 0, len(resps1))
assert.Equal(t, 0, len(resps2))

resp1 := req1.Expect()
resp2 := req2.Expect()

assert.Equal(t, 2, int(len(resps1)))
assert.Equal(t, 1, int(len(resps2)))
assert.Equal(t, 2, len(resps1))
assert.Equal(t, 1, len(resps2))

assert.Equal(t, resp1, resps1[0])
assert.Equal(t, resp2, resps1[1])
Expand Down
4 changes: 2 additions & 2 deletions request_test.go
Expand Up @@ -145,11 +145,11 @@ func TestRequestMatchers(t *testing.T) {
resps = append(resps, r)
})

assert.Equal(t, 0, int(len(resps)))
assert.Equal(t, 0, len(resps))

resp := req.Expect()

assert.Equal(t, 1, int(len(resps)))
assert.Equal(t, 1, len(resps))
assert.Equal(t, resp, resps[0])
}

Expand Down

0 comments on commit 098613c

Please sign in to comment.