CloudMigrations: Add unit tests for snapshot management (#89521)
* add regex support for api tests * revert dumb thing * add api tests * add unit test for core async workflow * add xorm store unit tests * fix typo * remove unnecessary assignment
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/cloudmigration"
|
||||
"github.com/grafana/grafana/pkg/services/gcom"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
var fixedDate = time.Date(2024, 6, 5, 17, 30, 40, 0, time.UTC)
|
||||
@@ -140,7 +139,7 @@ func (m FakeServiceImpl) CreateSnapshot(ctx context.Context, sessionUid string)
|
||||
return nil, fmt.Errorf("mock error")
|
||||
}
|
||||
return &cloudmigration.CloudMigrationSnapshot{
|
||||
UID: util.GenerateShortUID(),
|
||||
UID: "fake_uid",
|
||||
SessionUID: sessionUid,
|
||||
Status: cloudmigration.SnapshotStatusUnknown,
|
||||
}, nil
|
||||
@@ -151,8 +150,8 @@ func (m FakeServiceImpl) GetSnapshot(ctx context.Context, sessionUid string, sna
|
||||
return nil, fmt.Errorf("mock error")
|
||||
}
|
||||
return &cloudmigration.CloudMigrationSnapshot{
|
||||
UID: util.GenerateShortUID(),
|
||||
SessionUID: sessionUid,
|
||||
UID: "fake_uid",
|
||||
SessionUID: "fake_uid",
|
||||
Status: cloudmigration.SnapshotStatusUnknown,
|
||||
}, nil
|
||||
}
|
||||
@@ -163,12 +162,12 @@ func (m FakeServiceImpl) GetSnapshotList(ctx context.Context, query cloudmigrati
|
||||
}
|
||||
return []cloudmigration.CloudMigrationSnapshot{
|
||||
{
|
||||
UID: util.GenerateShortUID(),
|
||||
UID: "fake_uid",
|
||||
SessionUID: query.SessionUID,
|
||||
Status: cloudmigration.SnapshotStatusUnknown,
|
||||
},
|
||||
{
|
||||
UID: util.GenerateShortUID(),
|
||||
UID: "fake_uid",
|
||||
SessionUID: query.SessionUID,
|
||||
Status: cloudmigration.SnapshotStatusUnknown,
|
||||
},
|
||||
@@ -181,3 +180,10 @@ func (m FakeServiceImpl) UploadSnapshot(ctx context.Context, sessionUid string,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m FakeServiceImpl) CancelSnapshot(ctx context.Context, sessionUid string, snapshotUid string) error {
|
||||
if m.ReturnError {
|
||||
return fmt.Errorf("mock error")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user