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
5adde259
Commit
5adde259
authored
Mar 08, 2019
by
Hugo Häggmark
Committed by
Leonard Gram
Mar 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teams: team update test
parent
3c46b786
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
1 deletions
+54
-1
pkg/api/team.go
+2
-1
pkg/services/teams/team.go
+10
-0
pkg/services/teams/teams_test.go
+42
-0
No files found.
pkg/api/team.go
View file @
5adde259
...
...
@@ -4,6 +4,7 @@ import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/teams"
"github.com/grafana/grafana/pkg/util"
)
...
...
@@ -40,7 +41,7 @@ func (hs *HTTPServer) CreateTeam(c *m.ReqContext, cmd m.CreateTeamCommand) Respo
func
UpdateTeam
(
c
*
m
.
ReqContext
,
cmd
m
.
UpdateTeamCommand
)
Response
{
cmd
.
OrgId
=
c
.
OrgId
cmd
.
Id
=
c
.
ParamsInt64
(
":teamId"
)
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
if
err
:=
teams
.
UpdateTeam
(
c
.
SignedInUser
,
&
cmd
);
err
!=
nil
{
if
err
==
m
.
ErrTeamNameTaken
{
return
Error
(
400
,
"Team name taken"
,
err
)
}
...
...
pkg/services/teams/team.go
0 → 100644
View file @
5adde259
package
teams
import
(
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
)
func
UpdateTeam
(
user
m
.
SignedInUser
,
cmd
*
m
.
UpdateTeamCommand
)
error
{
return
bus
.
Dispatch
(
cmd
)
}
pkg/services/teams/teams_test.go
0 → 100644
View file @
5adde259
package
teams
import
(
.
"github.com/smartystreets/goconvey/convey"
m
"github.com/grafana/grafana/pkg/models"
)
func
TestUpdateTeam
(
t
*
testing
.
T
)
{
Convey
(
"Updating a team as an editor"
,
t
,
func
()
{
Convey
(
"Given an editor and a team he isn't a member of"
,
func
()
{
UpdateTeam
(
editor
,
m
.
UpdateTeamCommand
{
Id
:
0
,
Name
:
""
,
Email
:
""
,
OrgId
:
0
,
})
})
// the editor should not be able to update the team if they aren't members of it
fakeDash
:=
m
.
NewDashboard
(
"Child dash"
)
fakeDash
.
Id
=
1
fakeDash
.
FolderId
=
1
fakeDash
.
HasAcl
=
false
bus
.
AddHandler
(
"test"
,
func
(
query
*
m
.
GetDashboardsBySlugQuery
)
error
{
dashboards
:=
[]
*
m
.
Dashboard
{
fakeDash
}
query
.
Result
=
dashboards
return
nil
})
var
getDashboardQueries
[]
*
m
.
GetDashboardQuery
bus
.
AddHandler
(
"test"
,
func
(
query
*
m
.
GetDashboardQuery
)
error
{
query
.
Result
=
fakeDash
getDashboardQueries
=
append
(
getDashboardQueries
,
query
)
return
nil
})
bus
.
AddHandler
(
"test"
,
func
(
query
*
m
.
IsDashboardProvisionedQuery
)
error
{
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