File: not_implemented_test.go

package info (click to toggle)
golang-github-go-openapi-runtime 0.21.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 944 kB
  • sloc: sh: 9; makefile: 4
file content (20 lines) | stat: -rw-r--r-- 501 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package middleware

import (
	"net/http"
	"net/http/httptest"
	"testing"

	"github.com/go-openapi/runtime"
	"github.com/stretchr/testify/require"
)

func TestErrorResponder(t *testing.T) {
	resp := Error(http.StatusBadRequest, map[string]string{"message": "this is the error body"})

	rec := httptest.NewRecorder()
	resp.WriteResponse(rec, runtime.JSONProducer())

	require.Equal(t, http.StatusBadRequest, rec.Code)
	require.Equal(t, "{\"message\":\"this is the error body\"}\n", rec.Body.String())
}