Skip to content

Commit

Permalink
Merge pull request #366 from ably/feature/358-extract-ablytest
Browse files Browse the repository at this point in the history
Use reexported ablytest from github.com/ably/ably-go-test-utilities
  • Loading branch information
lmars authored Aug 9, 2021
2 parents d2b1daa + 16b26ad commit 1be684d
Show file tree
Hide file tree
Showing 32 changed files with 53 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ably/ably_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"time"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ably/internal/ablyutil"
"github.com/ably/ably-go/ablytest"
)

type Result interface {
Expand Down
2 changes: 1 addition & 1 deletion ably/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"time"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func single() *ably.PaginateParams {
Expand Down
2 changes: 1 addition & 1 deletion ably/event_emitter_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func Test_RTE3_EventEmitter_On(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ably/event_emitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func TestEventEmitterConcurrency(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ably/http_paginated_response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/ably/ably-go/ably"

"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func TestHTTPPaginatedResponse(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ably/proto_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

type custom struct{}
Expand Down
2 changes: 1 addition & 1 deletion ably/readme_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ably_test

import "testing"
import "github.com/ably/ably-go/ably"
import "github.com/ably/ably-go/ably/internal/ablytest"
import "github.com/ably/ably-go/ablytest"

/* README.md:22 */ import "context"

Expand Down
2 changes: 1 addition & 1 deletion ably/realtime_channel_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"time"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func TestRealtimeChannel_RTL2_ChannelEventForStateChange(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ably/realtime_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func expectMsg(ch <-chan *ably.Message, name string, data interface{}, t time.Duration, received bool) error {
Expand Down
2 changes: 1 addition & 1 deletion ably/realtime_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func TestRealtime_RealtimeHost(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ably/realtime_conn_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"time"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func Test_RTN2_WebsocketQueryParams(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ably/realtime_conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

var connTransitions = []ably.ConnectionState{
Expand Down
2 changes: 1 addition & 1 deletion ably/realtime_presence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func contains(members []*ably.PresenceMessage, clients ...string) error {
Expand Down
2 changes: 1 addition & 1 deletion ably/rest_channel_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func TestRSL1f1(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ably/rest_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/ably/ably-go/ably/internal/ablyutil"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func TestRESTChannel(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ably/rest_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"time"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ably/internal/ablyutil"
"github.com/ably/ably-go/ablytest"
)

func newHTTPClientMock(srv *httptest.Server) *http.Client {
Expand Down
2 changes: 1 addition & 1 deletion ably/rest_presence_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func TestPresenceHistory_RSP4_RSP4b3(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ably/transitioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

type ConnTransitioner struct {
Expand Down
3 changes: 1 addition & 2 deletions ably/internal/ablytest/ablytest.go → ablytest/ablytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/ably/ably-go/ably"
"github.com/ably/ably-go/ably/internal/ablyutil"
)

var Timeout = 30 * time.Second
Expand Down Expand Up @@ -59,7 +58,7 @@ func encode(typ string, in interface{}) ([]byte, error) {
case "application/json":
return json.Marshal(in)
case "application/x-msgpack":
return ablyutil.MarshalMsgpack(in)
return marshalMsgpack(in)
case "text/plain":
return []byte(fmt.Sprintf("%v", in)), nil
default:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ablytest_test
import (
"fmt"

"github.com/ably/ably-go/ably/internal/ablytest"
"github.com/ably/ably-go/ablytest"
)

func ExampleFmtFunc_Wrap() {
Expand Down
File renamed without changes.
32 changes: 32 additions & 0 deletions ablytest/msgpack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ablytest

import (
"bytes"
"io"

"github.com/ugorji/go/codec"
)

var handle codec.MsgpackHandle

func init() {
handle.Raw = true
handle.WriteExt = true
handle.RawToString = true
}

// marshalMsgpack returns msgpack encoding of v
func marshalMsgpack(v interface{}) ([]byte, error) {
var buf bytes.Buffer
err := encodeMsg(&buf, v)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}

// encodeMsg encodes v into msgpack format and writes the output to w.
func encodeMsg(w io.Writer, v interface{}) error {
enc := codec.NewEncoder(w, &handle)
return enc.Encode(v)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/test_readme_examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (w *writer) writeHeader() state {
w.writeln(`package ably_test`)
w.writeln(`import "testing"`)
w.writeln(`import "github.com/ably/ably-go/ably"`)
w.writeln(`import "github.com/ably/ably-go/ably/internal/ablytest"`)
w.writeln(`import "github.com/ably/ably-go/ablytest"`)

loop:
for {
Expand Down

0 comments on commit 1be684d

Please sign in to comment.