mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 20:49:16 +00:00
adding profile test
This commit is contained in:
parent
57b6936226
commit
a2354704fc
@ -31,6 +31,7 @@ func getCardModel(card *store.Card) *Card {
|
|||||||
Revision: card.DataRevision,
|
Revision: card.DataRevision,
|
||||||
Status: card.Status,
|
Status: card.Status,
|
||||||
Notes: card.Notes,
|
Notes: card.Notes,
|
||||||
|
Token: card.OutToken,
|
||||||
Groups: groups,
|
Groups: groups,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -51,11 +51,13 @@ func AddTestContacts(t *testing.T, prefix string, count int) []string {
|
|||||||
return access
|
return access
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectTestContacts(t *testing.T, access [2]string) {
|
func ConnectTestContacts(t *testing.T, accessA string, accessB string) (contact [2]string) {
|
||||||
var card Card
|
var card Card
|
||||||
var msg DataMessage
|
var msg DataMessage
|
||||||
var vars map[string]string
|
var vars map[string]string
|
||||||
var contactStatus ContactStatus
|
var contactStatus ContactStatus
|
||||||
|
var id string
|
||||||
|
access := [2]string{accessA, accessB}
|
||||||
|
|
||||||
// get A identity message
|
// get A identity message
|
||||||
r, w, _ := NewRequest("GET", "/profile/message", nil)
|
r, w, _ := NewRequest("GET", "/profile/message", nil)
|
||||||
@ -84,6 +86,7 @@ func ConnectTestContacts(t *testing.T, access [2]string) {
|
|||||||
SetBearerAuth(r, access[1])
|
SetBearerAuth(r, access[1])
|
||||||
GetOpenMessage(w, r)
|
GetOpenMessage(w, r)
|
||||||
assert.NoError(t, ReadResponse(w, &msg))
|
assert.NoError(t, ReadResponse(w, &msg))
|
||||||
|
id = card.CardId
|
||||||
|
|
||||||
// set open message in A
|
// set open message in A
|
||||||
r, w, _ = NewRequest("PUT", "/contact/openMessage", msg)
|
r, w, _ = NewRequest("PUT", "/contact/openMessage", msg)
|
||||||
@ -136,4 +139,15 @@ func ConnectTestContacts(t *testing.T, access [2]string) {
|
|||||||
SetCardStatus(w, r)
|
SetCardStatus(w, r)
|
||||||
assert.NoError(t, ReadResponse(w, &card))
|
assert.NoError(t, ReadResponse(w, &card))
|
||||||
|
|
||||||
|
// extract contact tokens
|
||||||
|
contact[0] = card.CardData.Token
|
||||||
|
r, w, _ = NewRequest("GET", "/contact/cards/{cardId}", nil)
|
||||||
|
vars = map[string]string{ "cardId": id }
|
||||||
|
r = mux.SetURLVars(r, vars)
|
||||||
|
SetBearerAuth(r, access[1])
|
||||||
|
GetCard(w, r)
|
||||||
|
assert.NoError(t, ReadResponse(w, &card))
|
||||||
|
contact[1] = card.CardData.Token
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
32
net/server/internal/ucProfileNotification_test.go
Normal file
32
net/server/internal/ucProfileNotification_test.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package databag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestProfileNotification(t *testing.T) {
|
||||||
|
|
||||||
|
// start notifcation thread
|
||||||
|
go SendNotifications()
|
||||||
|
|
||||||
|
access := AddTestContacts(t, "profilenotification", 2);
|
||||||
|
contact := ConnectTestContacts(t, access[0], access[1])
|
||||||
|
|
||||||
|
PrintMsg(access)
|
||||||
|
PrintMsg(contact)
|
||||||
|
|
||||||
|
// connect revision websocket for A
|
||||||
|
|
||||||
|
// get profile revision of B
|
||||||
|
|
||||||
|
// update profile of B
|
||||||
|
|
||||||
|
// read revision message
|
||||||
|
|
||||||
|
// check card increment
|
||||||
|
|
||||||
|
// check B profile incremented
|
||||||
|
|
||||||
|
// stop notification thread
|
||||||
|
ExitNotifications()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user