From bee20a159c93a072ea017b59bb7896fc09baf838 Mon Sep 17 00:00:00 2001 From: Fabian Vowie Date: Sat, 15 Jan 2022 13:01:13 +0100 Subject: [PATCH] Return pipeline metadata in pipeline route --- main.go | 2 +- main_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 2574244..0f43e55 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,7 @@ type Metadata struct { func PipelineHandle(pipeline IPipeline, w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(true) + json.NewEncoder(w).Encode(pipeline) } func IndexHandler(w http.ResponseWriter, r *http.Request) { diff --git a/main_test.go b/main_test.go index 64710c3..3540a04 100644 --- a/main_test.go +++ b/main_test.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "net/http" "net/http/httptest" "testing" @@ -50,6 +51,8 @@ func TestEndpointRoute(t *testing.T) { router.ServeHTTP(responseRecorder, request) assert.Equal(t, responseRecorder.Code, 200) + body, _ := json.Marshal(givenEndpoint) + assert.JSONEq(t, string(body), responseRecorder.Body.String()) }) t.Run("Unregistered pipelines return 404", func(t *testing.T) {