testing articles in contact app

This commit is contained in:
Roland Osborne 2022-02-21 21:52:49 -08:00
parent eff8279ce4
commit 187452727b
2 changed files with 30 additions and 1 deletions

View File

@ -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

View File

@ -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
}))
} }