Skip to content

Commit

Permalink
Fix response type for ingest pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
olivere committed Aug 5, 2019
1 parent 6da3cc8 commit 0f67219
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Jacob [@jdelgad](https://github.com/jdelgad)
Jan Düpmeier [@jduepmeier](https://github.com/jduepmeier)
Jayme Rotsaert [@jrots](https://github.com/jrots)
Jean-Alexandre Beaumont [@Enteris](https://github.com/Enteris)
Jean-François Roche [@jfroche](https://github.com/jfroche)
Jeff Rand [@jeffrand](https://github.com/jeffrand)
Jeremy Canady [@jrmycanady](https://github.com/jrmycanady)
Jérémie Vexiau [@texvex](https://github.com/texvex)
Expand Down
8 changes: 6 additions & 2 deletions ingest_get_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ func (s *IngestGetPipelineService) Do(ctx context.Context) (IngestGetPipelineRes
// IngestGetPipelineResponse is the response of IngestGetPipelineService.Do.
type IngestGetPipelineResponse map[string]*IngestGetPipeline

// IngestGetPipeline describes a specific ingest pipeline, its
// processors etc.
type IngestGetPipeline struct {
ID string `json:"id"`
Config map[string]interface{} `json:"config"`
Description string `json:"description"`
Processors []map[string]interface{} `json:"processors"`
Version int64 `json:"version,omitempty"`
OnFailure []map[string]interface{} `json:"on_failure,omitempty"`
}
48 changes: 29 additions & 19 deletions ingest_get_pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package elastic

import (
"context"
"log"
"os"
"testing"
)

Expand Down Expand Up @@ -46,7 +48,7 @@ func TestIngestGetPipelineURL(t *testing.T) {
}

func TestIngestLifecycle(t *testing.T) {
client := setupTestClientAndCreateIndexAndAddDocs(t) //, SetTraceLog(log.New(os.Stdout, "", 0)))
client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", 0)))

// With the new ES Docker images, XPack is already installed and returns a pipeline. So we cannot test for "no pipelines". Skipping for now.
/*
Expand Down Expand Up @@ -84,27 +86,35 @@ func TestIngestLifecycle(t *testing.T) {
}

// Get all pipelines again
getres, err := client.IngestGetPipeline().Do(context.TODO())
if err != nil {
t.Fatal(err)
}
if have := len(getres); have == 0 {
t.Fatalf("expected at least 1 pipeline, got %d", have)
}
if _, found := getres["my-pipeline"]; !found {
t.Fatalf("expected to find pipline with id %q", "my-pipeline")
{
getres, err := client.IngestGetPipeline().Do(context.TODO())
if err != nil {
t.Fatal(err)
}
if have := len(getres); have == 0 {
t.Fatalf("expected at least 1 pipeline, got %d", have)
}
pipeline, found := getres["my-pipeline"]
if !found {
t.Fatalf("expected to find pipline with id %q", "my-pipeline")
}
if want, have := "reset retweets", pipeline.Description; want != have {
t.Fatalf("expected pipeline description of %q, have %q", want, have)
}
}

// Get pipeline by ID
getres, err = client.IngestGetPipeline("my-pipeline").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
if want, have := 1, len(getres); want != have {
t.Fatalf("expected %d pipelines, got %d", want, have)
}
if _, found := getres["my-pipeline"]; !found {
t.Fatalf("expected to find pipline with id %q", "my-pipeline")
{
getres, err := client.IngestGetPipeline("my-pipeline").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
if want, have := 1, len(getres); want != have {
t.Fatalf("expected %d pipelines, got %d", want, have)
}
if _, found := getres["my-pipeline"]; !found {
t.Fatalf("expected to find pipline with id %q", "my-pipeline")
}
}

// Delete pipeline
Expand Down

0 comments on commit 0f67219

Please sign in to comment.