Chore: Remove Result field from datasources (#63048)

* Remove Result field from AddDataSourceCommand
* Remove DatasourcesPermissionFilterQuery Result
* Remove GetDataSourceQuery Result
* Remove GetDataSourcesByTypeQuery Result
* Remove GetDataSourcesQuery Result
* Remove GetDefaultDataSourceQuery Result
* Remove UpdateDataSourceCommand Result
This commit is contained in:
suntala
2023-02-09 15:49:44 +01:00
committed by GitHub
parent 8048a66e90
commit 49b3027049
47 changed files with 371 additions and 369 deletions
@@ -66,7 +66,7 @@ func TestBacktesting(t *testing.T) {
UserID: userId,
OrgID: 1,
}
err := env.Server.HTTPServer.DataSourcesService.AddDataSource(context.Background(), dsCmd)
_, err := env.Server.HTTPServer.DataSourcesService.AddDataSource(context.Background(), dsCmd)
require.NoError(t, err)
break
}
@@ -64,7 +64,7 @@ func TestIntegrationAzureMonitor(t *testing.T) {
}
uid := "azuremonitor"
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
OrgID: 1,
Access: datasources.DS_ACCESS_PROXY,
Name: "Azure Monitor",
+3 -2
View File
@@ -149,11 +149,12 @@ func (c TestContext) createUser(cmd user.CreateUserCommand) {
require.NoError(c.t, err)
}
func (c TestContext) createDs(cmd *datasources.AddDataSourceCommand) {
func (c TestContext) createDs(cmd *datasources.AddDataSourceCommand) *datasources.DataSource {
c.t.Helper()
err := c.env.Server.HTTPServer.DataSourcesService.AddDataSource(context.Background(), cmd)
dataSource, err := c.env.Server.HTTPServer.DataSourcesService.AddDataSource(context.Background(), cmd)
require.NoError(c.t, err)
return dataSource
}
func (c TestContext) createCorrelation(cmd correlations.CreateCorrelationCommand) correlations.Correlation {
@@ -47,16 +47,16 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
ReadOnly: true,
OrgID: 1,
}
ctx.createDs(createDsCommand)
readOnlyDS := createDsCommand.Result.UID
dataSource := ctx.createDs(createDsCommand)
readOnlyDS := dataSource.UID
createDsCommand = &datasources.AddDataSourceCommand{
Name: "writable",
Type: "loki",
OrgID: 1,
}
ctx.createDs(createDsCommand)
writableDs := createDsCommand.Result.UID
dataSource = ctx.createDs(createDsCommand)
writableDs := dataSource.UID
t.Run("Unauthenticated users shouldn't be able to create correlations", func(t *testing.T) {
res := ctx.Post(PostParams{
@@ -47,17 +47,17 @@ func TestIntegrationDeleteCorrelation(t *testing.T) {
ReadOnly: true,
OrgID: 1,
}
ctx.createDs(createDsCommand)
readOnlyDS := createDsCommand.Result.UID
dataSource := ctx.createDs(createDsCommand)
readOnlyDS := dataSource.UID
createDsCommand = &datasources.AddDataSourceCommand{
Name: "writable",
Type: "loki",
OrgID: 1,
}
ctx.createDs(createDsCommand)
writableDs := createDsCommand.Result.UID
writableDsOrgId := createDsCommand.Result.OrgID
dataSource = ctx.createDs(createDsCommand)
writableDs := dataSource.UID
writableDsOrgId := dataSource.OrgID
t.Run("Unauthenticated users shouldn't be able to delete correlations", func(t *testing.T) {
res := ctx.Delete(DeleteParams{
@@ -70,8 +70,7 @@ func TestIntegrationReadCorrelation(t *testing.T) {
Type: "loki",
OrgID: 1,
}
ctx.createDs(createDsCommand)
dsWithCorrelations := createDsCommand.Result
dsWithCorrelations := ctx.createDs(createDsCommand)
correlation := ctx.createCorrelation(correlations.CreateCorrelationCommand{
SourceUID: dsWithCorrelations.UID,
TargetUID: &dsWithCorrelations.UID,
@@ -88,8 +87,7 @@ func TestIntegrationReadCorrelation(t *testing.T) {
Type: "loki",
OrgID: 1,
}
ctx.createDs(createDsCommand)
dsWithoutCorrelations := createDsCommand.Result
dsWithoutCorrelations := ctx.createDs(createDsCommand)
// This creates 2 records in the correlation table that should never be returned by the API.
// Given all tests in this file work on the assumption that only a single correlation exists,
@@ -47,17 +47,17 @@ func TestIntegrationUpdateCorrelation(t *testing.T) {
ReadOnly: true,
OrgID: 1,
}
ctx.createDs(createDsCommand)
readOnlyDS := createDsCommand.Result.UID
dataSource := ctx.createDs(createDsCommand)
readOnlyDS := dataSource.UID
createDsCommand = &datasources.AddDataSourceCommand{
Name: "writable",
Type: "loki",
OrgID: 1,
}
ctx.createDs(createDsCommand)
writableDs := createDsCommand.Result.UID
writableDsOrgId := createDsCommand.Result.OrgID
dataSource = ctx.createDs(createDsCommand)
writableDs := dataSource.UID
writableDsOrgId := dataSource.OrgID
t.Run("Unauthenticated users shouldn't be able to update correlations", func(t *testing.T) {
res := ctx.Patch(PatchParams{
@@ -56,7 +56,7 @@ func TestIntegrationElasticsearch(t *testing.T) {
}
uid := "es"
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
OrgID: 1,
Access: datasources.DS_ACCESS_PROXY,
Name: "Elasticsearch",
+1 -1
View File
@@ -54,7 +54,7 @@ func TestIntegrationGraphite(t *testing.T) {
}
uid := "graphite"
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
OrgID: 1,
Access: datasources.DS_ACCESS_PROXY,
Name: "graphite",
+1 -1
View File
@@ -54,7 +54,7 @@ func TestIntegrationInflux(t *testing.T) {
}
uid := "influxdb"
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
OrgID: 1,
Access: datasources.DS_ACCESS_PROXY,
Name: "InfluxDB",
+1 -1
View File
@@ -54,7 +54,7 @@ func TestIntegrationLoki(t *testing.T) {
}
uid := "loki"
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
OrgID: 1,
Access: datasources.DS_ACCESS_PROXY,
Name: "Loki",
+1 -1
View File
@@ -54,7 +54,7 @@ func TestIntegrationOpenTSDB(t *testing.T) {
}
uid := "influxdb"
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
OrgID: 1,
Access: datasources.DS_ACCESS_PROXY,
Name: "opentsdb",
@@ -302,17 +302,17 @@ func newTestScenario(t *testing.T, name string, opts []testScenarioOption, callb
tsCtx.modifyIncomingRequest = in.modifyIncomingRequest
tsCtx.testEnv.OAuthTokenService.Token = in.token
err = testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, cmd)
_, err = testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, cmd)
require.NoError(t, err)
getDataSourceQuery := &datasources.GetDataSourceQuery{
OrgID: 1,
UID: tsCtx.uid,
}
err = testEnv.Server.HTTPServer.DataSourcesService.GetDataSource(ctx, getDataSourceQuery)
dataSource, err := testEnv.Server.HTTPServer.DataSourcesService.GetDataSource(ctx, getDataSourceQuery)
require.NoError(t, err)
rt, err := testEnv.Server.HTTPServer.DataSourcesService.GetHTTPTransport(ctx, getDataSourceQuery.Result, testEnv.HTTPClientProvider)
rt, err := testEnv.Server.HTTPServer.DataSourcesService.GetHTTPTransport(ctx, dataSource, testEnv.HTTPClientProvider)
require.NoError(t, err)
tsCtx.rt = rt
+1 -1
View File
@@ -55,7 +55,7 @@ func TestIntegrationPrometheus(t *testing.T) {
}
uid := "prometheus"
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
OrgID: 1,
Access: datasources.DS_ACCESS_PROXY,
Name: "Prometheus",