Browse Source
Return pipeline metadata in pipeline route
feature/add-pipeline-endpoints
Fabian Vowie
3 years ago
No known key found for this signature in database
GPG Key ID: C27317C33B27C410
2 changed files with
4 additions and
1 deletions
-
main.go
-
main_test.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) { |
|
|
|
|
|
@ -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) { |
|
|
|