Skip to content

Commit

Permalink
Fix processor error return
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-gr committed Jun 20, 2023
1 parent 83b46b7 commit e6cce98
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 4 additions & 1 deletion internal/elasticsearch/ingest/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ func (p Pipeline) Processors() (procs []Processor, err error) {
default:
return nil, fmt.Errorf("unsupported pipeline format: %s", p.Format)
}
return procs, fmt.Errorf("failure processing %s pipeline '%s': %w", p.Format, p.Filename(), err)
if err != nil {
return nil, fmt.Errorf("failure processing %s pipeline '%s': %w", p.Format, p.Filename(), err)
}
return procs, nil
}

// extract a list of processors from a pipeline definition in YAML format.
Expand Down
12 changes: 3 additions & 9 deletions internal/elasticsearch/ingest/processors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,11 @@ processors:
}
procs, err := p.Processors()
if !tt.wantErr {
if !assert.NoError(t, err) {
t.Fatal(err)
}
assert.NoError(t, err)
} else {
if !assert.Error(t, err) {
t.Fatal("error expected")
}
}
if !assert.Equal(t, tt.expected, procs) {
t.Errorf("Processors() gotProcs = %v, want %v", procs, tt.expected)
assert.Error(t, err)
}
assert.Equal(t, tt.expected, procs)
})
}
}

0 comments on commit e6cce98

Please sign in to comment.