mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 19:05:42 +03:00
Require batch
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user