gothinkster / realworld

"The mother of all demo apps" — Exemplary fullstack Medium.com clone powered by React, Angular, Node, Django, and many more

Home Page:https://main--realworld-docs.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Golang + Slowpoke

recoilme opened this issue · comments

Hi,
Work in progress at https://github.com/recoilme/golang-gin-realworld-example-app
Slowpoke: https://github.com/recoilme/slowpoke
After finishing backend - i will start full stack on it

Looks like finished!)

Fullstack golang app - based on this backend - will live in the separate repo. Issue:
#234

This backend is finished 18 days ago. Does someone take a look at it?
@Cameron-C-Chapman ?

@recoilme I noticed that go test was removed from .travis.yml. Any reason for that? Also could you try running Postman API tests shown here. Thanks!

@anishkny
go test: No reason. I fork this repo from this realworld example:
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/.travis.yml

  • didn't see what go test commented( i uncomment this

Postman API tests: Also could you try running Postman API tests shown here.

I try. You have many errors in tests, fix it, please
For example your tests scripts send:
Create Article POST http://127.0.0.1:8081/api/articles [201 Created, 822B, 26ms]
Delete Article DELETE http://127.0.0.1:8081/api/articles/how-to-train-your-dragon [200 OK, 486B, 4ms]
Update Article PUT http://127.0.0.1:8081/api/articles/how-to-train-your-dragon [404 Not Found, 503B, 2ms]
Error: 26. Response contains "article" property //Realy ??
Favorite Article (deleted)
POST http://127.0.0.1:8081/api/articles/how-to-train-your-dragon/favorite [404 Not Found, 503B, 1ms]//Realy ??

Your test script update deleted article
You try favorite deleted article
And so on...

And i think you must add registration - at top of test, thats very strange - create user manualy

Very many logic errors in your test scripts, no time to fix all of them sorry(
Or may be it some problem in newman, I don't know, sorry

I add test log for you:

newman run postman.json -e env.json --global-var "EMAIL=jake@jake.jake" --global-var "PASSWORD=jakejake"
newman

Conduit

❏ Auth
↳ Login
  POST http://127.0.0.1:8081/api/users/login [200 OK, 661B, 101ms]
  ✓  Response contains "user" property
  ✓  User has "email" property
  ✓  User has "username" property
  ✓  User has "bio" property
  ✓  User has "image" property
  ✓  User has "token" property

↳ Login and Remember Token
  POST http://127.0.0.1:8081/api/users/login [200 OK, 661B, 87ms]
  ✓  Response contains "user" property
  ✓  User has "email" property
  ✓  User has "username" property
  ✓  User has "bio" property
  ✓  User has "image" property
  ✓  User has "token" property
  ✓  Environment variable "token" has been set

↳ Register
  POST http://127.0.0.1:8081/api/users [422 Unprocessable Entity, 545B, 84ms]
  1. Response contains "user" property
  2. User has "email" property
  3. User has "username" property
  4. User has "bio" property
  5. User has "image" property
  6. User has "token" property

↳ Current User
  GET http://127.0.0.1:8081/api/user [200 OK, 661B, 4ms]
  ✓  Response contains "user" property
  ✓  User has "email" property
  ✓  User has "username" property
  ✓  User has "bio" property
  ✓  User has "image" property
  ✓  User has "token" property

↳ Update User
  PUT http://127.0.0.1:8081/api/user [422 Unprocessable Entity, 545B, 2ms]
  7. Response contains "user" property
  8. User has "email" property
  9. User has "username" property
 10. User has "bio" property
 11. User has "image" property
 12. User has "token" property

❏ Articles
↳ All Articles
  GET http://127.0.0.1:8081/api/articles [200 OK, 491B, 5ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles by Author
  GET http://127.0.0.1:8081/api/articles?author=johnjacob [200 OK, 491B, 4ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles Favorited by Username
  GET http://127.0.0.1:8081/api/articles?favorited=jane [200 OK, 491B, 5ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles by Tag
  GET http://127.0.0.1:8081/api/articles?tag=dragons [200 OK, 491B, 3ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Single Article by slug
  GET http://127.0.0.1:8081/api/articles/how-to-train-your-dragon [404 Not Found, 503B, 5ms]
 13. Response contains "article" property
 14. Article has "title" property
 15. Article has "slug" property
 16. Article has "body" property
 17. Article has "createdAt" property
 18⠄ RangeError in test-script

❏ Articles with authentication
↳ Feed
  GET http://127.0.0.1:8081/api/articles/feed [404 Not Found, 504B, 1ms]
 19. Response code is 200 OK

↳ All Articles
  GET http://127.0.0.1:8081/api/articles [200 OK, 491B, 2ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ All Articles with auth
  GET http://127.0.0.1:8081/api/articles [200 OK, 491B, 1ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles by Author
  GET http://127.0.0.1:8081/api/articles?author=johnjacob [200 OK, 491B, 2ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles by Author with auth
  GET http://127.0.0.1:8081/api/articles?author=johnjacob [200 OK, 491B, 6ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles Favorited by Username
  GET http://127.0.0.1:8081/api/articles?favorited=jane [200 OK, 491B, 2ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles Favorited by Username with auth
  GET http://127.0.0.1:8081/api/articles?favorited=jane [200 OK, 491B, 1ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles by Tag
  GET http://127.0.0.1:8081/api/articles?tag=dragons [200 OK, 491B, 3ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Single Article by slug
  GET http://127.0.0.1:8081/api/articles/how-to-train-your-dragon [404 Not Found, 503B, 1ms]
 20. Response contains "article" property
 21. Article has "title" property
 22. Article has "slug" property
 23. Article has "body" property
 24. Article has "createdAt" property
 25⠄ RangeError in test-script

↳ Create Article
  POST http://127.0.0.1:8081/api/articles [201 Created, 822B, 26ms]
  ✓  Response contains "article" property
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  ✓  Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  ✓  Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer

↳ Delete Article
  DELETE http://127.0.0.1:8081/api/articles/how-to-train-your-dragon [200 OK, 486B, 4ms]

↳ Update Article
  PUT http://127.0.0.1:8081/api/articles/how-to-train-your-dragon [404 Not Found, 503B, 2ms]
 26. Response contains "article" property
 27. Article has "title" property
 28. Article has "slug" property
 29. Article has "body" property
 30. Article has "createdAt" property
 31⠄ RangeError in test-script

↳ Favorite Article
  POST http://127.0.0.1:8081/api/articles/how-to-train-your-dragon/favorite [404 Not Found, 503B, 1ms]
 32. Response contains "article" property
 33. Article has "title" property
 34. Article has "slug" property
 35. Article has "body" property
 36. Article has "createdAt" property
 37⠄ RangeError in test-script

↳ Unfavorite Article
  DELETE http://127.0.0.1:8081/api/articles/how-to-train-your-dragon/favorite [404 Not Found, 503B, 2ms]
 38. Response contains "article" property
 39. Article has "title" property
 40. Article has "slug" property
 41. Article has "body" property
 42. Article has "createdAt" property
 43⠄ RangeError in test-script

❏ Comments
↳ All Comments for Article
  GET http://127.0.0.1:8081/api/articles/how-to-train-your-dragon/comments [404 Not Found, 503B, 1ms]
 44. Response code is 200 OK

↳ Create Comment for Article
  POST http://127.0.0.1:8081/api/articles/how-to-train-your-dragon/comments [404 Not Found, 502B, 2ms]
 45. Response contains "comment" property
 46. Comment has "id" property
 47. Comment has "body" property
 48. Comment has "createdAt" property
 49⠄ RangeError in test-script

↳ Delete Comment for Article
  DELETE http://127.0.0.1:8081/api/articles/how-to-train-your-dragon/comments/1 [200 OK, 486B, 2ms]

❏ Profiles
↳ Profile
  GET http://127.0.0.1:8081/api/profiles/rick [404 Not Found, 506B, 1ms]
 50. Response code is 200 OK

↳ Follow Profile
  POST http://127.0.0.1:8081/api/profiles/rick/follow [404 Not Found, 506B, 2ms]
 51. Response code is 200 OK

↳ Unfollow Profile
  DELETE http://127.0.0.1:8081/api/profiles/rick/follow [404 Not Found, 506B, 1ms]
 52. Response code is 200 OK

❏ Tags
↳ All Tags
  GET http://127.0.0.1:8081/api/tags [200 OK, 489B, 5ms]
  ✓  Response code is 200 OK
  ✓  Response contains "tags" property
  ✓  "tags" property returned as array

┌─────────────────────────┬──────────┬──────────┐
│                         │ executed │   failed │
├─────────────────────────┼──────────┼──────────┤
│              iterations │        1 │        0 │
├─────────────────────────┼──────────┼──────────┤
│                requests │       31 │        0 │
├─────────────────────────┼──────────┼──────────┤
│            test-scripts │       29 │        6 │
├─────────────────────────┼──────────┼──────────┤
│      prerequest-scripts │        0 │        0 │
├─────────────────────────┼──────────┼──────────┤
│              assertions │      138 │       46 │
├─────────────────────────┴──────────┴──────────┤
│ total run duration: 1308ms                    │
├───────────────────────────────────────────────┤
│ total data received: 1.93KB (approx)          │
├───────────────────────────────────────────────┤
│ average response time: 11ms                   │
└───────────────────────────────────────────────┘

and in general - don't test web app with scripts - it's bad idea
most of errors you may find only with careful manual testing
but i understand what you don't have time for that, so very many submited apps contains errors. All, that i test) But may be that's not critical for education app

And one more thing - don't use my code in production
I just ported this project https://github.com/gothinkster/golang-gin-realworld-example-app
from sqlite to my database - but i don't do any code review

My app, as this app - absolutely ugly. It does tons of database requests on each web request
That's a terrible part of code what i don't fix, sorry for that.. I feel shame I just learned golang on this project.

I fixed it and write high load optimized code in another project, similar to real world - https://github.com/recoilme/tgram
But this project, as other written backends what i see - absolutely trash for real usage. But high load code on other hands - more hard to understand. So, i don't know what to do in this case. Many people copy paste bad, trash code, but on another hand - that's simplified code - easy to understand