onasty/e2e/apiv1_notes_authoirzed_test.go (view raw)
Smirnov Oleksandr
Smirnov Oleksandr
ss2316544@gmail.com feat: add password support to notes (#41)..., 1 year ago
ss2316544@gmail.com feat: add password support to notes (#41)..., 1 year ago
| 1 | package e2e_test |
| 2 | |
| 3 | import "net/http" |
| 4 | |
| 5 | func (e *AppTestSuite) TestNoteV1_Create_authorized() { |
| 6 | uid, toks := e.createAndSingIn(e.uuid()+"@test.com", e.uuid(), "password") |
| 7 | httpResp := e.httpRequest( |
| 8 | http.MethodPost, |
| 9 | "/api/v1/note", |
| 10 | e.jsonify(apiv1NoteCreateRequest{ //nolint:exhaustruct |
| 11 | Content: "some random ass content for the test", |
| 12 | }), |
| 13 | toks.AccessToken, |
| 14 | ) |
| 15 | |
| 16 | var body apiv1NoteCreateResponse |
| 17 | e.readBodyAndUnjsonify(httpResp.Body, &body) |
| 18 | |
| 19 | dbNote := e.getNoteFromDBbySlug(body.Slug) |
| 20 | dbNoteAuthor := e.getLastNoteAuthorsRecordByAuthorID(uid) |
| 21 | |
| 22 | e.Equal(http.StatusCreated, httpResp.Code) |
| 23 | e.Equal(dbNote.ID.String(), dbNoteAuthor.noteID.String()) |
| 24 | } |