You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by eiri <gi...@git.apache.org> on 2015/09/25 15:45:12 UTC

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

GitHub user eiri opened a pull request:

    https://github.com/apache/couchdb-couch-log/pull/6

    Isolate couch_log from backend for unit testing

    This addresses the same issue fixed by latest @rnewson commit, just takes less integration testing and more unit testing approach.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cloudant/couchdb-couch-log isolate-unit-testing

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-couch-log/pull/6.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #6
    
----
commit 345c20662564aa50eb2be60d423bf2f0f7e20636
Author: Eric Avdey <ei...@eiri.ca>
Date:   2015-09-25T13:40:16Z

    Isolate couch_log from backend for unit testing
    
    This adds a custom backend for unit testing to decouple
    couch_log from project specific backend and allow to assert
    that callback calls carried through.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143295307
  
    you say 'just', but that's the entire point of mock objects. :)
    
    Are you saying that meck as I sketched would allow multiple calls to couch_log_eunit:warning/2 even though I said we :expect only one?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by eiri <gi...@git.apache.org>.
Github user eiri commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143728621
  
    @rnewson yes, meck does invalidate on none-expected calls, yet to get that behaviour the whole mocked module will need to be loaded and then unloaded for each severity, I haven't seen a way to make already mocked function 'unexpected'.
    
    My test based on validating of the whole history and checks that we are doing exactly right calls and doing them exactly once.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by eiri <gi...@git.apache.org>.
Github user eiri commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143232412
  
    @rnewson this is a fair idea, I'll do that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/couchdb-couch-log/pull/6


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by eiri <gi...@git.apache.org>.
Github user eiri commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143253787
  
    you mean we want to assert the whole history of the calls, not just the last call as it is right now?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143718736
  
    still, it's better than allowing calls to :warning when we're testing :debug.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143717775
  
    oh, that's ... terrible.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by eiri <gi...@git.apache.org>.
Github user eiri commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143302278
  
    Well, yes:
    ```
    Eshell V5.8.2  (abort with ^G)
    1> meck:new(couch_log_eunit, [non_strict]).
    ok
    2> meck:expect(couch_log_eunit, debug, 2, ok).
    ok
    3> couch_log_eunit:debug(a, b).
    ok
    4> couch_log_eunit:debug(a, b).
    ok
    5> meck:validate(couch_log_eunit).
    true
    ```
    
    Meck's `expect` lays out a contract, not defines the usage flow and meck's `validate` "just" confirms that that contract been respected, but not asserts in which fashion :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143277650
  
    No, I mean each test should have a mock backend that verifies what we expect to happen for that test;
    
    ```
    meck:expect(couch_log_eunit, debug, 2, ok),
    ?assertEqual(ok, couch_log:debug("message", [])),
    meck:validate()
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143229347
  
    oh, interesting. Hm, but why not use meck to mock the backend and then assert that it was called? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143252730
  
    This constructs a mock backend but does not confirm the behavior we want. We want to check that couch_log:X("", []) invokes backend_module:X("", []) for each level (and nothing else).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143743046
  
    Yes, agreed, I finally see it. +1.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request: Isolate couch_log from backend for...

Posted by eiri <gi...@git.apache.org>.
Github user eiri commented on the pull request:

    https://github.com/apache/couchdb-couch-log/pull/6#issuecomment-143291308
  
    Hm, `meck:validate/1` just checks if the whole mocked module has been used according to its expectations, i.e. that there was no calls with a wrong number of arguments or calls to non-existing function etc.
    
    I guess I can wrap each log level into its own suite with meck's load, expect, assert, validate and unload to ensure that we are calling backend's `X` function and nothing else, but my current test pretty much does the same thing, just with less typing and bonus of validating that we are not doing the double calls.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---