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

refactor(all): Small refactor #193

Merged
merged 1 commit into from
Dec 26, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions client/service_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ func (s *ServiceManager) Start() *exec.Cmd {
}
}()

scanner2 := bufio.NewScanner(cmdReaderErr)
scannerErr := bufio.NewScanner(cmdReaderErr)
go func() {
for scanner2.Scan() {
log.Printf("[ERROR] service: %s\n", scanner2.Text())
for scannerErr.Scan() {
log.Printf("[ERROR] service: %s\n", scannerErr.Text())
}
}()

Expand Down
3 changes: 1 addition & 2 deletions command/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ var installCmd = &cobra.Command{

// Run the installer
i := install.NewInstaller()
var err error
if err = i.CheckInstallation(); err != nil {
if err := i.CheckInstallation(); err != nil {
log.Println("[ERROR] Your Pact CLI installation is out of date, please update to the latest version. Error:", err)
os.Exit(1)
}
Expand Down
7 changes: 3 additions & 4 deletions dsl/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ type PactClient struct {
}

// newClient creates a new Pact client manager with the provided services
func newClient(MockServiceManager client.Service, verificationServiceManager client.Service, messageServiceManager client.Service, publishServiceManager client.Service) *PactClient {
MockServiceManager.Setup()
func newClient(mockServiceManager client.Service, verificationServiceManager client.Service, messageServiceManager client.Service, publishServiceManager client.Service) *PactClient {
mockServiceManager.Setup()
verificationServiceManager.Setup()
messageServiceManager.Setup()
publishServiceManager.Setup()

return &PactClient{
pactMockSvcManager: MockServiceManager,
pactMockSvcManager: mockServiceManager,
verificationSvcManager: verificationServiceManager,
messageSvcManager: messageServiceManager,
publishSvcManager: publishServiceManager,
Expand Down Expand Up @@ -165,7 +165,6 @@ func (p *PactClient) VerifyProvider(request types.VerifyRequest) ([]types.Provid

err = waitForPort(port, p.getNetworkInterface(), address, p.TimeoutDuration,
fmt.Sprintf(`Timed out waiting for Provider API to start on port %d - are you sure it's running?`, port))

if err != nil {
return response, err
}
Expand Down
8 changes: 4 additions & 4 deletions dsl/pact.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,13 @@ var checkCliCompatibility = func() {

// BeforeEachMiddleware is invoked before any other, only on the __setup
// request (to avoid duplication)
func BeforeEachMiddleware(BeforeEach types.Hook) proxy.Middleware {
func BeforeEachMiddleware(beforeEach types.Hook) proxy.Middleware {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == providerStatesSetupPath {

log.Println("[DEBUG] executing before hook")
err := BeforeEach()
err := beforeEach()

if err != nil {
log.Println("[ERROR] error executing before hook:", err)
Expand All @@ -461,14 +461,14 @@ func BeforeEachMiddleware(BeforeEach types.Hook) proxy.Middleware {
// AfterEachMiddleware is invoked after any other, and is the last
// function to be called prior to returning to the test suite. It is
// therefore not invoked on __setup
func AfterEachMiddleware(AfterEach types.Hook) proxy.Middleware {
func AfterEachMiddleware(afterEach types.Hook) proxy.Middleware {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
next.ServeHTTP(w, r)

if r.URL.Path != providerStatesSetupPath {
log.Println("[DEBUG] executing after hook")
err := AfterEach()
err := afterEach()

if err != nil {
log.Println("[ERROR] error executing after hook:", err)
Expand Down
4 changes: 2 additions & 2 deletions dsl/pact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,9 @@ func TestPact_StateHandlerMiddlewarePassThroughInvalidPath(t *testing.T) {
}

func dummyHandler(header string) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set(header, "true")
})
}
}

func TestPact_AddMessage(t *testing.T) {
Expand Down