-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
191 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package daemon | ||
|
||
import "os/exec" | ||
|
||
// ServiceMock is the mock implementation of the Service interface. | ||
type ServiceMock struct { | ||
Command string | ||
processes map[int]*exec.Cmd | ||
Args []string | ||
ServiceStopResult bool | ||
ServiceStopError error | ||
ServiceList map[int]*exec.Cmd | ||
ServiceStartCmd *exec.Cmd | ||
ServicePort int | ||
ServiceStopCount int | ||
ServicesSetupCalled bool | ||
} | ||
|
||
// Setup the Management services. | ||
func (s *ServiceMock) Setup() { | ||
s.ServicesSetupCalled = true | ||
} | ||
|
||
// Stop a Service and returns the exit status. | ||
func (s *ServiceMock) Stop(pid int) (bool, error) { | ||
s.ServiceStopCount++ | ||
return s.ServiceStopResult, s.ServiceStopError | ||
} | ||
|
||
// List all Service PIDs. | ||
func (s *ServiceMock) List() map[int]*exec.Cmd { | ||
return s.ServiceList | ||
} | ||
|
||
// Start a Service and log its output. | ||
func (s *ServiceMock) Start() *exec.Cmd { | ||
return s.ServiceStartCmd | ||
} | ||
|
||
// NewService creates a new MockService with default settings. | ||
func (s *ServiceMock) NewService() (int, Service) { | ||
return s.ServicePort, s | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package daemon |