mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 21:52:43 +08:00
refactoring: moved compare dashboard version command out of sqlstore, the code in this command did not use any sql operations and was more high level, could be moved out and use existing queries to get the versions
This commit is contained in:
@ -98,59 +98,3 @@ func TestGetDashboardVersions(t *testing.T) {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestCompareDashboardVersions(t *testing.T) {
|
||||
Convey("Testing dashboard version comparison", t, func() {
|
||||
InitTestDB(t)
|
||||
|
||||
savedDash := insertTestDashboard("test dash 43", 1, "x")
|
||||
updateTestDashboard(savedDash, map[string]interface{}{
|
||||
"tags": "y",
|
||||
})
|
||||
|
||||
Convey("Compare two versions that are different", func() {
|
||||
query := m.GetDashboardVersionsQuery{DashboardId: savedDash.Id, OrgId: 1}
|
||||
|
||||
err := GetDashboardVersions(&query)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(query.Result), ShouldEqual, 2)
|
||||
|
||||
cmd := m.CompareDashboardVersionsCommand{
|
||||
DashboardId: savedDash.Id,
|
||||
BaseVersion: query.Result[0].Version,
|
||||
NewVersion: query.Result[1].Version,
|
||||
DiffType: m.DiffDelta,
|
||||
}
|
||||
|
||||
err = CompareDashboardVersionsCommand(&cmd)
|
||||
So(err, ShouldBeNil)
|
||||
So(cmd.Delta, ShouldNotBeNil)
|
||||
})
|
||||
|
||||
Convey("Compare two versions that are the same", func() {
|
||||
cmd := m.CompareDashboardVersionsCommand{
|
||||
DashboardId: savedDash.Id,
|
||||
BaseVersion: savedDash.Version,
|
||||
NewVersion: savedDash.Version,
|
||||
DiffType: m.DiffDelta,
|
||||
}
|
||||
|
||||
err := CompareDashboardVersionsCommand(&cmd)
|
||||
So(err, ShouldNotBeNil)
|
||||
So(cmd.Delta, ShouldBeNil)
|
||||
})
|
||||
|
||||
Convey("Compare two versions that don't exist", func() {
|
||||
cmd := m.CompareDashboardVersionsCommand{
|
||||
DashboardId: savedDash.Id,
|
||||
BaseVersion: 123,
|
||||
NewVersion: 456,
|
||||
DiffType: m.DiffDelta,
|
||||
}
|
||||
|
||||
err := CompareDashboardVersionsCommand(&cmd)
|
||||
So(err, ShouldNotBeNil)
|
||||
So(cmd.Delta, ShouldBeNil)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user