alexedwards / scs

HTTP Session Management for Go
MIT License
2.09k stars 166 forks source link

Session should implement interface to be mockable #97

Closed titouanfreville closed 1 year ago

titouanfreville commented 4 years ago

Hello, To simplify unit testing, it would be nice to implement an interface on the main Session object. Though an interface will mask inner field, implementing an interface and being able to have the Session as interface would greatly simplify clean unit test for code.

alexedwards commented 4 years ago

Hi,

Can you explain/give an example of what you're currently doing and why it is 'unclean'? Is it because you don't want to wrap the handler with LoadAndSave() for the purpose of unit testing that handler alone?

titouanfreville commented 4 years ago

Hy,

It is under unit test where I don't even want to know how the session is used.

Basically, I have a session package with multiple potential implementation, all those implementation needs to be tested from a unit point of vue and simulating the all process of SCS is to heavy under unit testing as it will require to either force memstore object and manipulate http request where I don't want to see them.

I could also wrap the scs package but it's not really nice to do so. ^^

alexedwards commented 1 year ago

I don't want to take this forward at the moment. I'm going to close this issue.