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

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
romshark committed Dec 11, 2018
1 parent 8d04346 commit d193299
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
44 changes: 44 additions & 0 deletions test/connSignalBufferOverflow_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package test

import (
"sync"
"testing"

wwr "github.com/qbeon/webwire-go"
"github.com/stretchr/testify/assert"
)

// TestConnSignalBufferOverflow tests Connection.Signal with a name and payload
// that would overflow the buffer
func TestConnSignalBufferOverflow(t *testing.T) {
finished := sync.WaitGroup{}
finished.Add(1)

// Initialize server
setup := SetupTestServer(
t,
&ServerImpl{
ClientConnected: func(_ wwr.ConnectionOptions, c wwr.Connection) {
defer finished.Done()

payload := make([]byte, 2048)
err := c.Signal(
[]byte(nil), // No name
wwr.Payload{Data: payload}, // Payload too big
)

assert.Error(t, err)
assert.IsType(t, wwr.ErrBufferOverflow{}, err)
},
},
wwr.ServerOptions{
MessageBufferSize: 1024,
},
nil, // Use the default transport implementation
)

// Initialize client
setup.NewClientSocket()

finished.Wait()
}
3 changes: 1 addition & 2 deletions test/connSignalNoNameNoPayload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"sync"
"testing"

"github.com/stretchr/testify/assert"

wwr "github.com/qbeon/webwire-go"
"github.com/stretchr/testify/assert"
)

// TestConnSignalNoNameNoPayload tests Connection.Signal providing both a nil
Expand Down

0 comments on commit d193299

Please sign in to comment.