Rename Helper to JobGetter

This commit is contained in:
Kenjiro Nakayama 2016-08-16 19:49:14 +09:00
parent c77fbcc67b
commit c25baab028
8 changed files with 18 additions and 18 deletions

View File

@ -229,18 +229,18 @@ READ:
return l.ReadCloser.Read(p)
}
type Helper struct {
type JobGetter struct {
// The fields below can be overwritten for tests
testStdin io.Reader
}
// StructJob returns the Job struct from jobfile.
func (h *Helper) StructJob(jpath string) (*structs.Job, error) {
func (j *JobGetter) StructJob(jpath string) (*structs.Job, error) {
var jobfile io.Reader
switch jpath {
case "-":
if h.testStdin != nil {
jobfile = h.testStdin
if j.testStdin != nil {
jobfile = j.testStdin
} else {
jobfile = os.Stdin
}

View File

@ -213,8 +213,8 @@ job "job1" {
t.Fatalf("err: %s", err)
}
h := &Helper{}
sj, err := h.StructJob(fh.Name())
j := &JobGetter{}
sj, err := j.StructJob(fh.Name())
if err != nil {
t.Fatalf("err: %s", err)
}

View File

@ -25,7 +25,7 @@ potentially invalid.`
type PlanCommand struct {
Meta
Helper
JobGetter
color *colorstring.Colorize
}
@ -99,7 +99,7 @@ func (c *PlanCommand) Run(args []string) int {
path := args[0]
// Get Job struct from Jobfile
job, err := c.Helper.StructJob(args[0])
job, err := c.JobGetter.StructJob(args[0])
if err != nil {
c.Ui.Error(fmt.Sprintf("Error getting job struct: %s", err))
return 1

View File

@ -110,8 +110,8 @@ func TestPlanCommand_From_STDIN(t *testing.T) {
ui := new(cli.MockUi)
cmd := &PlanCommand{
Meta: Meta{Ui: ui},
Helper: Helper{testStdin: stdinR},
Meta: Meta{Ui: ui},
JobGetter: JobGetter{testStdin: stdinR},
}
go func() {

View File

@ -21,7 +21,7 @@ var (
type RunCommand struct {
Meta
Helper
JobGetter
}
func (c *RunCommand) Help() string {
@ -120,7 +120,7 @@ func (c *RunCommand) Run(args []string) int {
}
// Get Job struct from Jobfile
job, err := c.Helper.StructJob(args[0])
job, err := c.JobGetter.StructJob(args[0])
if err != nil {
c.Ui.Error(fmt.Sprintf("Error getting job struct: %s", err))
return 1

View File

@ -156,8 +156,8 @@ func TestRunCommand_From_STDIN(t *testing.T) {
ui := new(cli.MockUi)
cmd := &RunCommand{
Meta: Meta{Ui: ui},
Helper: Helper{testStdin: stdinR},
Meta: Meta{Ui: ui},
JobGetter: JobGetter{testStdin: stdinR},
}
go func() {

View File

@ -7,7 +7,7 @@ import (
type ValidateCommand struct {
Meta
Helper
JobGetter
}
func (c *ValidateCommand) Help() string {
@ -43,7 +43,7 @@ func (c *ValidateCommand) Run(args []string) int {
}
// Get Job struct from Jobfile
job, err := c.Helper.StructJob(args[0])
job, err := c.JobGetter.StructJob(args[0])
if err != nil {
c.Ui.Error(fmt.Sprintf("Error getting job struct: %s", err))
return 1

View File

@ -111,8 +111,8 @@ func TestValidateCommand_From_STDIN(t *testing.T) {
ui := new(cli.MockUi)
cmd := &ValidateCommand{
Meta: Meta{Ui: ui},
Helper: Helper{testStdin: stdinR},
Meta: Meta{Ui: ui},
JobGetter: JobGetter{testStdin: stdinR},
}
go func() {