Require batch

This commit is contained in:
Alex Dadgar
2016-12-16 15:20:12 -08:00
parent d1ecd38c25
commit c308ef7e49
2 changed files with 19 additions and 2 deletions

View File

@@ -1271,6 +1271,11 @@ func (j *Job) Validate() error {
}
if j.IsConstructor() {
if j.Type != JobTypeBatch {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("Constructor job can only be used with %q scheduler", JobTypeBatch))
}
if err := j.Constructor.Validate(); err != nil {
mErr.Errors = append(mErr.Errors, err)
}

View File

@@ -1445,7 +1445,7 @@ func TestVault_Validate(t *testing.T) {
}
}
func TestDispatchConfig_Validate(t *testing.T) {
func TestConstructorConfig_Validate(t *testing.T) {
d := &ConstructorConfig{
Payload: "foo",
}
@@ -1463,7 +1463,19 @@ func TestDispatchConfig_Validate(t *testing.T) {
}
}
func TestDispatchConfig_Canonicalize(t *testing.T) {
func TestConstructorConfig_Validate_NonBatch(t *testing.T) {
job := testJob()
job.Constructor = &ConstructorConfig{
Payload: DispatchPayloadOptional,
}
job.Type = JobTypeSystem
if err := job.Validate(); err == nil || !strings.Contains(err.Error(), "only be used with") {
t.Fatalf("Expected bad scheduler tpye: %v", err)
}
}
func TestConstructorConfig_Canonicalize(t *testing.T) {
d := &ConstructorConfig{}
d.Canonicalize()
if d.Payload != DispatchPayloadOptional {