Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Print stack for unexpected call #171

Closed

Conversation

msabramo
Copy link
Contributor

@msabramo msabramo commented Apr 10, 2018

Print stack for Unexpected call errors

so the user who is running the tests can see exactly where/why the function is being called. E.g.:

------------------------------
• Failure [0.002 seconds]
Handlers
/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/handlers_test.go:46
  List
  /Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/handlers_test.go:85
    works [It]
    /Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/handlers_test.go:86

    Unexpected call to *mock_db.MockWrapper.Select([0xc4201908a0 SELECT * FROM ApplicationDefinition]) at /Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/mocks/shared/db/wrapper.go:82 because: there are no expected calls of the method "Select" for that receiver
    Stack: git.corp.adobe.com/adobe-platform/flight-director/mocks/shared/db.(*MockWrapper).Select
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/mocks/shared/db/wrapper.go:82
    git.corp.adobe.com/adobe-platform/flight-director/shared/db.(*QueryFilter).SelectIntoEntities
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/shared/db/query_filter.go:74
    git.corp.adobe.com/adobe-platform/flight-director/shared/models.GetApplicationDefinitionList
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/shared/models/application.go:153
    git.corp.adobe.com/adobe-platform/flight-director/shared/models.GetAllApplicationDefinition
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/shared/models/application.go:166
    git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications.(*Dispatcher).List
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/handlers.go:228
    git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications.(*Dispatcher).List-fm
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/dispatcher.go:26
    net/http.HandlerFunc.ServeHTTP
    	/usr/local/Cellar/go/1.10/libexec/src/net/http/server.go:1947
    git.corp.adobe.com/adobe-platform/flight-director/vendor/github.com/gorilla/mux.(*Router).ServeHTTP
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/vendor/github.com/gorilla/mux/mux.go:159
    git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications.glob..func2.3.1
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/handlers_test.go:89


    /Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/mocks/shared/db/wrapper.go:82
------------------------------

This has a dependency on github.com/pkg/errors, which I simply vendored in to make things simple and easy for users of github.com/golang/mock.

Cc: @seanisom, @mayanand, @balshetzer

@mayanand
Copy link

This will be very helpful. Currently, it is more of a trial and error to find this info.

@msabramo msabramo force-pushed the print-stack-for-unexpected-call branch from c7b7034 to 946653f Compare April 10, 2018 20:44
@msabramo msabramo force-pushed the print-stack-for-unexpected-call branch 3 times, most recently from fce40a6 to 03613f8 Compare April 10, 2018 22:28
@msabramo
Copy link
Contributor Author

msabramo commented Jun 1, 2018

Bump

@msabramo
Copy link
Contributor Author

ping

@raylillywhite
Copy link

It'd be great to get this merged into the main repo. I've been using the fork and it's helped immensely.

@msabramo
Copy link
Contributor Author

Anything I can do to help this get merged?

@poy
Copy link
Collaborator

poy commented Nov 30, 2018

@msabramo

@balshetzer and I discussed this offline. We think it might be best to have this more as an opt-in. We are proposing (#238) a way to add options to the controller. I think this PR would be a good fit as an option.

so the user can see exactly why the function is being called. E.g.:

```
------------------------------
• Failure [0.002 seconds]
Handlers
/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/handlers_test.go:46
  List
  /Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/handlers_test.go:85
    works [It]
    /Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/handlers_test.go:86

    Unexpected call to *mock_db.MockWrapper.Select([0xc4201908a0 SELECT * FROM ApplicationDefinition]) at /Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/mocks/shared/db/wrapper.go:82 because: there are no expected calls of the method "Select" for that receiver
    Stack: git.corp.adobe.com/adobe-platform/flight-director/mocks/shared/db.(*MockWrapper).Select
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/mocks/shared/db/wrapper.go:82
    git.corp.adobe.com/adobe-platform/flight-director/shared/db.(*QueryFilter).SelectIntoEntities
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/shared/db/query_filter.go:74
    git.corp.adobe.com/adobe-platform/flight-director/shared/models.GetApplicationDefinitionList
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/shared/models/application.go:153
    git.corp.adobe.com/adobe-platform/flight-director/shared/models.GetAllApplicationDefinition
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/shared/models/application.go:166
    git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications.(*Dispatcher).List
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/handlers.go:228
    git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications.(*Dispatcher).List-fm
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/dispatcher.go:26
    net/http.HandlerFunc.ServeHTTP
    	/usr/local/Cellar/go/1.10/libexec/src/net/http/server.go:1947
    git.corp.adobe.com/adobe-platform/flight-director/vendor/github.com/gorilla/mux.(*Router).ServeHTTP
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/vendor/github.com/gorilla/mux/mux.go:159
    git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications.glob..func2.3.1
    	/Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/server/routes/applications/handlers_test.go:89

    /Users/abramowi/go/src/git.corp.adobe.com/adobe-platform/flight-director/mocks/shared/db/wrapper.go:82
------------------------------
```
with `github.com/pkg/errors` for its stack trace functionality
@msabramo msabramo force-pushed the print-stack-for-unexpected-call branch from 03613f8 to 8623138 Compare August 14, 2019 00:44
@msabramo
Copy link
Contributor Author

I rebased and fixed merge conflicts. I'll have to look at the options you added to see how I can incorporate it into my code. Any quick tips?

@poy poy self-requested a review September 27, 2019 04:42
@poy
Copy link
Collaborator

poy commented Sep 27, 2019

Hey sorry for the radio silence on this!

If you're still interested, I would love to discuss it further with you. A few things:

  • I would prefer if we could avoid vendoring. I think modules offers a decent solution for that.
  • This feel like something the verbose flag should have some say in (e.g., this extra stack information is printed only when go test -v is used. WDYT?

@poy poy self-assigned this Sep 27, 2019
@codyoss
Copy link
Member

codyoss commented Nov 20, 2019

@msabramo Thoughts?

@codyoss
Copy link
Member

codyoss commented Dec 27, 2019

I am going to close this for now due to lack of inactivity. Please reopen if you are still interested in working on this. Thanks.

@codyoss codyoss closed this Dec 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants