-
Notifications
You must be signed in to change notification settings - Fork 24
Resource generator should generate default tests #245
Comments
@markbates i can take this one :) |
@apaganobeleno if you need some help, just let me know. |
@as27 would you like to take this one? i'm afraid i wont have much time for the next month and don't want to delay this more. |
@apaganobeleno yes of course. I would love to help out here. |
@markbates I would make the tests analog to the todo app. The tests will also use |
That makes sense. |
The test generator is almost ready. But when I run the tests I receive always return code 500. I think I need a little help to understand why. The template file for the generator would be here: I made a own repository for a generated example. The output after code generation is: But when I run |
@as27 Giving a quick look, it seems you have a typo in https://github.com/as27/buffalo/blob/resource-test-generator/generators/resource/templates/actions/resource-use_model_test.go.tmpl line 49
The other errors seem linked to the lack of CSRF token in your request, but the suite utils should disable this middleware. |
@stanislas-m thanks. CSRF was the missing link I didn't see. But that issue is more a |
@as27, as I understand the way the CSRF is handled in the test suite, it just replaces the middleware with a no-op. Maybe I'm wrong, but I think the Maybe the edit: I found a |
@stanislas-m thank you. I had the same thoughts about this. |
@as27, I also think preventing the middleware to do its work is a bad thing. What we should test, is the normal case, with a given token. The CSRF token is stored in the buffalo context, and in the session (key name is "authenticity_token"). Maybe you can do a first query to get a valid token, and manage to get the token from either the context or the session. |
Hello guys ! I really like the idea of having a basic set of tests generated automatically. Cheers |
Will be looking into this once gobuffalo/buffalo#1521 is merged, it should make this change a lot easier |
Right now it generates tests that look like this:
It would be fantastic if these tests were actually implemented when generating a new resource.
This ticket is not for the faint of heart. :)
The text was updated successfully, but these errors were encountered: