open-nomad/nomad/periodic_test.go

39 lines
645 B
Go
Raw Normal View History

2015-12-01 22:54:57 +00:00
package nomad
import (
"fmt"
"github.com/hashicorp/nomad/nomad/structs"
)
type MockPeriodic struct {
Enabled bool
Jobs map[string]*structs.Job
}
func NewMockPeriodic() *MockPeriodic {
return &MockPeriodic{Jobs: make(map[string]*structs.Job)}
}
func (m *MockPeriodic) SetEnabled(enabled bool) {
m.Enabled = enabled
}
func (m *MockPeriodic) Add(job *structs.Job) error {
if job == nil {
return fmt.Errorf("Must pass non nil job")
}
m.Jobs[job.ID] = job
return nil
}
func (m *MockPeriodic) Remove(jobID string) error {
delete(m.Jobs, jobID)
return nil
}
func (m *MockPeriodic) ForceRun(jobID string) error {
return nil
}