pow icon indicating copy to clipboard operation
pow copied to clipboard

Improving guides with unit tests

Open danschultzer opened this issue 6 years ago • 7 comments

The following guides may be improved with unit test examples:

  • [ ] https://github.com/danschultzer/pow/blob/master/guides/custom_controllers.md
  • [ ] https://github.com/danschultzer/pow/blob/master/guides/sync_user.md
  • [x] ~~https://github.com/danschultzer/pow/blob/master/guides/lock_users.md~~
  • [x] ~~https://github.com/danschultzer/pow/blob/master/guides/user_roles.md~~

There's already unit test in this guide:

https://github.com/danschultzer/pow/blob/master/guides/redis_cache_store_backend.md

I'm not sure if it makes sense for all the above guides, but I think in the case of user roles it could definitely be useful.

danschultzer avatar Jun 28 '19 17:06 danschultzer

I just wanted to say that, the amount of effort going into guides on this project is really great thank you!

As to the comment around if its worth it. I personally think guides can prove to provide more value than code in that it will take less effort to maintain guides and provide equal value. In addition I think it provides great value to the community at large as many new comers to phoenix and elixir in general will look to your guides. So again thank you!.

joshchernoff avatar Nov 15 '19 23:11 joshchernoff

Thanks @joshchernoff!

Yeah, documentation is really important, and I feel it's too often neglected in open source libraries. It's understandable since you can only do so much with your free time, but I do agree with you that it's equally important if not more so.

There's also a lot of planned guides for the website: https://github.com/pow-auth/pow_site/issues

danschultzer avatar Nov 15 '19 23:11 danschultzer

@danschultzer https://github.com/danschultzer/pow/pull/496 Added a first example for unittests in the lock users guide.

cdvv7788 avatar Apr 19 '20 19:04 cdvv7788

Thanks! I've fleshed it out a bit more, but haven't tested it yet.

danschultzer avatar Apr 20 '20 01:04 danschultzer

@cdvv7788 all tested, and pushed to the new https://github.com/pow-auth/pow_demo repo 😄

danschultzer avatar Apr 23 '20 17:04 danschultzer

@danschultzer nice! It was indeed a little problematic to test it. I had to create a project from scratch, configure it, etc. This should help with that in the future. Question: how do you plan on maintaining the demo? Will we need to run through all of the branches and perform the updates in there? Does it make sense to have a demo generator (probably more work but should be easier to maintain)?

cdvv7788 avatar Apr 23 '20 17:04 cdvv7788

Yeah, I think a generator would be great to have! For now it's just rebase and force push, not great 😄

Actually I've thought about a generator ever since I began working on Pow so you only had to run a single mix task without any adjustments. However there was no big libraries that did code injection, or at least I didn't find one that I particularly like.

Now with phx.gen.auth there might be a good way to do it: https://github.com/aaronrenner/phx_gen_auth/blob/master/lib/mix/phx_gen_auth/injector.ex

danschultzer avatar Apr 23 '20 17:04 danschultzer