mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
testing articles in contact app
This commit is contained in:
parent
eff8279ce4
commit
187452727b
@ -72,7 +72,7 @@ func (a *TestApp) UpdateArticle() (err error) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
revision := strconv.FormatInt(a.revision.Article, 10)
|
revision := strconv.FormatInt(a.revision.Article, 10)
|
||||||
params := &TestApiParams{ query: "/articles?revision=" + revision, tokenType: APP_TOKENAPP, token: a.token }
|
params := &TestApiParams{ query: "/articles?articleRevision=" + revision, tokenType: APP_TOKENAPP, token: a.token }
|
||||||
response := &TestApiResponse{ data: &articles }
|
response := &TestApiResponse{ data: &articles }
|
||||||
if err = TestApiRequest(GetArticles, params, response); err != nil {
|
if err = TestApiRequest(GetArticles, params, response); err != nil {
|
||||||
return
|
return
|
||||||
|
@ -39,5 +39,34 @@ func TestContactApp(t *testing.T) {
|
|||||||
return false
|
return false
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// add a new article
|
||||||
|
article := &Article{}
|
||||||
|
subject := &Subject{ Data: "subjectdata", DataType: "subjectdatatype" }
|
||||||
|
params := &TestApiParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAPP, token: set.A.Token, body: subject }
|
||||||
|
response := &TestApiResponse{ data: article }
|
||||||
|
assert.NoError(t, TestApiRequest(AddArticle, params, response))
|
||||||
|
|
||||||
|
// wait for a
|
||||||
|
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
|
||||||
|
a, set := testApp.articles[article.Id]
|
||||||
|
if set && a.Data.Data == "subjectdata" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}))
|
||||||
|
|
||||||
|
// remove a new article
|
||||||
|
params = &TestApiParams{ restType: "DELETE", query: "/articles/{articleId}", path: map[string]string{ "articleId": article.Id },
|
||||||
|
tokenType: APP_TOKENAPP, token: set.A.Token, body: subject }
|
||||||
|
response = &TestApiResponse{}
|
||||||
|
assert.NoError(t, TestApiRequest(RemoveArticle, params, response))
|
||||||
|
|
||||||
|
// wait for a to be removed
|
||||||
|
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
|
||||||
|
if _, set := testApp.articles[article.Id]; !set {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user