-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow adapters to run test suite with their db #31
Conversation
Codecov Report
@@ Coverage Diff @@
## master #31 +/- ##
==========================================
- Coverage 83.63% 81.81% -1.82%
==========================================
Files 3 3
Lines 55 55
Branches 13 12 -1
==========================================
- Hits 46 45 -1
- Misses 9 10 +1
Continue to review full report at Codecov.
|
Hm, I just tried this for the
The tests exist though, everything is exactly where it needs to be... Any ideas what's going wrong here? |
This is a bug upstream in |
Okay I've managed to circumvent the bug with a super ugly and slow, but working, hack. I I've verified this works with the flat-file-db adapter. @relekang would you mind giving this a try? |
This looks neat 🙂 I did not get it to run on the redis adapter 😕
|
Hmm, will take a look later! |
Picking this back up, switching to |
Okay this works now. Slightly changed instructions, but it's largely the same! 🎉 The tests of the main repo now test the main repo, but they can also be used to test any third party adapter. I'll do the
|
Damn this is still failing due to |
🤔 Yeah, probably because we don't get the dev dependencies of a dependency. Adding the necessary dependencies in the adapter might be a solution? or is that what the npm i in adapter.test.js is about? |
I'm |
@i appreciate the attempt to use Node for this but it might be easier to keep node out of the equation when triggering the tests to be run. The invocation seems to work if you do it manually and don't try to use require. What if an adapter could just list micro-analytics-cli as a node devDependency then trigger the tests via bash/npm script. The micro-analytics-cli would first npm install the dependencies but then would manually copy the adapter from the cwd into the child node_modules folder of the cli. The idea here is that the invocation of node doesn't happen until the dependency structure has been setup using just bash. The bash command would look something like |
If you think that could work out please take a stab at it! I'm really stuck here. |
I'll see what I can scrape together. |
I think we also might need an adapter test suite that has a few basic unit tests, since a test that fails for the micro-analytics project might be hard to track down for people who are not very familiar with the codebase. What I am suggestion is to have What do you think? |
Sure! |
…tics into adapter-tests
Closing this as I think we need to start over if we want to revisit this after the #69. However, I think the approach of writing specific tests for adapters works nicely so far. |
This adds a simple script that makes it possible to run our own test suite against a newly written adapter. Usage would be like so:
Testing your adapter
micro-analytics
contains an test suite to verify everything works as expected. We also export this test suite to make it possible to verify your adapter works as expected!To run our test suite with your adapter (we recommend doing this in CI too) you only have to do three steps:
First,
npm install --save-dev micro-analytics-cli
to get the test suite.Second, create a new file called
test.js
which contains this code: (don't forget to replace'./index'
with the relative path to your main entry file!)Finally, run our test suite with your db adapter with
node test.js
! 🎉@relekang I've published a pre-release version containing this change under
micro-analytics-cli@dev
. Mind trying this on yourmicro-analytics-adapter-redis
and seeing if it works?Closes #19