You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by GitBox <gi...@apache.org> on 2022/08/18 17:32:11 UTC

[GitHub] [tinkerpop] good41898 commented on pull request #1786: export Result field

good41898 commented on PR #1786:
URL: https://github.com/apache/tinkerpop/pull/1786#issuecomment-1219753208

   To give an example of the issue, I have abstracted the gremlin-go driver into an interface like this:
   ```
   GremlinGoDriver interface {
      Submit(traversalString string) (gremlingo.ResultSet, error)
      Close()
   }
   ```
   
   Which contains the two methods of the driver that I use. While unit testing, I am able to mock out any methods (like the Submit() and Close() method) as long as the function signatures for the mocked methods match the signatures of the actual methods. Where I am running into issues is when trying to mock returned data from a `ResultSet` object. I am able to create a new struct containing the result set so I can mock those methods (like the ResultSet.All() method) as well, like this:
   
   ```
   type MockResultSet struct {
     ResultSet
    }
    
    func (m MockResultSet) All() ([]*Result, error) {
       var res []*Result
       return  res
    }
   ```
     
   However, since the function signatures must match, this mocked All() method must return a Result object, which I cannot assign data to as the result field is non-exported.
   
   Let me know if this is helpful/ makes sense. Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org