Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update prismPath and update prism binary #80

Merged
merged 3 commits into from
Sep 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions sendgrid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package sendgrid
import (
"bytes"
"fmt"
"github.com/sendgrid/rest"
"io"
"net/http"
"net/http/httptest"
Expand All @@ -13,12 +12,14 @@ import (
"strings"
"testing"
"time"

"github.com/sendgrid/rest"
)

var (
testAPIKey = "SENDGRID_APIKEY"
testHost = ""
prismPath = os.Getenv("GOPATH") + "/bin"
prismPath = "prism"
prismArgs = []string{"run", "-s", "https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json"}
prismCmd *exec.Cmd
buffer bytes.Buffer
Expand All @@ -31,7 +32,6 @@ func TestMain(m *testing.M) {
// Learn how to configure prism here: https://designer.stoplight.io/docs/prism
testHost = "http://localhost:4010"

prismPath += "/prism"
if runtime.GOOS == "windows" {
prismPath += ".exe"
}
Expand All @@ -58,6 +58,19 @@ func TestMain(m *testing.M) {
fmt.Fprintf(os.Stderr, "Please download the Windows binary (https://github.com/stoplightio/prism/releases) and place it in your $GOPATH/bin directory")
os.Exit(1)
}
} else {
updatePrismCmd := exec.Command(prismPath, "up")
err := updatePrismCmd.Start()
if err != nil {
fmt.Println("Error updating prism, please download an update! (https://github.com/stoplightio/prism/releases)", err)
} else {
fmt.Println("Waiting for prism to update...")
err = updatePrismCmd.Wait()
if err != nil {
fmt.Println("Error updating prism, please download an update! (https://github.com/stoplightio/prism/releases)", err)
}
fmt.Println("Prism is now up to date!")
}
}

prismCmd = exec.Command(prismPath, prismArgs...)
Expand Down