|
|
|
|
@ -5,6 +5,7 @@ import ( |
|
|
|
|
"os" |
|
|
|
|
"path/filepath" |
|
|
|
|
"testing" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
"github.com/google/uuid" |
|
|
|
|
"github.com/grafana/grafana/pkg/api/routing" |
|
|
|
|
@ -350,6 +351,36 @@ func Test_OnlyQueriesStatusFromGMSWhenRequired(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func Test_DeletedDashboardsNotMigrated(t *testing.T) { |
|
|
|
|
s := setUpServiceTest(t, false).(*Service) |
|
|
|
|
// modify what the mock returns for just this test case
|
|
|
|
|
dashMock := s.dashboardService.(*dashboards.FakeDashboardService) |
|
|
|
|
dashMock.On("GetAllDashboards", mock.Anything).Return( |
|
|
|
|
[]*dashboards.Dashboard{ |
|
|
|
|
{ |
|
|
|
|
UID: "1", |
|
|
|
|
Data: simplejson.New(), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
UID: "2", |
|
|
|
|
Data: simplejson.New(), |
|
|
|
|
Deleted: time.Now(), |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
nil, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
data, err := s.getMigrationDataJSON(context.TODO(), &user.SignedInUser{OrgID: 1}) |
|
|
|
|
assert.NoError(t, err) |
|
|
|
|
dashCount := 0 |
|
|
|
|
for _, it := range data.Items { |
|
|
|
|
if it.Type == cloudmigration.DashboardDataType { |
|
|
|
|
dashCount++ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
assert.Equal(t, 1, dashCount) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ctxWithSignedInUser() context.Context { |
|
|
|
|
c := &contextmodel.ReqContext{ |
|
|
|
|
SignedInUser: &user.SignedInUser{OrgID: 1}, |
|
|
|
|
@ -400,7 +431,9 @@ func setUpServiceTest(t *testing.T, withDashboardMock bool) cloudmigration.Servi |
|
|
|
|
|
|
|
|
|
s, err := ProvideService( |
|
|
|
|
cfg, |
|
|
|
|
featuremgmt.WithFeatures(featuremgmt.FlagOnPremToCloudMigrations), |
|
|
|
|
featuremgmt.WithFeatures( |
|
|
|
|
featuremgmt.FlagOnPremToCloudMigrations, |
|
|
|
|
featuremgmt.FlagDashboardRestore), |
|
|
|
|
sqlStore, |
|
|
|
|
dsService, |
|
|
|
|
secretsService, |
|
|
|
|
|