Chore: Moves common and response into separate packages (#30298)
* Chore: moves common and response into separate packages * Chore: moves common and response into separate packages * Update pkg/api/utils/common.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Chore: changes after PR comments * Chore: move wrap to routing package * Chore: move functions in common to response package * Chore: move functions in common to response package * Chore: formats imports Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
co-authored by
Arve Knudsen
parent
a94c256516
commit
3d41267fc4
@@ -4,6 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/api/routing"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -61,7 +63,7 @@ func TestAddDataSource_InvalidURL(t *testing.T) {
|
||||
|
||||
sc := setupScenarioContext(t, "/api/datasources")
|
||||
|
||||
sc.m.Post(sc.url, Wrap(func(c *models.ReqContext) Response {
|
||||
sc.m.Post(sc.url, routing.Wrap(func(c *models.ReqContext) response.Response {
|
||||
return AddDataSource(c, models.AddDataSourceCommand{
|
||||
Name: "Test",
|
||||
Url: "invalid:url",
|
||||
@@ -91,7 +93,7 @@ func TestAddDataSource_URLWithoutProtocol(t *testing.T) {
|
||||
|
||||
sc := setupScenarioContext(t, "/api/datasources")
|
||||
|
||||
sc.m.Post(sc.url, Wrap(func(c *models.ReqContext) Response {
|
||||
sc.m.Post(sc.url, routing.Wrap(func(c *models.ReqContext) response.Response {
|
||||
return AddDataSource(c, models.AddDataSourceCommand{
|
||||
Name: name,
|
||||
Url: url,
|
||||
@@ -109,7 +111,7 @@ func TestUpdateDataSource_InvalidURL(t *testing.T) {
|
||||
|
||||
sc := setupScenarioContext(t, "/api/datasources/1234")
|
||||
|
||||
sc.m.Put(sc.url, Wrap(func(c *models.ReqContext) Response {
|
||||
sc.m.Put(sc.url, routing.Wrap(func(c *models.ReqContext) response.Response {
|
||||
return AddDataSource(c, models.AddDataSourceCommand{
|
||||
Name: "Test",
|
||||
Url: "invalid:url",
|
||||
@@ -139,7 +141,7 @@ func TestUpdateDataSource_URLWithoutProtocol(t *testing.T) {
|
||||
|
||||
sc := setupScenarioContext(t, "/api/datasources/1234")
|
||||
|
||||
sc.m.Put(sc.url, Wrap(func(c *models.ReqContext) Response {
|
||||
sc.m.Put(sc.url, routing.Wrap(func(c *models.ReqContext) response.Response {
|
||||
return AddDataSource(c, models.AddDataSourceCommand{
|
||||
Name: name,
|
||||
Url: url,
|
||||
|
||||
Reference in New Issue
Block a user