This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
charmbits/service: first steps towards mocking services
- Loading branch information
Showing
4 changed files
with
194 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package service | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/juju/juju/service/common" | ||
"github.com/juju/juju/service/upstart" | ||
) | ||
|
||
// OSServiceParams holds the parameters for | ||
// creating a new service. | ||
type OSServiceParams struct { | ||
// Name holds the name of the service. | ||
Name string | ||
|
||
// Description holds the description of the service. | ||
Description string | ||
|
||
// Output holds the file where output will be put. | ||
Output string | ||
|
||
// Exe holds the name of the executable to run. | ||
Exe string | ||
|
||
// Args holds any arguments to the executable, | ||
// which should be OK to to pass to the shell | ||
// without quoting. | ||
Args []string | ||
} | ||
|
||
// NewService is used to create a new service. | ||
// It is defined as a variable so that it can be | ||
// replaced for testing purposes. | ||
var NewService = func(p OSServiceParams) OSService { | ||
cmd := p.Exe + " " + strings.Join(p.Args, " ") | ||
return &upstart.Service{ | ||
Name: p.Name, | ||
Conf: common.Conf{ | ||
InitDir: "/etc/init", | ||
Desc: p.Description, | ||
Cmd: cmd, | ||
Out: p.Output, | ||
}, | ||
} | ||
} |
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