func TestServerDiscoveryModelPOSTValidateReturnsErrorsWhenInvalidJSON(t *testing.T) {
	assert := test.NewAssert(t)

	server := NewServer(testJourney(), nullLogger(), &versionmock.Version{})
	defer func() {
		assert.NoError(server.Shutdown(context.TODO()))
	}()

	discoveryModel := `{ "bad-json" }`
	expected := `{"error": "code=400, message=Syntax error: offset=14, error=invalid character '}' after object key"}`

	code, body, headers := request(http.MethodPost, "/api/discovery-model",
		strings.NewReader(discoveryModel), server)

	assert.NotNil(body)
	assert.JSONEq(expected, body.String())
	assert.Equal(http.StatusBadRequest, code)
	assert.Equal(expectedJSONHeaders(), headers)
}
// /api/discovery-model/validate - POST - When invalid JSON returns error message
/api/discovery-model/validate - POST - When invalid JSON returns error message
// / api / discovery - model / validate - POST - When invalid JSON returns error message
func TestServerDiscoveryModelPOSTValidateReturnsErrorsWhenInvalidJSON(t *testing.T) {
	assert := test.NewAssert(t)
	server := NewServer(testJourney(), nullLogger(), &versionmock.Version{})
	defer func() {
		assert.NoError(server.Shutdown(context.TODO()))
	}()
	discoveryModel := `{ "bad-json" }`
	expected := `{"error": "code=400, message=Syntax error: offset=14, error=invalid character '}' after object key"}`
	code, body, headers := request(http.MethodPost, "/api/discovery-model",
		strings.NewReader(discoveryModel), server)
	assert.NotNil(body)
	assert.JSONEq(expected, body.String())
	assert.Equal(http.StatusBadRequest, code)
	assert.Equal(expectedJSONHeaders(), headers)
}
func TestServerDiscoveryModelPOSTValidateReturnsErrorsWhenInvalidJSON ( t * testing . T ) { assert := test . NewAssert ( t ) server := NewServer ( testJourney ( ) , nullLogger ( ) , & versionmock . Version { } ) defer func ( ) { assert . NoError ( server . Shutdown ( context . TODO ( ) ) ) } ( ) discoveryModel := `{ "bad-json" }` expected := `{"error": "code=400, message=Syntax error: offset=14, error=invalid character '}' after object key"}` code , body , headers := request ( http . MethodPost , " " , strings . NewReader ( discoveryModel ) , server ) assert . NotNil ( body ) assert . JSONEq ( expected , body . String ( ) ) assert . Equal ( http . StatusBadRequest , code ) assert . Equal ( expectedJSONHeaders ( ) , headers ) }
api/discovery-model/validate - POST - When invalid JSON returns error message
api / discovery - model / validate - POST - When invalid JSON returns error message