Skip to content
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

[1/2] Add tests for user-facing behavior #70

Merged
merged 10 commits into from
Jun 1, 2017
Merged

Commits on May 26, 2017

  1. [1/2] Add tests for user-facing behavior

    TL;DR: This PR adds integration tests, which fail. Fixing the tests is a much
    larger change made in a separate PR.
    
    As I was working on some Fx modules that use dig, I noticed some behavior that
    surprised me. In exploring dig's code, I realized that many of my assumptions
    about how the library should behave aren't covered by dig's testing suite.
    
    In this PR, I've added a bunch of end-to-end tests in the top-level dig package.
    Those tests *only* use the public `Provide` and `Invoke` APIs to verify that the
    behaviors Fx needs work correctly. I haven't altered any of dig's production
    code.
    
    Unfortunately, these tests exposed a number of bugs:
    
    ```
    $ go test . | grep FAIL
    
        # Container.Provide(nil) panics.
    --- FAIL: TestCantProvideUntypedNil (0.00s)
    
        # The container allows us to provide errors, but via some code paths.
    --- FAIL: TestCantProvideErrors (0.00s)
    
        # All types in the graph must have their deps satisfied, even if nobody's
        # using them.
    --- FAIL: TestIncompleteGraphIsOkay (0.00s)
    
        # Container doesn't detect cycles.
    --- FAIL: TestProvideCycleFails (0.00s)
    
    --- FAIL: TestEndToEndSuccess (0.00s)
        # We can't provide slices or maps from standard constructor functions, but
        # we can provide instances. Elaborate constructors like `func() []Foo, int,
        # error` also work correctly.
        --- FAIL: TestEndToEndSuccess/slice_constructor (0.00s)
        --- FAIL: TestEndToEndSuccess/map_constructor (0.00s)
    
        # We can't provide both []Foo and Foo, since dig considers them the same
        # type.
        --- FAIL: TestEndToEndSuccess/collections_and_instances_of_same_type (0.00s)
    ```
    
    This is concerning to me, since dig has 89% code coverage. Fixing these bugs and
    structuring the code so that we can confidently refactor without breaking
    user-facing behavior was a larger change, so I've broken it out into a separate
    PR.
    Akshay Shah committed May 26, 2017
    Configuration menu
    Copy the full SHA
    cc5eac8 View commit details
    Browse the repository at this point in the history

Commits on May 30, 2017

  1. Use pointers in e2e tests

    Akshay Shah committed May 30, 2017
    Configuration menu
    Copy the full SHA
    ec46812 View commit details
    Browse the repository at this point in the history

Commits on May 31, 2017

  1. pointer*: assert value

    abhinav committed May 31, 2017
    Configuration menu
    Copy the full SHA
    850b9e0 View commit details
    Browse the repository at this point in the history
  2. struct*: redundant reference

    abhinav committed May 31, 2017
    Configuration menu
    Copy the full SHA
    a9fc2ca View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    88f3cd0 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a5a8e37 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    6899b6e View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    aee8ee9 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    849e746 View commit details
    Browse the repository at this point in the history
  8. super nit

    abhinav committed May 31, 2017
    Configuration menu
    Copy the full SHA
    e3bfd0c View commit details
    Browse the repository at this point in the history