Skip to content

Commit

Permalink
feat: upgrade to ffi 0.1.2, w\ support for branches. Fixes #180
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Nov 17, 2021
1 parent 965f535 commit 5a48fa6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 23 deletions.
4 changes: 2 additions & 2 deletions installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ const (
var packages = map[string]packageInfo{
FFIPackage: {
libName: "libpact_ffi",
version: "0.1.0",
semverRange: ">= 0.1.0, < 1.0.0",
version: "0.1.2",
semverRange: ">= 0.1.2, < 1.0.0",
},
}

Expand Down
7 changes: 2 additions & 5 deletions internal/native/message_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ typedef int bool;
typedef struct MessageHandle MessageHandle;
struct MessageHandle {
uintptr_t pact;
uintptr_t message;
unsigned int interaction_ref;
};
/// Wraps a PactMessage model struct
typedef struct MessagePactHandle MessagePactHandle;
struct MessagePactHandle {
uintptr_t pact;
unsigned int pact_ref;
};
MessagePactHandle pactffi_new_message_pact(const char *consumer_name, const char *provider_name);
Expand Down Expand Up @@ -161,8 +160,6 @@ func (i *Message) WithContents(contentType string, body []byte) *Message {
cHeader := C.CString(contentType)
defer free(cHeader)

cBytes := C.CString(string(body))
defer free(cBytes)
C.pactffi_message_with_contents(i.handle, cHeader, (*C.char)(unsafe.Pointer(&body[0])), C.int(len(body)))

return i
Expand Down
17 changes: 2 additions & 15 deletions internal/native/mock_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,13 @@ char* pactffi_version();
typedef struct InteractionHandle InteractionHandle;
struct InteractionHandle {
uintptr_t pact;
uintptr_t interaction;
};
typedef struct MessageHandle MessageHandle;
struct MessageHandle {
uintptr_t pact;
uintptr_t message;
unsigned int interaction_ref;
};
/// Wraps a Pact model struct
typedef struct PactHandle PactHandle;
struct PactHandle {
uintptr_t pact;
};
/// Wraps a PactMessage model struct
typedef struct MessagePactHandle MessagePactHandle;
struct MessagePactHandle {
uintptr_t pact;
unsigned int pact_ref;
};
/// External interface to cleanup a mock server. This function will try terminate the mock server
Expand Down
3 changes: 3 additions & 0 deletions message/message_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"reflect"
"testing"

"github.com/pact-foundation/pact-go/v2/internal/native"
mockserver "github.com/pact-foundation/pact-go/v2/internal/native"
)

Expand All @@ -35,6 +36,8 @@ func NewMessagePactV3(config MessageConfig) (*MessagePactV3, error) {
return nil, err
}

native.Init()

return provider, err
}

Expand Down
2 changes: 2 additions & 0 deletions provider/http_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"testing"
"time"

native "github.com/pact-foundation/pact-go/v2/internal/native"
"github.com/pact-foundation/pact-go/v2/models"
"github.com/pact-foundation/pact-go/v2/proxy"
)
Expand Down Expand Up @@ -119,6 +120,7 @@ func (v *HTTPVerifier) verifyProviderRaw(request VerifyRequest, writer outputWri
}

log.Println("[DEBUG] pact provider verification")
native.Init()

return verificationRequest.Verify(writer)
}
Expand Down
1 change: 0 additions & 1 deletion provider/verify_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ func (v *VerifyRequest) Verify(writer outputWriter) error {
fmt.Sprintf(`Timed out waiting for Provider API to start on port %d - are you sure it's running?`, port))

service := native.Verifier{}
native.Init()
res := service.Verify(v.args)

return res
Expand Down

0 comments on commit 5a48fa6

Please sign in to comment.