@@ -2,6 +2,7 @@ package sentry
22
33import (
44 "context"
5+ "encoding/json"
56 "fmt"
67 "net/http"
78 "testing"
@@ -146,22 +147,39 @@ func TestDashboardsService_Create(t *testing.T) {
146147 mux .HandleFunc ("/api/0/organizations/the-interstellar-jurisdiction/dashboards/" , func (w http.ResponseWriter , r * http.Request ) {
147148 assertMethod (t , "POST" , r )
148149 assertPostJSONValue (t , map [string ]interface {}{
149- "title" : "General" ,
150- "widgets" : map [string ]interface {}{},
150+ "title" : "General" ,
151+ "permissions" : map [string ]interface {}{
152+ "isEditableByEveryone" : true ,
153+ "teamsWithEditAccess" : []interface {}{json .Number ("3" ), json .Number ("4" )},
154+ },
155+ "projects" : []interface {}{json .Number ("1" ), json .Number ("2" )},
156+ "period" : "14d" ,
151157 }, r )
152158
153159 w .Header ().Set ("Content-Type" , "application/json" )
154160 fmt .Fprint (w , `{
155161 "id": "12072",
156162 "title": "General",
157163 "dateCreated": "2022-06-07T16:48:26.255520Z",
158- "widgets": []
164+ "widgets": [],
165+ "permissions": {
166+ "isEditableByEveryone": true,
167+ "teamsWithEditAccess": [3, 4]
168+ },
169+ "projects": [1, 2],
170+ "period": "14d"
159171 }` )
160172 })
161173
162174 params := & Dashboard {
163175 Title : String ("General" ),
164176 Widgets : []* DashboardWidget {},
177+ Permissions : & Permission {
178+ IsEditableByEveryone : Bool (true ),
179+ TeamsWithEditAccess : []* int {Int (3 ), Int (4 )},
180+ },
181+ Projects : []* int {Int (1 ), Int (2 )},
182+ Period : String ("14d" ),
165183 }
166184 ctx := context .Background ()
167185 dashboard , _ , err := client .Dashboards .Create (ctx , "the-interstellar-jurisdiction" , params )
@@ -171,6 +189,12 @@ func TestDashboardsService_Create(t *testing.T) {
171189 Title : String ("General" ),
172190 DateCreated : Time (mustParseTime ("2022-06-07T16:48:26.255520Z" )),
173191 Widgets : []* DashboardWidget {},
192+ Projects : []* int {Int (1 ), Int (2 )},
193+ Permissions : & Permission {
194+ IsEditableByEveryone : Bool (true ),
195+ TeamsWithEditAccess : []* int {Int (3 ), Int (4 )},
196+ },
197+ Period : String ("14d" ),
174198 }
175199 assert .Equal (t , expected , dashboard )
176200 assert .NoError (t , err )
@@ -183,24 +207,29 @@ func TestDashboardsService_Update(t *testing.T) {
183207 mux .HandleFunc ("/api/0/organizations/the-interstellar-jurisdiction/dashboards/12072/" , func (w http.ResponseWriter , r * http.Request ) {
184208 assertMethod (t , "PUT" , r )
185209 assertPostJSONValue (t , map [string ]interface {}{
186- "id" : "12072" ,
187- "title" : "General" ,
188- "widgets" : map [string ]interface {}{},
210+ "id" : "12072" ,
211+ "title" : "General" ,
212+ "projects" : []interface {}{json .Number ("1" ), json .Number ("2" )},
213+ "period" : "14d" ,
189214 }, r )
190215
191216 w .Header ().Set ("Content-Type" , "application/json" )
192217 fmt .Fprint (w , `{
193218 "id": "12072",
194219 "title": "General",
195220 "dateCreated": "2022-06-07T16:48:26.255520Z",
196- "widgets": []
221+ "widgets": [],
222+ "projects": [1, 2],
223+ "period": "14d"
197224 }` )
198225 })
199226
200227 params := & Dashboard {
201- ID : String ("12072" ),
202- Title : String ("General" ),
203- Widgets : []* DashboardWidget {},
228+ ID : String ("12072" ),
229+ Title : String ("General" ),
230+ Widgets : []* DashboardWidget {},
231+ Projects : []* int {Int (1 ), Int (2 )},
232+ Period : String ("14d" ),
204233 }
205234 ctx := context .Background ()
206235 dashboard , _ , err := client .Dashboards .Update (ctx , "the-interstellar-jurisdiction" , "12072" , params )
@@ -210,6 +239,8 @@ func TestDashboardsService_Update(t *testing.T) {
210239 Title : String ("General" ),
211240 DateCreated : Time (mustParseTime ("2022-06-07T16:48:26.255520Z" )),
212241 Widgets : []* DashboardWidget {},
242+ Projects : []* int {Int (1 ), Int (2 )},
243+ Period : String ("14d" ),
213244 }
214245 assert .Equal (t , expected , dashboard )
215246 assert .NoError (t , err )
0 commit comments