Chore: Aggregate save dashboard error (#26443)

* Chore: Aggregate save dashboard error
* Use errors package for error detection

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
This commit is contained in:
gastonqiu
2020-07-21 11:12:01 +02:00
committed by GitHub
co-authored by Arve Knudsen Sofia Papagiannaki
parent 3c72b2f988
commit f427f90a45
7 changed files with 151 additions and 64 deletions
+1 -1
View File
@@ -103,7 +103,7 @@ func (dr *dashboardServiceImpl) buildSaveDashboardCommand(dto *SaveDashboardDTO,
if !util.IsValidShortUID(dash.Uid) {
return nil, models.ErrDashboardInvalidUid
} else if len(dash.Uid) > 40 {
return nil, models.ErrDashboardUidToLong
return nil, models.ErrDashboardUidTooLong
}
if err := validateDashboardRefreshInterval(dash); err != nil {
@@ -75,7 +75,7 @@ func TestDashboardService(t *testing.T) {
{Uid: "asdf90_-", Error: nil},
{Uid: "asdf/90", Error: models.ErrDashboardInvalidUid},
{Uid: " asdfghjklqwertyuiopzxcvbnmasdfghjklqwer ", Error: nil},
{Uid: "asdfghjklqwertyuiopzxcvbnmasdfghjklqwertyuiopzxcvbnmasdfghjklqwertyuiopzxcvbnm", Error: models.ErrDashboardUidToLong},
{Uid: "asdfghjklqwertyuiopzxcvbnmasdfghjklqwertyuiopzxcvbnmasdfghjklqwertyuiopzxcvbnm", Error: models.ErrDashboardUidTooLong},
}
for _, tc := range testCases {