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
+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{