mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
testing card disconnection
This commit is contained in:
parent
16faf5eaf9
commit
6deaeba63d
@ -108,6 +108,7 @@ func SetCardStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
slot.Card.NotifiedArticle = articleRevision
|
slot.Card.NotifiedArticle = articleRevision
|
||||||
slot.Card.NotifiedChannel = channelRevision
|
slot.Card.NotifiedChannel = channelRevision
|
||||||
slot.Card.NotifiedProfile = profileRevision
|
slot.Card.NotifiedProfile = profileRevision
|
||||||
|
slot.Card.DetailRevision += 1
|
||||||
|
|
||||||
// save and update contact revision
|
// save and update contact revision
|
||||||
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
@ -63,6 +63,9 @@ func SetCloseMessage(w http.ResponseWriter, r *http.Request) {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if res := tx.Model(&card).Update("detail_revision", account.CardRevision + 1).Error; res != nil {
|
||||||
|
return res
|
||||||
|
}
|
||||||
if res := tx.Model(&slot).Update("revision", account.CardRevision + 1).Error; res != nil {
|
if res := tx.Model(&slot).Update("revision", account.CardRevision + 1).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@ -178,4 +178,28 @@ func TestContactApp(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// disconnect from B
|
||||||
|
card := &Card{}
|
||||||
|
params = &TestApiParams{ restType: "PUT", query: "/contact/cards/{cardId}/status", tokenType: APP_TOKENAPP, token: set.B.Token,
|
||||||
|
path: map[string]string{ "cardId": set.B.A.CardId }, body: APP_CARDCONFIRMED }
|
||||||
|
response = &TestApiResponse{ data: card }
|
||||||
|
assert.NoError(t, TestApiRequest(SetCardStatus, params, response))
|
||||||
|
msg := &DataMessage{}
|
||||||
|
params = &TestApiParams { query: "/contact/cards/{cardId}/closeMessage", tokenType: APP_TOKENAPP, token: set.B.Token,
|
||||||
|
path: map[string]string{ "cardId": set.B.A.CardId } }
|
||||||
|
response = &TestApiResponse{ data: msg }
|
||||||
|
assert.NoError(t, TestApiRequest(GetCloseMessage, params, response))
|
||||||
|
params = &TestApiParams { restType: "PUT", query: "/contact/closeMessage", body: msg }
|
||||||
|
response = &TestApiResponse{}
|
||||||
|
assert.NoError(t, TestApiRequest(SetCloseMessage, params, response))
|
||||||
|
|
||||||
|
// wait for
|
||||||
|
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
|
||||||
|
contact, contactSet := testApp.contacts[set.A.B.CardId]
|
||||||
|
if contactSet && contact.card.Data.CardDetail.Status == APP_CARDCONFIRMED {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user