Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
linters warnings fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rustatian committed Feb 3, 2021
1 parent a232fd3 commit 52981c3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 25 deletions.
2 changes: 1 addition & 1 deletion access_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (w *accessValidator) copy(rw http.ResponseWriter) {
}
}

io.Copy(rw, w.buffer)
_, _ = io.Copy(rw, w.buffer)
}

// Header returns the header map that will be sent by WriteHeader.
Expand Down
2 changes: 1 addition & 1 deletion access_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func TestResponseWrapper_Body(t *testing.T) {
w := newValidator()
w.Write([]byte("hello"))
_, _ =w.Write([]byte("hello"))

assert.Equal(t, []byte("hello"), w.Body())
}
Expand Down
68 changes: 45 additions & 23 deletions service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func Test_HttpService_Echo(t *testing.T) {
}`,
}))

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 3000)
defer c.Stop()

Expand All @@ -78,7 +78,9 @@ func Test_HttpService_Echo(t *testing.T) {

r, err := http.DefaultClient.Do(req)
assert.NoError(t, err)
defer r.Body.Close()
defer func() {
_ = r.Body.Close()
}()

b, _ := ioutil.ReadAll(r.Body)

Expand All @@ -101,7 +103,7 @@ func Test_HttpService_Echo400(t *testing.T) {
}`,
}))

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 3000)
defer c.Stop()

Expand All @@ -110,7 +112,9 @@ func Test_HttpService_Echo400(t *testing.T) {

r, err := http.DefaultClient.Do(req)
assert.NoError(t, err)
defer r.Body.Close()
defer func() {
_ = r.Body.Close()
}()

assert.NoError(t, err)
assert.Equal(t, 401, r.StatusCode)
Expand All @@ -137,7 +141,7 @@ func Test_Service_EnvPath(t *testing.T) {
broadcast: `{}`,
}))

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 3000)
defer c.Stop()

Expand All @@ -149,7 +153,9 @@ func Test_Service_EnvPath(t *testing.T) {
if err != nil {
panic(err)
}
defer r.Body.Close()
defer func() {
_ = r.Body.Close()
}()

b, _ := ioutil.ReadAll(r.Body)

Expand Down Expand Up @@ -197,15 +203,17 @@ func Test_Service_JoinTopic(t *testing.T) {
broadcast: `{}`,
}))

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6038", Path: "/ws"}

conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
assert.NoError(t, err)
defer conn.Close()
defer func() {
_ = conn.Close()
}()

read := make(chan interface{})

Expand Down Expand Up @@ -247,15 +255,17 @@ func Test_Service_DenyJoin(t *testing.T) {
broadcast: `{}`,
}))

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6037", Path: "/ws"}

conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
assert.NoError(t, err)
defer conn.Close()
defer func() {
_ = conn.Close()
}()

read := make(chan interface{})

Expand Down Expand Up @@ -298,7 +308,7 @@ func Test_Service_DenyJoinServer(t *testing.T) {
broadcast: `{}`,
}))

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

Expand Down Expand Up @@ -329,15 +339,17 @@ func Test_Service_EmptyTopics(t *testing.T) {
broadcast: `{}`,
}))

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6036", Path: "/ws"}

conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
assert.NoError(t, err)
defer conn.Close()
defer func() {
_ = conn.Close()
}()

read := make(chan interface{})

Expand Down Expand Up @@ -389,15 +401,17 @@ func Test_Service_BadTopics(t *testing.T) {
broadcast: `{}`,
}))

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6035", Path: "/ws"}

conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
assert.NoError(t, err)
defer conn.Close()
defer func() {
_ = conn.Close()
}()

read := make(chan interface{})

Expand Down Expand Up @@ -438,15 +452,17 @@ func Test_Service_BadTopicsLeave(t *testing.T) {
broadcast: `{}`,
}))

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6034", Path: "/ws"}

conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
assert.NoError(t, err)
defer conn.Close()
defer func() {
_ = conn.Close()
}()

read := make(chan interface{})

Expand Down Expand Up @@ -497,15 +513,17 @@ func Test_Service_Events(t *testing.T) {
}
})

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6033", Path: "/ws"}

conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
assert.NoError(t, err)
defer conn.Close()
defer func() {
_ = conn.Close()
}()

<-done

Expand Down Expand Up @@ -561,7 +579,7 @@ func Test_Service_Warmup(t *testing.T) {
}
})

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

Expand All @@ -578,7 +596,9 @@ func Test_Service_Warmup(t *testing.T) {

conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
assert.NoError(t, err)
defer conn.Close()
defer func() {
_ = conn.Close()
}()

<-done

Expand Down Expand Up @@ -640,7 +660,7 @@ func Test_Service_Stop(t *testing.T) {
}
})

go func() { c.Serve() }()
go func() { _ = c.Serve() }()
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

Expand All @@ -657,7 +677,9 @@ func Test_Service_Stop(t *testing.T) {

conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
assert.NoError(t, err)
defer conn.Close()
defer func() {
_ = conn.Close()
}()

<-done

Expand Down

0 comments on commit 52981c3

Please sign in to comment.