mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
testing expired view
This commit is contained in:
parent
4bb89658d8
commit
d37b5a2e17
@ -89,7 +89,7 @@ func GetArticles(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if viewRevisionSet || articleRevisionSet {
|
if viewRevisionSet || articleRevisionSet {
|
||||||
if viewRevision != card.ViewRevision {
|
if viewRevision != card.ViewRevision {
|
||||||
ErrResponse(w, http.StatusGone, errors.New("artivle view has changed"))
|
ErrResponse(w, http.StatusGone, errors.New("article view has changed"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ func TestShareAttribute(t *testing.T) {
|
|||||||
var cViewRevision int64
|
var cViewRevision int64
|
||||||
var bArticleRevision int64
|
var bArticleRevision int64
|
||||||
var cArticleRevision int64
|
var cArticleRevision int64
|
||||||
|
hdr := map[string][]string{}
|
||||||
|
|
||||||
// setup testing group
|
// setup testing group
|
||||||
set, err := AddTestGroup("shareattribute")
|
set, err := AddTestGroup("shareattribute")
|
||||||
@ -145,6 +146,13 @@ func TestShareAttribute(t *testing.T) {
|
|||||||
nil, nil, APP_TOKENAPP, set.C.Token, cards, nil))
|
nil, nil, APP_TOKENAPP, set.C.Token, cards, nil))
|
||||||
assert.Equal(t, 1, len(*cards))
|
assert.Equal(t, 1, len(*cards))
|
||||||
cRev = rev
|
cRev = rev
|
||||||
|
articles = &[]Article{}
|
||||||
|
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles",
|
||||||
|
nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, &hdr))
|
||||||
|
assert.Equal(t, 1, len(*articles))
|
||||||
|
assert.Equal(t, "nestedimage", (*articles)[0].Data.DataType)
|
||||||
|
cArticleRevision, _ = strconv.ParseInt(hdr["Article-Revision"][0], 10, 64)
|
||||||
|
cViewRevision, _ = strconv.ParseInt(hdr["View-Revision"][0], 10, 64)
|
||||||
|
|
||||||
// unshare article with B
|
// unshare article with B
|
||||||
param["articleId"] = article.Id
|
param["articleId"] = article.Id
|
||||||
@ -175,10 +183,6 @@ func TestShareAttribute(t *testing.T) {
|
|||||||
card = &Card{}
|
card = &Card{}
|
||||||
param["cardId"] = set.C.A.CardId
|
param["cardId"] = set.C.A.CardId
|
||||||
GetTestRevision(set.B.Revisions)
|
GetTestRevision(set.B.Revisions)
|
||||||
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}",
|
|
||||||
¶m, nil, APP_TOKENCONTACT, set.C.Token, card, nil))
|
|
||||||
cArticleRevision = card.Data.NotifiedArticle
|
|
||||||
cViewRevision = card.Data.NotifiedView
|
|
||||||
|
|
||||||
// delete article
|
// delete article
|
||||||
param["articleId"] = article.Id
|
param["articleId"] = article.Id
|
||||||
@ -205,5 +209,12 @@ func TestShareAttribute(t *testing.T) {
|
|||||||
nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, nil))
|
nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, nil))
|
||||||
assert.Equal(t, 1, len(*articles))
|
assert.Equal(t, 1, len(*articles))
|
||||||
assert.Nil(t, (*articles)[0].Data)
|
assert.Nil(t, (*articles)[0].Data)
|
||||||
|
|
||||||
|
// test view change
|
||||||
|
rView = strconv.FormatInt(cViewRevision - 1, 10)
|
||||||
|
rArticle = strconv.FormatInt(cArticleRevision - 1, 10)
|
||||||
|
articles = &[]Article{}
|
||||||
|
assert.Error(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle,
|
||||||
|
nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user