Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
bdc6e2fe
Unverified
Commit
bdc6e2fe
authored
Nov 14, 2020
by
Emil Hessman
Committed by
GitHub
Nov 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chore: Require OrgId to be specified in delete playlist command (#29117)
parent
fbf0d2c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
pkg/services/sqlstore/playlist.go
+1
-1
pkg/services/sqlstore/playlist_test.go
+30
-2
No files found.
pkg/services/sqlstore/playlist.go
View file @
bdc6e2fe
...
...
@@ -108,7 +108,7 @@ func GetPlaylist(query *models.GetPlaylistByIdQuery) error {
}
func
DeletePlaylist
(
cmd
*
models
.
DeletePlaylistCommand
)
error
{
if
cmd
.
Id
==
0
{
if
cmd
.
Id
==
0
||
cmd
.
OrgId
==
0
{
return
models
.
ErrCommandValidationFailed
}
...
...
pkg/services/sqlstore/playlist_test.go
View file @
bdc6e2fe
...
...
@@ -3,6 +3,7 @@
package
sqlstore
import
(
"fmt"
"testing"
"github.com/grafana/grafana/pkg/models"
...
...
@@ -32,9 +33,36 @@ func TestPlaylistDataAccess(t *testing.T) {
})
t
.
Run
(
"Can remove playlist"
,
func
(
t
*
testing
.
T
)
{
query
:=
models
.
DeletePlaylistCommand
{
Id
:
1
}
err
=
DeletePlaylist
(
&
q
uery
)
deleteQuery
:=
models
.
DeletePlaylistCommand
{
Id
:
1
,
Org
Id
:
1
}
err
=
DeletePlaylist
(
&
deleteQ
uery
)
require
.
NoError
(
t
,
err
)
getQuery
:=
models
.
GetPlaylistByIdQuery
{
Id
:
1
}
err
=
GetPlaylist
(
&
getQuery
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
int64
(
0
),
getQuery
.
Result
.
Id
,
"playlist should've been removed"
)
})
})
t
.
Run
(
"Delete playlist that doesn't exist"
,
func
(
t
*
testing
.
T
)
{
deleteQuery
:=
models
.
DeletePlaylistCommand
{
Id
:
1
,
OrgId
:
1
}
err
:=
DeletePlaylist
(
&
deleteQuery
)
require
.
NoError
(
t
,
err
)
})
t
.
Run
(
"Delete playlist with invalid command yields error"
,
func
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
desc
string
cmd
models
.
DeletePlaylistCommand
}{
{
desc
:
"none"
,
cmd
:
models
.
DeletePlaylistCommand
{}},
{
desc
:
"no OrgId"
,
cmd
:
models
.
DeletePlaylistCommand
{
Id
:
1
}},
{
desc
:
"no Id"
,
cmd
:
models
.
DeletePlaylistCommand
{
OrgId
:
1
}},
}
for
_
,
tc
:=
range
testCases
{
err
:=
DeletePlaylist
(
&
tc
.
cmd
)
require
.
EqualError
(
t
,
err
,
models
.
ErrCommandValidationFailed
.
Error
(),
fmt
.
Sprintf
(
"expected command validation error for %q"
,
tc
.
desc
))
}
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment