Uploaded image for project: 'Qpid Proton'
  1. Qpid Proton
  2. PROTON-2035

[go] Inability to mock Golang interfaces

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: proton-c-0.27.0
    • Fix Version/s: proton-c-0.28.0
    • Component/s: go-binding
    • Labels:
      None
    • Environment:
      Centos 7, Golang 1.11

      Description

      I'll preface this by saying, I'm new to using Golang so this could entirely be my misunderstanding.

      I'm trying to use Proton-C 0.27's Golang bindings to connect to a broker and receive messages from it which works fine. However I'm finding it hard to mock the Receiver and Connection interfaces using either Go Mock or Testify's mocks. Both complain that the mock interfaces can't be used as they don't have an electron.closed function, despite it being defined. 

      I believe this to be due to the closed and waitSync functions being defined in lowercase, changing them throughout the implementation to start with capitals makes the mock interfaces work fine. I understand they're lowercase however to keep them private to the package. 

      Is this an oversight in the implementation or is there a better way to mock Connections and Receivers without editing the original source code?

      Again I apologise if this is a simple matter, this is my first Golang project and mock implementation.

       

      Thank you,

      Matt

        Attachments

          Activity

            People

            • Assignee:
              aconway Alan Conway
              Reporter:
              fletch Matt Threlfall
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: