From eb08774370a0240f07a6235edceb53dd29aa2aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 4 Mar 2021 16:48:06 +0100 Subject: [PATCH] Assert that `executeTemplate` is invoked --- pkg/cmd/api/api_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/cmd/api/api_test.go b/pkg/cmd/api/api_test.go index 75132d7b4..3b2acb6cf 100644 --- a/pkg/cmd/api/api_test.go +++ b/pkg/cmd/api/api_test.go @@ -426,6 +426,20 @@ func Test_apiRun(t *testing.T) { stdout: "HTTP/1.1 200 Okey-dokey\nContent-Type: text/plain\r\n\r\n", stderr: ``, }, + { + name: "output template", + options: ApiOptions{ + Template: `{{.status}}`, + }, + httpResponse: &http.Response{ + StatusCode: 200, + Body: ioutil.NopCloser(bytes.NewBufferString(`{"status":"not a cat"}`)), + Header: http.Header{"Content-Type": []string{"application/json"}}, + }, + err: nil, + stdout: "not a cat", + stderr: ``, + }, } for _, tt := range tests {