Skip to content

Commit

Permalink
feat: Update CheckVersion to accept a libDir in case of non-std install
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Jul 3, 2024
1 parent c80e188 commit 402bb0c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/protobuf-message/protobuf_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestPluginMessageProvider(t *testing.T) {
err := pactlog.SetLogLevel("TRACE")
assert.NoError(t, err)

pactversion.CheckVersion()
pactversion.CheckVersion("/tmp")

verifier := provider.NewVerifier()

Expand Down
6 changes: 4 additions & 2 deletions internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import (
"github.com/pact-foundation/pact-go/v2/internal/native"
)

func CheckInstall() error {
func CheckInstall(libDir string) error {
// initialised the lib registry. It just needs one of the main lib interfaces Version() here
installer.LibRegistry[installer.FFIPackage] = &native.MockServer{}

i, err := installer.NewInstaller()
if err != nil {
return err
}

if libDir != "" {
i.SetLibDir(libDir)
}
return i.CheckInstallation()
}
4 changes: 2 additions & 2 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
// CheckVersion checks if the currently installed version is within semver range
// and will attempt to download the files to the default or configured directory if
// incorrect
func CheckVersion() {
if err := checker.CheckInstall(); err != nil {
func CheckVersion(libDir string) {
if err := checker.CheckInstall(libDir); err != nil {
log.Fatal("check version failed:", err)
}

Expand Down

0 comments on commit 402bb0c

Please sign in to comment.