mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 20:49:16 +00:00
more test cleanup
This commit is contained in:
parent
ff5c34e0df
commit
6ee801747c
@ -55,6 +55,10 @@ func TestMain(m *testing.M) {
|
|||||||
panic("failed to set account storage");
|
panic("failed to set account storage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
go SendNotifications()
|
||||||
|
|
||||||
m.Run()
|
m.Run()
|
||||||
|
|
||||||
|
ExitNotifications()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package databag
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/url"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"github.com/gorilla/websocket"
|
|
||||||
)
|
|
||||||
|
|
||||||
type StatusHandler struct {}
|
|
||||||
|
|
||||||
func (h *StatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
||||||
Status(w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
func getTestWebsocket() *websocket.Conn {
|
|
||||||
h := StatusHandler{}
|
|
||||||
s := httptest.NewServer(&h)
|
|
||||||
wsUrl, _ := url.Parse(s.URL)
|
|
||||||
wsUrl.Scheme = "ws"
|
|
||||||
ws, _, err := websocket.DefaultDialer.Dial(wsUrl.String(), nil)
|
|
||||||
if err != nil {
|
|
||||||
PrintMsg(err.Error());
|
|
||||||
}
|
|
||||||
return ws
|
|
||||||
}
|
|
@ -3,18 +3,16 @@ package databag
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
"net/url"
|
||||||
"net/http"
|
"net/http"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TestAccount struct {
|
const TEST_READDEADLINE = 2
|
||||||
AppToken string
|
|
||||||
ContactGuid string
|
|
||||||
ContactToken string
|
|
||||||
ContactCardId string
|
|
||||||
}
|
|
||||||
|
|
||||||
type TestCard struct {
|
type TestCard struct {
|
||||||
Guid string
|
Guid string
|
||||||
@ -39,14 +37,21 @@ type TestGroup struct {
|
|||||||
D TestContact
|
D TestContact
|
||||||
}
|
}
|
||||||
|
|
||||||
// A-B
|
|
||||||
// |x|
|
|
||||||
// C-D
|
|
||||||
//
|
//
|
||||||
// A: B[connected,group] : C[requested,group] : D[requested,nogroup]
|
// A --- connected,group connected,group --- B
|
||||||
// B: A[connected,group] : C[confirmed,group] : D[,]
|
// | \ /|
|
||||||
// C: A[confirmed,group] : B[confirmed,nogroup] : D[connected,group]
|
// | requested,nogroup confirmed,group |
|
||||||
// D: A[pending,nogroup] : B[,] : C[connected,group]
|
// | |
|
||||||
|
// requested,group ,
|
||||||
|
// |
|
||||||
|
// --x--
|
||||||
|
// |
|
||||||
|
// confirmed,group ,
|
||||||
|
// | |
|
||||||
|
// | confirmed,nogroup pending,nogroup |
|
||||||
|
// |/ \|
|
||||||
|
// C --- connected,group connected,group --- D
|
||||||
|
//
|
||||||
func AddTestGroup(prefix string) (*TestGroup, error) {
|
func AddTestGroup(prefix string) (*TestGroup, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@ -374,3 +379,62 @@ func NewRequest(rest string, path string, obj interface{}) (*http.Request, *http
|
|||||||
return httptest.NewRequest(rest, path, nil), w, nil
|
return httptest.NewRequest(rest, path, nil), w, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Websocket test support
|
||||||
|
type statusHandler struct {}
|
||||||
|
func (h *statusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
Status(w, r)
|
||||||
|
}
|
||||||
|
func StatusConnection(token string, rev *Revision) (ws *websocket.Conn, err error) {
|
||||||
|
var data []byte
|
||||||
|
var dataType int
|
||||||
|
|
||||||
|
// connect to websocket
|
||||||
|
s := httptest.NewServer(&statusHandler{})
|
||||||
|
wsUrl, _ := url.Parse(s.URL)
|
||||||
|
wsUrl.Scheme = "ws"
|
||||||
|
if ws, _, err = websocket.DefaultDialer.Dial(wsUrl.String(), nil); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// send authentication
|
||||||
|
announce := Announce{ AppToken: token }
|
||||||
|
if data, err = json.Marshal(&announce); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ws.WriteMessage(websocket.TextMessage, data)
|
||||||
|
|
||||||
|
// read revision response
|
||||||
|
ws.SetReadDeadline(time.Now().Add(TEST_READDEADLINE * time.Second))
|
||||||
|
if dataType, data, err = ws.ReadMessage(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if dataType != websocket.TextMessage {
|
||||||
|
err = errors.New("invalid status data type")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(data, rev); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func StatusRevision(ws *websocket.Conn, rev *Revision) (err error) {
|
||||||
|
var data []byte
|
||||||
|
var dataType int
|
||||||
|
|
||||||
|
// read revision update
|
||||||
|
ws.SetReadDeadline(time.Now().Add(TEST_READDEADLINE * time.Second))
|
||||||
|
if dataType, data, err = ws.ReadMessage(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if dataType != websocket.TextMessage {
|
||||||
|
err = errors.New("invalid status data type")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(data, rev); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -2,13 +2,15 @@ package databag
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
"encoding/json"
|
|
||||||
"time"
|
"time"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAttachAccount(t *testing.T) {
|
func TestAttachAccount(t *testing.T) {
|
||||||
|
var err error
|
||||||
|
var ws *websocket.Conn
|
||||||
|
var revision Revision
|
||||||
|
|
||||||
// get account token
|
// get account token
|
||||||
r, w, _ := NewRequest("POST", "/admin/accounts", nil)
|
r, w, _ := NewRequest("POST", "/admin/accounts", nil)
|
||||||
@ -64,14 +66,8 @@ func TestAttachAccount(t *testing.T) {
|
|||||||
assert.Equal(t, msgType, APP_MSGAUTHENTICATE)
|
assert.Equal(t, msgType, APP_MSGAUTHENTICATE)
|
||||||
|
|
||||||
// app connects websocket
|
// app connects websocket
|
||||||
ws := getTestWebsocket()
|
ws, err = StatusConnection(profile.Guid + "." + access, &revision);
|
||||||
announce := Announce{ AppToken: profile.Guid + "." + access }
|
assert.NoError(t, err)
|
||||||
msg, _ := json.Marshal(&announce)
|
|
||||||
ws.WriteMessage(websocket.TextMessage, msg)
|
|
||||||
ws.SetReadDeadline(time.Now().Add(2 * time.Second))
|
|
||||||
_, msg, _ = ws.ReadMessage()
|
|
||||||
var revision Revision
|
|
||||||
assert.NoError(t, json.Unmarshal(msg, &revision))
|
|
||||||
profileRevision := revision.Profile
|
profileRevision := revision.Profile
|
||||||
|
|
||||||
// set profile
|
// set profile
|
||||||
@ -95,9 +91,8 @@ func TestAttachAccount(t *testing.T) {
|
|||||||
assert.Equal(t, "Namer", profile.Name)
|
assert.Equal(t, "Namer", profile.Name)
|
||||||
|
|
||||||
// profile revision incremented
|
// profile revision incremented
|
||||||
ws.SetReadDeadline(time.Now().Add(2 * time.Second))
|
err = StatusRevision(ws, &revision)
|
||||||
_, msg, _ = ws.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(msg, &revision))
|
|
||||||
assert.NotEqual(t, profileRevision, revision.Profile)
|
assert.NotEqual(t, profileRevision, revision.Profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package databag
|
package databag
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"testing"
|
"testing"
|
||||||
"encoding/json"
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -16,6 +14,9 @@ func TestConnectContact(t *testing.T) {
|
|||||||
var vars map[string]string
|
var vars map[string]string
|
||||||
var cardRevision int64
|
var cardRevision int64
|
||||||
var contactStatus ContactStatus
|
var contactStatus ContactStatus
|
||||||
|
var ws *websocket.Conn
|
||||||
|
var err error
|
||||||
|
|
||||||
|
|
||||||
// create some contacts for this test
|
// create some contacts for this test
|
||||||
_, a, _ := AddTestAccount("connect0")
|
_, a, _ := AddTestAccount("connect0")
|
||||||
@ -29,14 +30,8 @@ func TestConnectContact(t *testing.T) {
|
|||||||
assert.NoError(t, ReadResponse(w, &msg))
|
assert.NoError(t, ReadResponse(w, &msg))
|
||||||
|
|
||||||
// app connects websocket
|
// app connects websocket
|
||||||
ws := getTestWebsocket()
|
ws, err = StatusConnection(b, &revision);
|
||||||
announce := Announce{ AppToken: b }
|
assert.NoError(t, err)
|
||||||
data, _ := json.Marshal(&announce)
|
|
||||||
ws.WriteMessage(websocket.TextMessage, data)
|
|
||||||
ws.SetReadDeadline(time.Now().Add(2 * time.Second))
|
|
||||||
_, data, _ = ws.ReadMessage()
|
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
//cardRevision = revision.Card
|
|
||||||
|
|
||||||
// add A card in B
|
// add A card in B
|
||||||
r, w, _ = NewRequest("POST", "/contact/cards", &msg)
|
r, w, _ = NewRequest("POST", "/contact/cards", &msg)
|
||||||
@ -45,10 +40,8 @@ func TestConnectContact(t *testing.T) {
|
|||||||
assert.NoError(t, ReadResponse(w, &card))
|
assert.NoError(t, ReadResponse(w, &card))
|
||||||
|
|
||||||
// profile revision incremented
|
// profile revision incremented
|
||||||
ws.SetReadDeadline(time.Now().Add(2 * time.Second))
|
err = StatusRevision(ws, &revision)
|
||||||
_, data, _ = ws.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
assert.NotEqual(t, cardRevision, revision.Card)
|
|
||||||
cardRevision = revision.Card
|
cardRevision = revision.Card
|
||||||
|
|
||||||
// update A status to connecting
|
// update A status to connecting
|
||||||
@ -60,9 +53,8 @@ func TestConnectContact(t *testing.T) {
|
|||||||
assert.NoError(t, ReadResponse(w, &card))
|
assert.NoError(t, ReadResponse(w, &card))
|
||||||
|
|
||||||
// card revision incremented
|
// card revision incremented
|
||||||
ws.SetReadDeadline(time.Now().Add(2 * time.Second))
|
err = StatusRevision(ws, &revision)
|
||||||
_, data, _ = ws.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
assert.NotEqual(t, cardRevision, revision.Card)
|
assert.NotEqual(t, cardRevision, revision.Card)
|
||||||
cardRevision = revision.Card
|
cardRevision = revision.Card
|
||||||
|
|
||||||
@ -118,9 +110,8 @@ func TestConnectContact(t *testing.T) {
|
|||||||
assert.Equal(t, APP_CARDCONNECTED, contactStatus.Status)
|
assert.Equal(t, APP_CARDCONNECTED, contactStatus.Status)
|
||||||
|
|
||||||
// card revision incremented
|
// card revision incremented
|
||||||
ws.SetReadDeadline(time.Now().Add(2 * time.Second))
|
err = StatusRevision(ws, &revision)
|
||||||
_, data, _ = ws.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
assert.NotEqual(t, cardRevision, revision.Card)
|
assert.NotEqual(t, cardRevision, revision.Card)
|
||||||
cardRevision = revision.Card
|
cardRevision = revision.Card
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package databag
|
package databag
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"testing"
|
"testing"
|
||||||
"encoding/json"
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -21,9 +19,9 @@ func TestGroupContact(t *testing.T) {
|
|||||||
var contactRevision int64
|
var contactRevision int64
|
||||||
var card Card
|
var card Card
|
||||||
var contactCardRevision int64
|
var contactCardRevision int64
|
||||||
|
var wsA *websocket.Conn
|
||||||
// start notification thread
|
var wsB *websocket.Conn
|
||||||
go SendNotifications()
|
var err error
|
||||||
|
|
||||||
// connect contacts
|
// connect contacts
|
||||||
_, a, _ := AddTestAccount("groupcontact0")
|
_, a, _ := AddTestAccount("groupcontact0")
|
||||||
@ -34,23 +32,11 @@ func TestGroupContact(t *testing.T) {
|
|||||||
OpenTestCard(b, bCard)
|
OpenTestCard(b, bCard)
|
||||||
|
|
||||||
// app connects websocket
|
// app connects websocket
|
||||||
wsA := getTestWebsocket()
|
wsA, err = StatusConnection(a, &revision);
|
||||||
announce := Announce{ AppToken: a }
|
assert.NoError(t, err)
|
||||||
data, _ := json.Marshal(&announce)
|
|
||||||
wsA.WriteMessage(websocket.TextMessage, data)
|
|
||||||
wsB := getTestWebsocket()
|
|
||||||
announce = Announce{ AppToken: b }
|
|
||||||
data, _ = json.Marshal(&announce)
|
|
||||||
wsB.WriteMessage(websocket.TextMessage, data)
|
|
||||||
|
|
||||||
// receive revision
|
|
||||||
wsA.SetReadDeadline(time.Now().Add(2 * time.Second))
|
|
||||||
_, data, _ = wsA.ReadMessage()
|
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
groupRevision = revision.Group
|
groupRevision = revision.Group
|
||||||
wsB.SetReadDeadline(time.Now().Add(2 * time.Second))
|
wsB, err = StatusConnection(b, &revision);
|
||||||
_, data, _ = wsB.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
contactRevision = revision.Card
|
contactRevision = revision.Card
|
||||||
|
|
||||||
// add group to conatact 0
|
// add group to conatact 0
|
||||||
@ -64,9 +50,8 @@ func TestGroupContact(t *testing.T) {
|
|||||||
assert.NoError(t, ReadResponse(w, &group))
|
assert.NoError(t, ReadResponse(w, &group))
|
||||||
|
|
||||||
// receive revision
|
// receive revision
|
||||||
wsA.SetReadDeadline(time.Now().Add(2 * time.Second))
|
err = StatusRevision(wsA, &revision)
|
||||||
_, data, _ = wsA.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
assert.NotEqual(t, groupRevision, revision.Group)
|
assert.NotEqual(t, groupRevision, revision.Group)
|
||||||
cardRevision = revision.Card
|
cardRevision = revision.Card
|
||||||
|
|
||||||
@ -101,14 +86,12 @@ func TestGroupContact(t *testing.T) {
|
|||||||
assert.Equal(t, len(card.CardData.Groups), 1)
|
assert.Equal(t, len(card.CardData.Groups), 1)
|
||||||
|
|
||||||
// receive revision
|
// receive revision
|
||||||
wsA.SetReadDeadline(time.Now().Add(2 * time.Second))
|
err = StatusRevision(wsA, &revision)
|
||||||
_, data, _ = wsA.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
assert.NotEqual(t, cardRevision, revision.Card)
|
assert.NotEqual(t, cardRevision, revision.Card)
|
||||||
groupRevision = revision.Group
|
groupRevision = revision.Group
|
||||||
wsB.SetReadDeadline(time.Now().Add(2 * time.Second))
|
err = StatusRevision(wsB, &revision)
|
||||||
_, data, _ = wsB.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
assert.NotEqual(t, contactRevision, revision.Card)
|
assert.NotEqual(t, contactRevision, revision.Card)
|
||||||
contactRevision = revision.Card
|
contactRevision = revision.Card
|
||||||
|
|
||||||
@ -144,9 +127,8 @@ func TestGroupContact(t *testing.T) {
|
|||||||
assert.Equal(t, group.DataType, "imagroupEDIT")
|
assert.Equal(t, group.DataType, "imagroupEDIT")
|
||||||
|
|
||||||
// receive revision
|
// receive revision
|
||||||
wsA.SetReadDeadline(time.Now().Add(2 * time.Second))
|
err = StatusRevision(wsA, &revision)
|
||||||
_, data, _ = wsA.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
assert.NotEqual(t, groupRevision, revision.Group)
|
assert.NotEqual(t, groupRevision, revision.Group)
|
||||||
groupRevision = revision.Group
|
groupRevision = revision.Group
|
||||||
|
|
||||||
@ -170,13 +152,11 @@ func TestGroupContact(t *testing.T) {
|
|||||||
assert.Equal(t, len(card.CardData.Groups), 0)
|
assert.Equal(t, len(card.CardData.Groups), 0)
|
||||||
|
|
||||||
// receive revision
|
// receive revision
|
||||||
wsA.SetReadDeadline(time.Now().Add(2 * time.Second))
|
err = StatusRevision(wsA, &revision)
|
||||||
_, data, _ = wsA.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
assert.NotEqual(t, groupRevision, revision.Group)
|
assert.NotEqual(t, groupRevision, revision.Group)
|
||||||
wsB.SetReadDeadline(time.Now().Add(2 * time.Second))
|
err = StatusRevision(wsB, &revision)
|
||||||
_, data, _ = wsB.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
assert.NotEqual(t, contactRevision, revision.Card)
|
assert.NotEqual(t, contactRevision, revision.Card)
|
||||||
|
|
||||||
// get contact revision
|
// get contact revision
|
||||||
@ -194,7 +174,4 @@ func TestGroupContact(t *testing.T) {
|
|||||||
GetGroups(w, r)
|
GetGroups(w, r)
|
||||||
assert.NoError(t, ReadResponse(w, &groups))
|
assert.NoError(t, ReadResponse(w, &groups))
|
||||||
assert.Equal(t, 0, len(groups))
|
assert.Equal(t, 0, len(groups))
|
||||||
|
|
||||||
// stop notification thread
|
|
||||||
ExitNotifications()
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package databag
|
package databag
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"testing"
|
"testing"
|
||||||
"encoding/json"
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -11,10 +9,8 @@ import (
|
|||||||
func TestProfileNotification(t *testing.T) {
|
func TestProfileNotification(t *testing.T) {
|
||||||
var views []CardView
|
var views []CardView
|
||||||
var revision Revision
|
var revision Revision
|
||||||
var data []byte
|
var ws *websocket.Conn
|
||||||
|
var err error
|
||||||
// start notifcation thread
|
|
||||||
go SendNotifications()
|
|
||||||
|
|
||||||
// connect contacts
|
// connect contacts
|
||||||
_, a, _ := AddTestAccount("profilenotification0")
|
_, a, _ := AddTestAccount("profilenotification0")
|
||||||
@ -33,15 +29,8 @@ func TestProfileNotification(t *testing.T) {
|
|||||||
profileRevision := views[0].RemoteProfile
|
profileRevision := views[0].RemoteProfile
|
||||||
|
|
||||||
// app connects websocket
|
// app connects websocket
|
||||||
ws := getTestWebsocket()
|
ws, err = StatusConnection(a, &revision);
|
||||||
announce := Announce{ AppToken: a }
|
assert.NoError(t, err)
|
||||||
data, _ = json.Marshal(&announce)
|
|
||||||
ws.WriteMessage(websocket.TextMessage, data)
|
|
||||||
|
|
||||||
// receive revision
|
|
||||||
ws.SetReadDeadline(time.Now().Add(2 * time.Second))
|
|
||||||
_, data, _ = ws.ReadMessage()
|
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
cardRevision := revision.Card
|
cardRevision := revision.Card
|
||||||
|
|
||||||
// update B profile
|
// update B profile
|
||||||
@ -56,9 +45,8 @@ func TestProfileNotification(t *testing.T) {
|
|||||||
assert.NoError(t, ReadResponse(w, nil))
|
assert.NoError(t, ReadResponse(w, nil))
|
||||||
|
|
||||||
// receive revision
|
// receive revision
|
||||||
ws.SetReadDeadline(time.Now().Add(2 * time.Second))
|
err = StatusRevision(ws, &revision)
|
||||||
_, data, _ = ws.ReadMessage()
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, json.Unmarshal(data, &revision))
|
|
||||||
assert.NotEqual(t, cardRevision, revision.Card)
|
assert.NotEqual(t, cardRevision, revision.Card)
|
||||||
|
|
||||||
// get views list of cards
|
// get views list of cards
|
||||||
@ -68,7 +56,4 @@ func TestProfileNotification(t *testing.T) {
|
|||||||
assert.NoError(t, ReadResponse(w, &views))
|
assert.NoError(t, ReadResponse(w, &views))
|
||||||
assert.Equal(t, len(views), 1)
|
assert.Equal(t, len(views), 1)
|
||||||
assert.NotEqual(t, profileRevision, views[0].RemoteProfile)
|
assert.NotEqual(t, profileRevision, views[0].RemoteProfile)
|
||||||
|
|
||||||
// stop notification thread
|
|
||||||
ExitNotifications()
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user