You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2499 lines
72 KiB

  1. // Copyright 2019 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Code generated by gapic-generator. DO NOT EDIT.
  15. package irm
  16. import (
  17. emptypb "github.com/golang/protobuf/ptypes/empty"
  18. irmpb "google.golang.org/genproto/googleapis/cloud/irm/v1alpha2"
  19. )
  20. import (
  21. "context"
  22. "flag"
  23. "fmt"
  24. "io"
  25. "log"
  26. "net"
  27. "os"
  28. "strings"
  29. "testing"
  30. "github.com/golang/protobuf/proto"
  31. "github.com/golang/protobuf/ptypes"
  32. "google.golang.org/api/option"
  33. status "google.golang.org/genproto/googleapis/rpc/status"
  34. "google.golang.org/grpc"
  35. "google.golang.org/grpc/codes"
  36. "google.golang.org/grpc/metadata"
  37. gstatus "google.golang.org/grpc/status"
  38. )
  39. var _ = io.EOF
  40. var _ = ptypes.MarshalAny
  41. var _ status.Status
  42. type mockIncidentServer struct {
  43. // Embed for forward compatibility.
  44. // Tests will keep working if more methods are added
  45. // in the future.
  46. irmpb.IncidentServiceServer
  47. reqs []proto.Message
  48. // If set, all calls return this error.
  49. err error
  50. // responses to return if err == nil
  51. resps []proto.Message
  52. }
  53. func (s *mockIncidentServer) CreateIncident(ctx context.Context, req *irmpb.CreateIncidentRequest) (*irmpb.Incident, error) {
  54. md, _ := metadata.FromIncomingContext(ctx)
  55. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  56. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  57. }
  58. s.reqs = append(s.reqs, req)
  59. if s.err != nil {
  60. return nil, s.err
  61. }
  62. return s.resps[0].(*irmpb.Incident), nil
  63. }
  64. func (s *mockIncidentServer) GetIncident(ctx context.Context, req *irmpb.GetIncidentRequest) (*irmpb.Incident, error) {
  65. md, _ := metadata.FromIncomingContext(ctx)
  66. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  67. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  68. }
  69. s.reqs = append(s.reqs, req)
  70. if s.err != nil {
  71. return nil, s.err
  72. }
  73. return s.resps[0].(*irmpb.Incident), nil
  74. }
  75. func (s *mockIncidentServer) SearchIncidents(ctx context.Context, req *irmpb.SearchIncidentsRequest) (*irmpb.SearchIncidentsResponse, error) {
  76. md, _ := metadata.FromIncomingContext(ctx)
  77. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  78. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  79. }
  80. s.reqs = append(s.reqs, req)
  81. if s.err != nil {
  82. return nil, s.err
  83. }
  84. return s.resps[0].(*irmpb.SearchIncidentsResponse), nil
  85. }
  86. func (s *mockIncidentServer) UpdateIncident(ctx context.Context, req *irmpb.UpdateIncidentRequest) (*irmpb.Incident, error) {
  87. md, _ := metadata.FromIncomingContext(ctx)
  88. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  89. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  90. }
  91. s.reqs = append(s.reqs, req)
  92. if s.err != nil {
  93. return nil, s.err
  94. }
  95. return s.resps[0].(*irmpb.Incident), nil
  96. }
  97. func (s *mockIncidentServer) SearchSimilarIncidents(ctx context.Context, req *irmpb.SearchSimilarIncidentsRequest) (*irmpb.SearchSimilarIncidentsResponse, error) {
  98. md, _ := metadata.FromIncomingContext(ctx)
  99. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  100. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  101. }
  102. s.reqs = append(s.reqs, req)
  103. if s.err != nil {
  104. return nil, s.err
  105. }
  106. return s.resps[0].(*irmpb.SearchSimilarIncidentsResponse), nil
  107. }
  108. func (s *mockIncidentServer) CreateAnnotation(ctx context.Context, req *irmpb.CreateAnnotationRequest) (*irmpb.Annotation, error) {
  109. md, _ := metadata.FromIncomingContext(ctx)
  110. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  111. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  112. }
  113. s.reqs = append(s.reqs, req)
  114. if s.err != nil {
  115. return nil, s.err
  116. }
  117. return s.resps[0].(*irmpb.Annotation), nil
  118. }
  119. func (s *mockIncidentServer) ListAnnotations(ctx context.Context, req *irmpb.ListAnnotationsRequest) (*irmpb.ListAnnotationsResponse, error) {
  120. md, _ := metadata.FromIncomingContext(ctx)
  121. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  122. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  123. }
  124. s.reqs = append(s.reqs, req)
  125. if s.err != nil {
  126. return nil, s.err
  127. }
  128. return s.resps[0].(*irmpb.ListAnnotationsResponse), nil
  129. }
  130. func (s *mockIncidentServer) CreateTag(ctx context.Context, req *irmpb.CreateTagRequest) (*irmpb.Tag, error) {
  131. md, _ := metadata.FromIncomingContext(ctx)
  132. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  133. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  134. }
  135. s.reqs = append(s.reqs, req)
  136. if s.err != nil {
  137. return nil, s.err
  138. }
  139. return s.resps[0].(*irmpb.Tag), nil
  140. }
  141. func (s *mockIncidentServer) DeleteTag(ctx context.Context, req *irmpb.DeleteTagRequest) (*emptypb.Empty, error) {
  142. md, _ := metadata.FromIncomingContext(ctx)
  143. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  144. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  145. }
  146. s.reqs = append(s.reqs, req)
  147. if s.err != nil {
  148. return nil, s.err
  149. }
  150. return s.resps[0].(*emptypb.Empty), nil
  151. }
  152. func (s *mockIncidentServer) ListTags(ctx context.Context, req *irmpb.ListTagsRequest) (*irmpb.ListTagsResponse, error) {
  153. md, _ := metadata.FromIncomingContext(ctx)
  154. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  155. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  156. }
  157. s.reqs = append(s.reqs, req)
  158. if s.err != nil {
  159. return nil, s.err
  160. }
  161. return s.resps[0].(*irmpb.ListTagsResponse), nil
  162. }
  163. func (s *mockIncidentServer) CreateSignal(ctx context.Context, req *irmpb.CreateSignalRequest) (*irmpb.Signal, error) {
  164. md, _ := metadata.FromIncomingContext(ctx)
  165. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  166. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  167. }
  168. s.reqs = append(s.reqs, req)
  169. if s.err != nil {
  170. return nil, s.err
  171. }
  172. return s.resps[0].(*irmpb.Signal), nil
  173. }
  174. func (s *mockIncidentServer) SearchSignals(ctx context.Context, req *irmpb.SearchSignalsRequest) (*irmpb.SearchSignalsResponse, error) {
  175. md, _ := metadata.FromIncomingContext(ctx)
  176. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  177. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  178. }
  179. s.reqs = append(s.reqs, req)
  180. if s.err != nil {
  181. return nil, s.err
  182. }
  183. return s.resps[0].(*irmpb.SearchSignalsResponse), nil
  184. }
  185. func (s *mockIncidentServer) GetSignal(ctx context.Context, req *irmpb.GetSignalRequest) (*irmpb.Signal, error) {
  186. md, _ := metadata.FromIncomingContext(ctx)
  187. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  188. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  189. }
  190. s.reqs = append(s.reqs, req)
  191. if s.err != nil {
  192. return nil, s.err
  193. }
  194. return s.resps[0].(*irmpb.Signal), nil
  195. }
  196. func (s *mockIncidentServer) UpdateSignal(ctx context.Context, req *irmpb.UpdateSignalRequest) (*irmpb.Signal, error) {
  197. md, _ := metadata.FromIncomingContext(ctx)
  198. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  199. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  200. }
  201. s.reqs = append(s.reqs, req)
  202. if s.err != nil {
  203. return nil, s.err
  204. }
  205. return s.resps[0].(*irmpb.Signal), nil
  206. }
  207. func (s *mockIncidentServer) EscalateIncident(ctx context.Context, req *irmpb.EscalateIncidentRequest) (*irmpb.EscalateIncidentResponse, error) {
  208. md, _ := metadata.FromIncomingContext(ctx)
  209. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  210. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  211. }
  212. s.reqs = append(s.reqs, req)
  213. if s.err != nil {
  214. return nil, s.err
  215. }
  216. return s.resps[0].(*irmpb.EscalateIncidentResponse), nil
  217. }
  218. func (s *mockIncidentServer) CreateArtifact(ctx context.Context, req *irmpb.CreateArtifactRequest) (*irmpb.Artifact, error) {
  219. md, _ := metadata.FromIncomingContext(ctx)
  220. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  221. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  222. }
  223. s.reqs = append(s.reqs, req)
  224. if s.err != nil {
  225. return nil, s.err
  226. }
  227. return s.resps[0].(*irmpb.Artifact), nil
  228. }
  229. func (s *mockIncidentServer) ListArtifacts(ctx context.Context, req *irmpb.ListArtifactsRequest) (*irmpb.ListArtifactsResponse, error) {
  230. md, _ := metadata.FromIncomingContext(ctx)
  231. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  232. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  233. }
  234. s.reqs = append(s.reqs, req)
  235. if s.err != nil {
  236. return nil, s.err
  237. }
  238. return s.resps[0].(*irmpb.ListArtifactsResponse), nil
  239. }
  240. func (s *mockIncidentServer) UpdateArtifact(ctx context.Context, req *irmpb.UpdateArtifactRequest) (*irmpb.Artifact, error) {
  241. md, _ := metadata.FromIncomingContext(ctx)
  242. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  243. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  244. }
  245. s.reqs = append(s.reqs, req)
  246. if s.err != nil {
  247. return nil, s.err
  248. }
  249. return s.resps[0].(*irmpb.Artifact), nil
  250. }
  251. func (s *mockIncidentServer) DeleteArtifact(ctx context.Context, req *irmpb.DeleteArtifactRequest) (*emptypb.Empty, error) {
  252. md, _ := metadata.FromIncomingContext(ctx)
  253. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  254. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  255. }
  256. s.reqs = append(s.reqs, req)
  257. if s.err != nil {
  258. return nil, s.err
  259. }
  260. return s.resps[0].(*emptypb.Empty), nil
  261. }
  262. func (s *mockIncidentServer) SendShiftHandoff(ctx context.Context, req *irmpb.SendShiftHandoffRequest) (*irmpb.SendShiftHandoffResponse, error) {
  263. md, _ := metadata.FromIncomingContext(ctx)
  264. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  265. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  266. }
  267. s.reqs = append(s.reqs, req)
  268. if s.err != nil {
  269. return nil, s.err
  270. }
  271. return s.resps[0].(*irmpb.SendShiftHandoffResponse), nil
  272. }
  273. func (s *mockIncidentServer) CreateSubscription(ctx context.Context, req *irmpb.CreateSubscriptionRequest) (*irmpb.Subscription, error) {
  274. md, _ := metadata.FromIncomingContext(ctx)
  275. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  276. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  277. }
  278. s.reqs = append(s.reqs, req)
  279. if s.err != nil {
  280. return nil, s.err
  281. }
  282. return s.resps[0].(*irmpb.Subscription), nil
  283. }
  284. func (s *mockIncidentServer) UpdateSubscription(ctx context.Context, req *irmpb.UpdateSubscriptionRequest) (*irmpb.Subscription, error) {
  285. md, _ := metadata.FromIncomingContext(ctx)
  286. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  287. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  288. }
  289. s.reqs = append(s.reqs, req)
  290. if s.err != nil {
  291. return nil, s.err
  292. }
  293. return s.resps[0].(*irmpb.Subscription), nil
  294. }
  295. func (s *mockIncidentServer) ListSubscriptions(ctx context.Context, req *irmpb.ListSubscriptionsRequest) (*irmpb.ListSubscriptionsResponse, error) {
  296. md, _ := metadata.FromIncomingContext(ctx)
  297. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  298. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  299. }
  300. s.reqs = append(s.reqs, req)
  301. if s.err != nil {
  302. return nil, s.err
  303. }
  304. return s.resps[0].(*irmpb.ListSubscriptionsResponse), nil
  305. }
  306. func (s *mockIncidentServer) DeleteSubscription(ctx context.Context, req *irmpb.DeleteSubscriptionRequest) (*emptypb.Empty, error) {
  307. md, _ := metadata.FromIncomingContext(ctx)
  308. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  309. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  310. }
  311. s.reqs = append(s.reqs, req)
  312. if s.err != nil {
  313. return nil, s.err
  314. }
  315. return s.resps[0].(*emptypb.Empty), nil
  316. }
  317. func (s *mockIncidentServer) CreateIncidentRoleAssignment(ctx context.Context, req *irmpb.CreateIncidentRoleAssignmentRequest) (*irmpb.IncidentRoleAssignment, error) {
  318. md, _ := metadata.FromIncomingContext(ctx)
  319. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  320. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  321. }
  322. s.reqs = append(s.reqs, req)
  323. if s.err != nil {
  324. return nil, s.err
  325. }
  326. return s.resps[0].(*irmpb.IncidentRoleAssignment), nil
  327. }
  328. func (s *mockIncidentServer) DeleteIncidentRoleAssignment(ctx context.Context, req *irmpb.DeleteIncidentRoleAssignmentRequest) (*emptypb.Empty, error) {
  329. md, _ := metadata.FromIncomingContext(ctx)
  330. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  331. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  332. }
  333. s.reqs = append(s.reqs, req)
  334. if s.err != nil {
  335. return nil, s.err
  336. }
  337. return s.resps[0].(*emptypb.Empty), nil
  338. }
  339. func (s *mockIncidentServer) ListIncidentRoleAssignments(ctx context.Context, req *irmpb.ListIncidentRoleAssignmentsRequest) (*irmpb.ListIncidentRoleAssignmentsResponse, error) {
  340. md, _ := metadata.FromIncomingContext(ctx)
  341. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  342. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  343. }
  344. s.reqs = append(s.reqs, req)
  345. if s.err != nil {
  346. return nil, s.err
  347. }
  348. return s.resps[0].(*irmpb.ListIncidentRoleAssignmentsResponse), nil
  349. }
  350. func (s *mockIncidentServer) RequestIncidentRoleHandover(ctx context.Context, req *irmpb.RequestIncidentRoleHandoverRequest) (*irmpb.IncidentRoleAssignment, error) {
  351. md, _ := metadata.FromIncomingContext(ctx)
  352. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  353. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  354. }
  355. s.reqs = append(s.reqs, req)
  356. if s.err != nil {
  357. return nil, s.err
  358. }
  359. return s.resps[0].(*irmpb.IncidentRoleAssignment), nil
  360. }
  361. func (s *mockIncidentServer) ConfirmIncidentRoleHandover(ctx context.Context, req *irmpb.ConfirmIncidentRoleHandoverRequest) (*irmpb.IncidentRoleAssignment, error) {
  362. md, _ := metadata.FromIncomingContext(ctx)
  363. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  364. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  365. }
  366. s.reqs = append(s.reqs, req)
  367. if s.err != nil {
  368. return nil, s.err
  369. }
  370. return s.resps[0].(*irmpb.IncidentRoleAssignment), nil
  371. }
  372. func (s *mockIncidentServer) ForceIncidentRoleHandover(ctx context.Context, req *irmpb.ForceIncidentRoleHandoverRequest) (*irmpb.IncidentRoleAssignment, error) {
  373. md, _ := metadata.FromIncomingContext(ctx)
  374. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  375. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  376. }
  377. s.reqs = append(s.reqs, req)
  378. if s.err != nil {
  379. return nil, s.err
  380. }
  381. return s.resps[0].(*irmpb.IncidentRoleAssignment), nil
  382. }
  383. func (s *mockIncidentServer) CancelIncidentRoleHandover(ctx context.Context, req *irmpb.CancelIncidentRoleHandoverRequest) (*irmpb.IncidentRoleAssignment, error) {
  384. md, _ := metadata.FromIncomingContext(ctx)
  385. if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
  386. return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
  387. }
  388. s.reqs = append(s.reqs, req)
  389. if s.err != nil {
  390. return nil, s.err
  391. }
  392. return s.resps[0].(*irmpb.IncidentRoleAssignment), nil
  393. }
  394. // clientOpt is the option tests should use to connect to the test server.
  395. // It is initialized by TestMain.
  396. var clientOpt option.ClientOption
  397. var (
  398. mockIncident mockIncidentServer
  399. )
  400. func TestMain(m *testing.M) {
  401. flag.Parse()
  402. serv := grpc.NewServer()
  403. irmpb.RegisterIncidentServiceServer(serv, &mockIncident)
  404. lis, err := net.Listen("tcp", "localhost:0")
  405. if err != nil {
  406. log.Fatal(err)
  407. }
  408. go serv.Serve(lis)
  409. conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
  410. if err != nil {
  411. log.Fatal(err)
  412. }
  413. clientOpt = option.WithGRPCConn(conn)
  414. os.Exit(m.Run())
  415. }
  416. func TestIncidentServiceCreateIncident(t *testing.T) {
  417. var name string = "name3373707"
  418. var title string = "title110371416"
  419. var etag string = "etag3123477"
  420. var duplicateIncident string = "duplicateIncident-316496506"
  421. var expectedResponse = &irmpb.Incident{
  422. Name: name,
  423. Title: title,
  424. Etag: etag,
  425. DuplicateIncident: duplicateIncident,
  426. }
  427. mockIncident.err = nil
  428. mockIncident.reqs = nil
  429. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  430. var incident *irmpb.Incident = &irmpb.Incident{}
  431. var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
  432. var request = &irmpb.CreateIncidentRequest{
  433. Incident: incident,
  434. Parent: formattedParent,
  435. }
  436. c, err := NewIncidentClient(context.Background(), clientOpt)
  437. if err != nil {
  438. t.Fatal(err)
  439. }
  440. resp, err := c.CreateIncident(context.Background(), request)
  441. if err != nil {
  442. t.Fatal(err)
  443. }
  444. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  445. t.Errorf("wrong request %q, want %q", got, want)
  446. }
  447. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  448. t.Errorf("wrong response %q, want %q)", got, want)
  449. }
  450. }
  451. func TestIncidentServiceCreateIncidentError(t *testing.T) {
  452. errCode := codes.PermissionDenied
  453. mockIncident.err = gstatus.Error(errCode, "test error")
  454. var incident *irmpb.Incident = &irmpb.Incident{}
  455. var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
  456. var request = &irmpb.CreateIncidentRequest{
  457. Incident: incident,
  458. Parent: formattedParent,
  459. }
  460. c, err := NewIncidentClient(context.Background(), clientOpt)
  461. if err != nil {
  462. t.Fatal(err)
  463. }
  464. resp, err := c.CreateIncident(context.Background(), request)
  465. if st, ok := gstatus.FromError(err); !ok {
  466. t.Errorf("got error %v, expected grpc error", err)
  467. } else if c := st.Code(); c != errCode {
  468. t.Errorf("got error code %q, want %q", c, errCode)
  469. }
  470. _ = resp
  471. }
  472. func TestIncidentServiceGetIncident(t *testing.T) {
  473. var name2 string = "name2-1052831874"
  474. var title string = "title110371416"
  475. var etag string = "etag3123477"
  476. var duplicateIncident string = "duplicateIncident-316496506"
  477. var expectedResponse = &irmpb.Incident{
  478. Name: name2,
  479. Title: title,
  480. Etag: etag,
  481. DuplicateIncident: duplicateIncident,
  482. }
  483. mockIncident.err = nil
  484. mockIncident.reqs = nil
  485. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  486. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  487. var request = &irmpb.GetIncidentRequest{
  488. Name: formattedName,
  489. }
  490. c, err := NewIncidentClient(context.Background(), clientOpt)
  491. if err != nil {
  492. t.Fatal(err)
  493. }
  494. resp, err := c.GetIncident(context.Background(), request)
  495. if err != nil {
  496. t.Fatal(err)
  497. }
  498. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  499. t.Errorf("wrong request %q, want %q", got, want)
  500. }
  501. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  502. t.Errorf("wrong response %q, want %q)", got, want)
  503. }
  504. }
  505. func TestIncidentServiceGetIncidentError(t *testing.T) {
  506. errCode := codes.PermissionDenied
  507. mockIncident.err = gstatus.Error(errCode, "test error")
  508. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  509. var request = &irmpb.GetIncidentRequest{
  510. Name: formattedName,
  511. }
  512. c, err := NewIncidentClient(context.Background(), clientOpt)
  513. if err != nil {
  514. t.Fatal(err)
  515. }
  516. resp, err := c.GetIncident(context.Background(), request)
  517. if st, ok := gstatus.FromError(err); !ok {
  518. t.Errorf("got error %v, expected grpc error", err)
  519. } else if c := st.Code(); c != errCode {
  520. t.Errorf("got error code %q, want %q", c, errCode)
  521. }
  522. _ = resp
  523. }
  524. func TestIncidentServiceSearchIncidents(t *testing.T) {
  525. var nextPageToken string = ""
  526. var incidentsElement *irmpb.Incident = &irmpb.Incident{}
  527. var incidents = []*irmpb.Incident{incidentsElement}
  528. var expectedResponse = &irmpb.SearchIncidentsResponse{
  529. NextPageToken: nextPageToken,
  530. Incidents: incidents,
  531. }
  532. mockIncident.err = nil
  533. mockIncident.reqs = nil
  534. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  535. var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
  536. var request = &irmpb.SearchIncidentsRequest{
  537. Parent: formattedParent,
  538. }
  539. c, err := NewIncidentClient(context.Background(), clientOpt)
  540. if err != nil {
  541. t.Fatal(err)
  542. }
  543. resp, err := c.SearchIncidents(context.Background(), request).Next()
  544. if err != nil {
  545. t.Fatal(err)
  546. }
  547. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  548. t.Errorf("wrong request %q, want %q", got, want)
  549. }
  550. want := (interface{})(expectedResponse.Incidents[0])
  551. got := (interface{})(resp)
  552. var ok bool
  553. switch want := (want).(type) {
  554. case proto.Message:
  555. ok = proto.Equal(want, got.(proto.Message))
  556. default:
  557. ok = want == got
  558. }
  559. if !ok {
  560. t.Errorf("wrong response %q, want %q)", got, want)
  561. }
  562. }
  563. func TestIncidentServiceSearchIncidentsError(t *testing.T) {
  564. errCode := codes.PermissionDenied
  565. mockIncident.err = gstatus.Error(errCode, "test error")
  566. var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
  567. var request = &irmpb.SearchIncidentsRequest{
  568. Parent: formattedParent,
  569. }
  570. c, err := NewIncidentClient(context.Background(), clientOpt)
  571. if err != nil {
  572. t.Fatal(err)
  573. }
  574. resp, err := c.SearchIncidents(context.Background(), request).Next()
  575. if st, ok := gstatus.FromError(err); !ok {
  576. t.Errorf("got error %v, expected grpc error", err)
  577. } else if c := st.Code(); c != errCode {
  578. t.Errorf("got error code %q, want %q", c, errCode)
  579. }
  580. _ = resp
  581. }
  582. func TestIncidentServiceUpdateIncident(t *testing.T) {
  583. var name string = "name3373707"
  584. var title string = "title110371416"
  585. var etag string = "etag3123477"
  586. var duplicateIncident string = "duplicateIncident-316496506"
  587. var expectedResponse = &irmpb.Incident{
  588. Name: name,
  589. Title: title,
  590. Etag: etag,
  591. DuplicateIncident: duplicateIncident,
  592. }
  593. mockIncident.err = nil
  594. mockIncident.reqs = nil
  595. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  596. var incident *irmpb.Incident = &irmpb.Incident{}
  597. var request = &irmpb.UpdateIncidentRequest{
  598. Incident: incident,
  599. }
  600. c, err := NewIncidentClient(context.Background(), clientOpt)
  601. if err != nil {
  602. t.Fatal(err)
  603. }
  604. resp, err := c.UpdateIncident(context.Background(), request)
  605. if err != nil {
  606. t.Fatal(err)
  607. }
  608. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  609. t.Errorf("wrong request %q, want %q", got, want)
  610. }
  611. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  612. t.Errorf("wrong response %q, want %q)", got, want)
  613. }
  614. }
  615. func TestIncidentServiceUpdateIncidentError(t *testing.T) {
  616. errCode := codes.PermissionDenied
  617. mockIncident.err = gstatus.Error(errCode, "test error")
  618. var incident *irmpb.Incident = &irmpb.Incident{}
  619. var request = &irmpb.UpdateIncidentRequest{
  620. Incident: incident,
  621. }
  622. c, err := NewIncidentClient(context.Background(), clientOpt)
  623. if err != nil {
  624. t.Fatal(err)
  625. }
  626. resp, err := c.UpdateIncident(context.Background(), request)
  627. if st, ok := gstatus.FromError(err); !ok {
  628. t.Errorf("got error %v, expected grpc error", err)
  629. } else if c := st.Code(); c != errCode {
  630. t.Errorf("got error code %q, want %q", c, errCode)
  631. }
  632. _ = resp
  633. }
  634. func TestIncidentServiceSearchSimilarIncidents(t *testing.T) {
  635. var nextPageToken string = ""
  636. var resultsElement *irmpb.SearchSimilarIncidentsResponse_Result = &irmpb.SearchSimilarIncidentsResponse_Result{}
  637. var results = []*irmpb.SearchSimilarIncidentsResponse_Result{resultsElement}
  638. var expectedResponse = &irmpb.SearchSimilarIncidentsResponse{
  639. NextPageToken: nextPageToken,
  640. Results: results,
  641. }
  642. mockIncident.err = nil
  643. mockIncident.reqs = nil
  644. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  645. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  646. var request = &irmpb.SearchSimilarIncidentsRequest{
  647. Name: formattedName,
  648. }
  649. c, err := NewIncidentClient(context.Background(), clientOpt)
  650. if err != nil {
  651. t.Fatal(err)
  652. }
  653. resp, err := c.SearchSimilarIncidents(context.Background(), request).Next()
  654. if err != nil {
  655. t.Fatal(err)
  656. }
  657. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  658. t.Errorf("wrong request %q, want %q", got, want)
  659. }
  660. want := (interface{})(expectedResponse.Results[0])
  661. got := (interface{})(resp)
  662. var ok bool
  663. switch want := (want).(type) {
  664. case proto.Message:
  665. ok = proto.Equal(want, got.(proto.Message))
  666. default:
  667. ok = want == got
  668. }
  669. if !ok {
  670. t.Errorf("wrong response %q, want %q)", got, want)
  671. }
  672. }
  673. func TestIncidentServiceSearchSimilarIncidentsError(t *testing.T) {
  674. errCode := codes.PermissionDenied
  675. mockIncident.err = gstatus.Error(errCode, "test error")
  676. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  677. var request = &irmpb.SearchSimilarIncidentsRequest{
  678. Name: formattedName,
  679. }
  680. c, err := NewIncidentClient(context.Background(), clientOpt)
  681. if err != nil {
  682. t.Fatal(err)
  683. }
  684. resp, err := c.SearchSimilarIncidents(context.Background(), request).Next()
  685. if st, ok := gstatus.FromError(err); !ok {
  686. t.Errorf("got error %v, expected grpc error", err)
  687. } else if c := st.Code(); c != errCode {
  688. t.Errorf("got error code %q, want %q", c, errCode)
  689. }
  690. _ = resp
  691. }
  692. func TestIncidentServiceCreateAnnotation(t *testing.T) {
  693. var name string = "name3373707"
  694. var content string = "content951530617"
  695. var expectedResponse = &irmpb.Annotation{
  696. Name: name,
  697. Content: content,
  698. }
  699. mockIncident.err = nil
  700. mockIncident.reqs = nil
  701. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  702. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  703. var annotation *irmpb.Annotation = &irmpb.Annotation{}
  704. var request = &irmpb.CreateAnnotationRequest{
  705. Parent: formattedParent,
  706. Annotation: annotation,
  707. }
  708. c, err := NewIncidentClient(context.Background(), clientOpt)
  709. if err != nil {
  710. t.Fatal(err)
  711. }
  712. resp, err := c.CreateAnnotation(context.Background(), request)
  713. if err != nil {
  714. t.Fatal(err)
  715. }
  716. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  717. t.Errorf("wrong request %q, want %q", got, want)
  718. }
  719. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  720. t.Errorf("wrong response %q, want %q)", got, want)
  721. }
  722. }
  723. func TestIncidentServiceCreateAnnotationError(t *testing.T) {
  724. errCode := codes.PermissionDenied
  725. mockIncident.err = gstatus.Error(errCode, "test error")
  726. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  727. var annotation *irmpb.Annotation = &irmpb.Annotation{}
  728. var request = &irmpb.CreateAnnotationRequest{
  729. Parent: formattedParent,
  730. Annotation: annotation,
  731. }
  732. c, err := NewIncidentClient(context.Background(), clientOpt)
  733. if err != nil {
  734. t.Fatal(err)
  735. }
  736. resp, err := c.CreateAnnotation(context.Background(), request)
  737. if st, ok := gstatus.FromError(err); !ok {
  738. t.Errorf("got error %v, expected grpc error", err)
  739. } else if c := st.Code(); c != errCode {
  740. t.Errorf("got error code %q, want %q", c, errCode)
  741. }
  742. _ = resp
  743. }
  744. func TestIncidentServiceListAnnotations(t *testing.T) {
  745. var nextPageToken string = ""
  746. var annotationsElement *irmpb.Annotation = &irmpb.Annotation{}
  747. var annotations = []*irmpb.Annotation{annotationsElement}
  748. var expectedResponse = &irmpb.ListAnnotationsResponse{
  749. NextPageToken: nextPageToken,
  750. Annotations: annotations,
  751. }
  752. mockIncident.err = nil
  753. mockIncident.reqs = nil
  754. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  755. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  756. var request = &irmpb.ListAnnotationsRequest{
  757. Parent: formattedParent,
  758. }
  759. c, err := NewIncidentClient(context.Background(), clientOpt)
  760. if err != nil {
  761. t.Fatal(err)
  762. }
  763. resp, err := c.ListAnnotations(context.Background(), request).Next()
  764. if err != nil {
  765. t.Fatal(err)
  766. }
  767. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  768. t.Errorf("wrong request %q, want %q", got, want)
  769. }
  770. want := (interface{})(expectedResponse.Annotations[0])
  771. got := (interface{})(resp)
  772. var ok bool
  773. switch want := (want).(type) {
  774. case proto.Message:
  775. ok = proto.Equal(want, got.(proto.Message))
  776. default:
  777. ok = want == got
  778. }
  779. if !ok {
  780. t.Errorf("wrong response %q, want %q)", got, want)
  781. }
  782. }
  783. func TestIncidentServiceListAnnotationsError(t *testing.T) {
  784. errCode := codes.PermissionDenied
  785. mockIncident.err = gstatus.Error(errCode, "test error")
  786. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  787. var request = &irmpb.ListAnnotationsRequest{
  788. Parent: formattedParent,
  789. }
  790. c, err := NewIncidentClient(context.Background(), clientOpt)
  791. if err != nil {
  792. t.Fatal(err)
  793. }
  794. resp, err := c.ListAnnotations(context.Background(), request).Next()
  795. if st, ok := gstatus.FromError(err); !ok {
  796. t.Errorf("got error %v, expected grpc error", err)
  797. } else if c := st.Code(); c != errCode {
  798. t.Errorf("got error code %q, want %q", c, errCode)
  799. }
  800. _ = resp
  801. }
  802. func TestIncidentServiceCreateTag(t *testing.T) {
  803. var name string = "name3373707"
  804. var displayName string = "displayName1615086568"
  805. var expectedResponse = &irmpb.Tag{
  806. Name: name,
  807. DisplayName: displayName,
  808. }
  809. mockIncident.err = nil
  810. mockIncident.reqs = nil
  811. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  812. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  813. var tag *irmpb.Tag = &irmpb.Tag{}
  814. var request = &irmpb.CreateTagRequest{
  815. Parent: formattedParent,
  816. Tag: tag,
  817. }
  818. c, err := NewIncidentClient(context.Background(), clientOpt)
  819. if err != nil {
  820. t.Fatal(err)
  821. }
  822. resp, err := c.CreateTag(context.Background(), request)
  823. if err != nil {
  824. t.Fatal(err)
  825. }
  826. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  827. t.Errorf("wrong request %q, want %q", got, want)
  828. }
  829. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  830. t.Errorf("wrong response %q, want %q)", got, want)
  831. }
  832. }
  833. func TestIncidentServiceCreateTagError(t *testing.T) {
  834. errCode := codes.PermissionDenied
  835. mockIncident.err = gstatus.Error(errCode, "test error")
  836. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  837. var tag *irmpb.Tag = &irmpb.Tag{}
  838. var request = &irmpb.CreateTagRequest{
  839. Parent: formattedParent,
  840. Tag: tag,
  841. }
  842. c, err := NewIncidentClient(context.Background(), clientOpt)
  843. if err != nil {
  844. t.Fatal(err)
  845. }
  846. resp, err := c.CreateTag(context.Background(), request)
  847. if st, ok := gstatus.FromError(err); !ok {
  848. t.Errorf("got error %v, expected grpc error", err)
  849. } else if c := st.Code(); c != errCode {
  850. t.Errorf("got error code %q, want %q", c, errCode)
  851. }
  852. _ = resp
  853. }
  854. func TestIncidentServiceDeleteTag(t *testing.T) {
  855. var expectedResponse *emptypb.Empty = &emptypb.Empty{}
  856. mockIncident.err = nil
  857. mockIncident.reqs = nil
  858. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  859. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/tags/%s", "[PROJECT]", "[INCIDENT]", "[TAG]")
  860. var request = &irmpb.DeleteTagRequest{
  861. Name: formattedName,
  862. }
  863. c, err := NewIncidentClient(context.Background(), clientOpt)
  864. if err != nil {
  865. t.Fatal(err)
  866. }
  867. err = c.DeleteTag(context.Background(), request)
  868. if err != nil {
  869. t.Fatal(err)
  870. }
  871. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  872. t.Errorf("wrong request %q, want %q", got, want)
  873. }
  874. }
  875. func TestIncidentServiceDeleteTagError(t *testing.T) {
  876. errCode := codes.PermissionDenied
  877. mockIncident.err = gstatus.Error(errCode, "test error")
  878. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/tags/%s", "[PROJECT]", "[INCIDENT]", "[TAG]")
  879. var request = &irmpb.DeleteTagRequest{
  880. Name: formattedName,
  881. }
  882. c, err := NewIncidentClient(context.Background(), clientOpt)
  883. if err != nil {
  884. t.Fatal(err)
  885. }
  886. err = c.DeleteTag(context.Background(), request)
  887. if st, ok := gstatus.FromError(err); !ok {
  888. t.Errorf("got error %v, expected grpc error", err)
  889. } else if c := st.Code(); c != errCode {
  890. t.Errorf("got error code %q, want %q", c, errCode)
  891. }
  892. }
  893. func TestIncidentServiceListTags(t *testing.T) {
  894. var nextPageToken string = ""
  895. var tagsElement *irmpb.Tag = &irmpb.Tag{}
  896. var tags = []*irmpb.Tag{tagsElement}
  897. var expectedResponse = &irmpb.ListTagsResponse{
  898. NextPageToken: nextPageToken,
  899. Tags: tags,
  900. }
  901. mockIncident.err = nil
  902. mockIncident.reqs = nil
  903. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  904. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  905. var request = &irmpb.ListTagsRequest{
  906. Parent: formattedParent,
  907. }
  908. c, err := NewIncidentClient(context.Background(), clientOpt)
  909. if err != nil {
  910. t.Fatal(err)
  911. }
  912. resp, err := c.ListTags(context.Background(), request).Next()
  913. if err != nil {
  914. t.Fatal(err)
  915. }
  916. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  917. t.Errorf("wrong request %q, want %q", got, want)
  918. }
  919. want := (interface{})(expectedResponse.Tags[0])
  920. got := (interface{})(resp)
  921. var ok bool
  922. switch want := (want).(type) {
  923. case proto.Message:
  924. ok = proto.Equal(want, got.(proto.Message))
  925. default:
  926. ok = want == got
  927. }
  928. if !ok {
  929. t.Errorf("wrong response %q, want %q)", got, want)
  930. }
  931. }
  932. func TestIncidentServiceListTagsError(t *testing.T) {
  933. errCode := codes.PermissionDenied
  934. mockIncident.err = gstatus.Error(errCode, "test error")
  935. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  936. var request = &irmpb.ListTagsRequest{
  937. Parent: formattedParent,
  938. }
  939. c, err := NewIncidentClient(context.Background(), clientOpt)
  940. if err != nil {
  941. t.Fatal(err)
  942. }
  943. resp, err := c.ListTags(context.Background(), request).Next()
  944. if st, ok := gstatus.FromError(err); !ok {
  945. t.Errorf("got error %v, expected grpc error", err)
  946. } else if c := st.Code(); c != errCode {
  947. t.Errorf("got error code %q, want %q", c, errCode)
  948. }
  949. _ = resp
  950. }
  951. func TestIncidentServiceCreateSignal(t *testing.T) {
  952. var name string = "name3373707"
  953. var etag string = "etag3123477"
  954. var incident string = "incident86983890"
  955. var title string = "title110371416"
  956. var contentType string = "contentType831846208"
  957. var content string = "content951530617"
  958. var expectedResponse = &irmpb.Signal{
  959. Name: name,
  960. Etag: etag,
  961. Incident: incident,
  962. Title: title,
  963. ContentType: contentType,
  964. Content: content,
  965. }
  966. mockIncident.err = nil
  967. mockIncident.reqs = nil
  968. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  969. var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
  970. var signal *irmpb.Signal = &irmpb.Signal{}
  971. var request = &irmpb.CreateSignalRequest{
  972. Parent: formattedParent,
  973. Signal: signal,
  974. }
  975. c, err := NewIncidentClient(context.Background(), clientOpt)
  976. if err != nil {
  977. t.Fatal(err)
  978. }
  979. resp, err := c.CreateSignal(context.Background(), request)
  980. if err != nil {
  981. t.Fatal(err)
  982. }
  983. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  984. t.Errorf("wrong request %q, want %q", got, want)
  985. }
  986. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  987. t.Errorf("wrong response %q, want %q)", got, want)
  988. }
  989. }
  990. func TestIncidentServiceCreateSignalError(t *testing.T) {
  991. errCode := codes.PermissionDenied
  992. mockIncident.err = gstatus.Error(errCode, "test error")
  993. var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
  994. var signal *irmpb.Signal = &irmpb.Signal{}
  995. var request = &irmpb.CreateSignalRequest{
  996. Parent: formattedParent,
  997. Signal: signal,
  998. }
  999. c, err := NewIncidentClient(context.Background(), clientOpt)
  1000. if err != nil {
  1001. t.Fatal(err)
  1002. }
  1003. resp, err := c.CreateSignal(context.Background(), request)
  1004. if st, ok := gstatus.FromError(err); !ok {
  1005. t.Errorf("got error %v, expected grpc error", err)
  1006. } else if c := st.Code(); c != errCode {
  1007. t.Errorf("got error code %q, want %q", c, errCode)
  1008. }
  1009. _ = resp
  1010. }
  1011. func TestIncidentServiceSearchSignals(t *testing.T) {
  1012. var nextPageToken string = ""
  1013. var signalsElement *irmpb.Signal = &irmpb.Signal{}
  1014. var signals = []*irmpb.Signal{signalsElement}
  1015. var expectedResponse = &irmpb.SearchSignalsResponse{
  1016. NextPageToken: nextPageToken,
  1017. Signals: signals,
  1018. }
  1019. mockIncident.err = nil
  1020. mockIncident.reqs = nil
  1021. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1022. var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
  1023. var request = &irmpb.SearchSignalsRequest{
  1024. Parent: formattedParent,
  1025. }
  1026. c, err := NewIncidentClient(context.Background(), clientOpt)
  1027. if err != nil {
  1028. t.Fatal(err)
  1029. }
  1030. resp, err := c.SearchSignals(context.Background(), request).Next()
  1031. if err != nil {
  1032. t.Fatal(err)
  1033. }
  1034. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1035. t.Errorf("wrong request %q, want %q", got, want)
  1036. }
  1037. want := (interface{})(expectedResponse.Signals[0])
  1038. got := (interface{})(resp)
  1039. var ok bool
  1040. switch want := (want).(type) {
  1041. case proto.Message:
  1042. ok = proto.Equal(want, got.(proto.Message))
  1043. default:
  1044. ok = want == got
  1045. }
  1046. if !ok {
  1047. t.Errorf("wrong response %q, want %q)", got, want)
  1048. }
  1049. }
  1050. func TestIncidentServiceSearchSignalsError(t *testing.T) {
  1051. errCode := codes.PermissionDenied
  1052. mockIncident.err = gstatus.Error(errCode, "test error")
  1053. var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
  1054. var request = &irmpb.SearchSignalsRequest{
  1055. Parent: formattedParent,
  1056. }
  1057. c, err := NewIncidentClient(context.Background(), clientOpt)
  1058. if err != nil {
  1059. t.Fatal(err)
  1060. }
  1061. resp, err := c.SearchSignals(context.Background(), request).Next()
  1062. if st, ok := gstatus.FromError(err); !ok {
  1063. t.Errorf("got error %v, expected grpc error", err)
  1064. } else if c := st.Code(); c != errCode {
  1065. t.Errorf("got error code %q, want %q", c, errCode)
  1066. }
  1067. _ = resp
  1068. }
  1069. func TestIncidentServiceGetSignal(t *testing.T) {
  1070. var name2 string = "name2-1052831874"
  1071. var etag string = "etag3123477"
  1072. var incident string = "incident86983890"
  1073. var title string = "title110371416"
  1074. var contentType string = "contentType831846208"
  1075. var content string = "content951530617"
  1076. var expectedResponse = &irmpb.Signal{
  1077. Name: name2,
  1078. Etag: etag,
  1079. Incident: incident,
  1080. Title: title,
  1081. ContentType: contentType,
  1082. Content: content,
  1083. }
  1084. mockIncident.err = nil
  1085. mockIncident.reqs = nil
  1086. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1087. var formattedName string = fmt.Sprintf("projects/%s/signals/%s", "[PROJECT]", "[SIGNAL]")
  1088. var request = &irmpb.GetSignalRequest{
  1089. Name: formattedName,
  1090. }
  1091. c, err := NewIncidentClient(context.Background(), clientOpt)
  1092. if err != nil {
  1093. t.Fatal(err)
  1094. }
  1095. resp, err := c.GetSignal(context.Background(), request)
  1096. if err != nil {
  1097. t.Fatal(err)
  1098. }
  1099. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1100. t.Errorf("wrong request %q, want %q", got, want)
  1101. }
  1102. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1103. t.Errorf("wrong response %q, want %q)", got, want)
  1104. }
  1105. }
  1106. func TestIncidentServiceGetSignalError(t *testing.T) {
  1107. errCode := codes.PermissionDenied
  1108. mockIncident.err = gstatus.Error(errCode, "test error")
  1109. var formattedName string = fmt.Sprintf("projects/%s/signals/%s", "[PROJECT]", "[SIGNAL]")
  1110. var request = &irmpb.GetSignalRequest{
  1111. Name: formattedName,
  1112. }
  1113. c, err := NewIncidentClient(context.Background(), clientOpt)
  1114. if err != nil {
  1115. t.Fatal(err)
  1116. }
  1117. resp, err := c.GetSignal(context.Background(), request)
  1118. if st, ok := gstatus.FromError(err); !ok {
  1119. t.Errorf("got error %v, expected grpc error", err)
  1120. } else if c := st.Code(); c != errCode {
  1121. t.Errorf("got error code %q, want %q", c, errCode)
  1122. }
  1123. _ = resp
  1124. }
  1125. func TestIncidentServiceUpdateSignal(t *testing.T) {
  1126. var name string = "name3373707"
  1127. var etag string = "etag3123477"
  1128. var incident string = "incident86983890"
  1129. var title string = "title110371416"
  1130. var contentType string = "contentType831846208"
  1131. var content string = "content951530617"
  1132. var expectedResponse = &irmpb.Signal{
  1133. Name: name,
  1134. Etag: etag,
  1135. Incident: incident,
  1136. Title: title,
  1137. ContentType: contentType,
  1138. Content: content,
  1139. }
  1140. mockIncident.err = nil
  1141. mockIncident.reqs = nil
  1142. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1143. var signal *irmpb.Signal = &irmpb.Signal{}
  1144. var request = &irmpb.UpdateSignalRequest{
  1145. Signal: signal,
  1146. }
  1147. c, err := NewIncidentClient(context.Background(), clientOpt)
  1148. if err != nil {
  1149. t.Fatal(err)
  1150. }
  1151. resp, err := c.UpdateSignal(context.Background(), request)
  1152. if err != nil {
  1153. t.Fatal(err)
  1154. }
  1155. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1156. t.Errorf("wrong request %q, want %q", got, want)
  1157. }
  1158. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1159. t.Errorf("wrong response %q, want %q)", got, want)
  1160. }
  1161. }
  1162. func TestIncidentServiceUpdateSignalError(t *testing.T) {
  1163. errCode := codes.PermissionDenied
  1164. mockIncident.err = gstatus.Error(errCode, "test error")
  1165. var signal *irmpb.Signal = &irmpb.Signal{}
  1166. var request = &irmpb.UpdateSignalRequest{
  1167. Signal: signal,
  1168. }
  1169. c, err := NewIncidentClient(context.Background(), clientOpt)
  1170. if err != nil {
  1171. t.Fatal(err)
  1172. }
  1173. resp, err := c.UpdateSignal(context.Background(), request)
  1174. if st, ok := gstatus.FromError(err); !ok {
  1175. t.Errorf("got error %v, expected grpc error", err)
  1176. } else if c := st.Code(); c != errCode {
  1177. t.Errorf("got error code %q, want %q", c, errCode)
  1178. }
  1179. _ = resp
  1180. }
  1181. func TestIncidentServiceEscalateIncident(t *testing.T) {
  1182. var expectedResponse *irmpb.EscalateIncidentResponse = &irmpb.EscalateIncidentResponse{}
  1183. mockIncident.err = nil
  1184. mockIncident.reqs = nil
  1185. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1186. var incident *irmpb.Incident = &irmpb.Incident{}
  1187. var request = &irmpb.EscalateIncidentRequest{
  1188. Incident: incident,
  1189. }
  1190. c, err := NewIncidentClient(context.Background(), clientOpt)
  1191. if err != nil {
  1192. t.Fatal(err)
  1193. }
  1194. resp, err := c.EscalateIncident(context.Background(), request)
  1195. if err != nil {
  1196. t.Fatal(err)
  1197. }
  1198. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1199. t.Errorf("wrong request %q, want %q", got, want)
  1200. }
  1201. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1202. t.Errorf("wrong response %q, want %q)", got, want)
  1203. }
  1204. }
  1205. func TestIncidentServiceEscalateIncidentError(t *testing.T) {
  1206. errCode := codes.PermissionDenied
  1207. mockIncident.err = gstatus.Error(errCode, "test error")
  1208. var incident *irmpb.Incident = &irmpb.Incident{}
  1209. var request = &irmpb.EscalateIncidentRequest{
  1210. Incident: incident,
  1211. }
  1212. c, err := NewIncidentClient(context.Background(), clientOpt)
  1213. if err != nil {
  1214. t.Fatal(err)
  1215. }
  1216. resp, err := c.EscalateIncident(context.Background(), request)
  1217. if st, ok := gstatus.FromError(err); !ok {
  1218. t.Errorf("got error %v, expected grpc error", err)
  1219. } else if c := st.Code(); c != errCode {
  1220. t.Errorf("got error code %q, want %q", c, errCode)
  1221. }
  1222. _ = resp
  1223. }
  1224. func TestIncidentServiceCreateArtifact(t *testing.T) {
  1225. var name string = "name3373707"
  1226. var displayName string = "displayName1615086568"
  1227. var etag string = "etag3123477"
  1228. var url string = "url116079"
  1229. var expectedResponse = &irmpb.Artifact{
  1230. Name: name,
  1231. DisplayName: displayName,
  1232. Etag: etag,
  1233. Url: url,
  1234. }
  1235. mockIncident.err = nil
  1236. mockIncident.reqs = nil
  1237. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1238. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1239. var artifact *irmpb.Artifact = &irmpb.Artifact{}
  1240. var request = &irmpb.CreateArtifactRequest{
  1241. Parent: formattedParent,
  1242. Artifact: artifact,
  1243. }
  1244. c, err := NewIncidentClient(context.Background(), clientOpt)
  1245. if err != nil {
  1246. t.Fatal(err)
  1247. }
  1248. resp, err := c.CreateArtifact(context.Background(), request)
  1249. if err != nil {
  1250. t.Fatal(err)
  1251. }
  1252. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1253. t.Errorf("wrong request %q, want %q", got, want)
  1254. }
  1255. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1256. t.Errorf("wrong response %q, want %q)", got, want)
  1257. }
  1258. }
  1259. func TestIncidentServiceCreateArtifactError(t *testing.T) {
  1260. errCode := codes.PermissionDenied
  1261. mockIncident.err = gstatus.Error(errCode, "test error")
  1262. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1263. var artifact *irmpb.Artifact = &irmpb.Artifact{}
  1264. var request = &irmpb.CreateArtifactRequest{
  1265. Parent: formattedParent,
  1266. Artifact: artifact,
  1267. }
  1268. c, err := NewIncidentClient(context.Background(), clientOpt)
  1269. if err != nil {
  1270. t.Fatal(err)
  1271. }
  1272. resp, err := c.CreateArtifact(context.Background(), request)
  1273. if st, ok := gstatus.FromError(err); !ok {
  1274. t.Errorf("got error %v, expected grpc error", err)
  1275. } else if c := st.Code(); c != errCode {
  1276. t.Errorf("got error code %q, want %q", c, errCode)
  1277. }
  1278. _ = resp
  1279. }
  1280. func TestIncidentServiceListArtifacts(t *testing.T) {
  1281. var nextPageToken string = ""
  1282. var artifactsElement *irmpb.Artifact = &irmpb.Artifact{}
  1283. var artifacts = []*irmpb.Artifact{artifactsElement}
  1284. var expectedResponse = &irmpb.ListArtifactsResponse{
  1285. NextPageToken: nextPageToken,
  1286. Artifacts: artifacts,
  1287. }
  1288. mockIncident.err = nil
  1289. mockIncident.reqs = nil
  1290. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1291. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1292. var request = &irmpb.ListArtifactsRequest{
  1293. Parent: formattedParent,
  1294. }
  1295. c, err := NewIncidentClient(context.Background(), clientOpt)
  1296. if err != nil {
  1297. t.Fatal(err)
  1298. }
  1299. resp, err := c.ListArtifacts(context.Background(), request).Next()
  1300. if err != nil {
  1301. t.Fatal(err)
  1302. }
  1303. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1304. t.Errorf("wrong request %q, want %q", got, want)
  1305. }
  1306. want := (interface{})(expectedResponse.Artifacts[0])
  1307. got := (interface{})(resp)
  1308. var ok bool
  1309. switch want := (want).(type) {
  1310. case proto.Message:
  1311. ok = proto.Equal(want, got.(proto.Message))
  1312. default:
  1313. ok = want == got
  1314. }
  1315. if !ok {
  1316. t.Errorf("wrong response %q, want %q)", got, want)
  1317. }
  1318. }
  1319. func TestIncidentServiceListArtifactsError(t *testing.T) {
  1320. errCode := codes.PermissionDenied
  1321. mockIncident.err = gstatus.Error(errCode, "test error")
  1322. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1323. var request = &irmpb.ListArtifactsRequest{
  1324. Parent: formattedParent,
  1325. }
  1326. c, err := NewIncidentClient(context.Background(), clientOpt)
  1327. if err != nil {
  1328. t.Fatal(err)
  1329. }
  1330. resp, err := c.ListArtifacts(context.Background(), request).Next()
  1331. if st, ok := gstatus.FromError(err); !ok {
  1332. t.Errorf("got error %v, expected grpc error", err)
  1333. } else if c := st.Code(); c != errCode {
  1334. t.Errorf("got error code %q, want %q", c, errCode)
  1335. }
  1336. _ = resp
  1337. }
  1338. func TestIncidentServiceUpdateArtifact(t *testing.T) {
  1339. var name string = "name3373707"
  1340. var displayName string = "displayName1615086568"
  1341. var etag string = "etag3123477"
  1342. var url string = "url116079"
  1343. var expectedResponse = &irmpb.Artifact{
  1344. Name: name,
  1345. DisplayName: displayName,
  1346. Etag: etag,
  1347. Url: url,
  1348. }
  1349. mockIncident.err = nil
  1350. mockIncident.reqs = nil
  1351. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1352. var artifact *irmpb.Artifact = &irmpb.Artifact{}
  1353. var request = &irmpb.UpdateArtifactRequest{
  1354. Artifact: artifact,
  1355. }
  1356. c, err := NewIncidentClient(context.Background(), clientOpt)
  1357. if err != nil {
  1358. t.Fatal(err)
  1359. }
  1360. resp, err := c.UpdateArtifact(context.Background(), request)
  1361. if err != nil {
  1362. t.Fatal(err)
  1363. }
  1364. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1365. t.Errorf("wrong request %q, want %q", got, want)
  1366. }
  1367. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1368. t.Errorf("wrong response %q, want %q)", got, want)
  1369. }
  1370. }
  1371. func TestIncidentServiceUpdateArtifactError(t *testing.T) {
  1372. errCode := codes.PermissionDenied
  1373. mockIncident.err = gstatus.Error(errCode, "test error")
  1374. var artifact *irmpb.Artifact = &irmpb.Artifact{}
  1375. var request = &irmpb.UpdateArtifactRequest{
  1376. Artifact: artifact,
  1377. }
  1378. c, err := NewIncidentClient(context.Background(), clientOpt)
  1379. if err != nil {
  1380. t.Fatal(err)
  1381. }
  1382. resp, err := c.UpdateArtifact(context.Background(), request)
  1383. if st, ok := gstatus.FromError(err); !ok {
  1384. t.Errorf("got error %v, expected grpc error", err)
  1385. } else if c := st.Code(); c != errCode {
  1386. t.Errorf("got error code %q, want %q", c, errCode)
  1387. }
  1388. _ = resp
  1389. }
  1390. func TestIncidentServiceDeleteArtifact(t *testing.T) {
  1391. var expectedResponse *emptypb.Empty = &emptypb.Empty{}
  1392. mockIncident.err = nil
  1393. mockIncident.reqs = nil
  1394. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1395. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/artifacts/%s", "[PROJECT]", "[INCIDENT]", "[ARTIFACT]")
  1396. var request = &irmpb.DeleteArtifactRequest{
  1397. Name: formattedName,
  1398. }
  1399. c, err := NewIncidentClient(context.Background(), clientOpt)
  1400. if err != nil {
  1401. t.Fatal(err)
  1402. }
  1403. err = c.DeleteArtifact(context.Background(), request)
  1404. if err != nil {
  1405. t.Fatal(err)
  1406. }
  1407. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1408. t.Errorf("wrong request %q, want %q", got, want)
  1409. }
  1410. }
  1411. func TestIncidentServiceDeleteArtifactError(t *testing.T) {
  1412. errCode := codes.PermissionDenied
  1413. mockIncident.err = gstatus.Error(errCode, "test error")
  1414. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/artifacts/%s", "[PROJECT]", "[INCIDENT]", "[ARTIFACT]")
  1415. var request = &irmpb.DeleteArtifactRequest{
  1416. Name: formattedName,
  1417. }
  1418. c, err := NewIncidentClient(context.Background(), clientOpt)
  1419. if err != nil {
  1420. t.Fatal(err)
  1421. }
  1422. err = c.DeleteArtifact(context.Background(), request)
  1423. if st, ok := gstatus.FromError(err); !ok {
  1424. t.Errorf("got error %v, expected grpc error", err)
  1425. } else if c := st.Code(); c != errCode {
  1426. t.Errorf("got error code %q, want %q", c, errCode)
  1427. }
  1428. }
  1429. func TestIncidentServiceSendShiftHandoff(t *testing.T) {
  1430. var contentType string = "contentType831846208"
  1431. var content string = "content951530617"
  1432. var expectedResponse = &irmpb.SendShiftHandoffResponse{
  1433. ContentType: contentType,
  1434. Content: content,
  1435. }
  1436. mockIncident.err = nil
  1437. mockIncident.reqs = nil
  1438. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1439. var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
  1440. var recipients []string = nil
  1441. var subject string = "subject-1867885268"
  1442. var request = &irmpb.SendShiftHandoffRequest{
  1443. Parent: formattedParent,
  1444. Recipients: recipients,
  1445. Subject: subject,
  1446. }
  1447. c, err := NewIncidentClient(context.Background(), clientOpt)
  1448. if err != nil {
  1449. t.Fatal(err)
  1450. }
  1451. resp, err := c.SendShiftHandoff(context.Background(), request)
  1452. if err != nil {
  1453. t.Fatal(err)
  1454. }
  1455. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1456. t.Errorf("wrong request %q, want %q", got, want)
  1457. }
  1458. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1459. t.Errorf("wrong response %q, want %q)", got, want)
  1460. }
  1461. }
  1462. func TestIncidentServiceSendShiftHandoffError(t *testing.T) {
  1463. errCode := codes.PermissionDenied
  1464. mockIncident.err = gstatus.Error(errCode, "test error")
  1465. var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
  1466. var recipients []string = nil
  1467. var subject string = "subject-1867885268"
  1468. var request = &irmpb.SendShiftHandoffRequest{
  1469. Parent: formattedParent,
  1470. Recipients: recipients,
  1471. Subject: subject,
  1472. }
  1473. c, err := NewIncidentClient(context.Background(), clientOpt)
  1474. if err != nil {
  1475. t.Fatal(err)
  1476. }
  1477. resp, err := c.SendShiftHandoff(context.Background(), request)
  1478. if st, ok := gstatus.FromError(err); !ok {
  1479. t.Errorf("got error %v, expected grpc error", err)
  1480. } else if c := st.Code(); c != errCode {
  1481. t.Errorf("got error code %q, want %q", c, errCode)
  1482. }
  1483. _ = resp
  1484. }
  1485. func TestIncidentServiceCreateSubscription(t *testing.T) {
  1486. var name string = "name3373707"
  1487. var etag string = "etag3123477"
  1488. var expectedResponse = &irmpb.Subscription{
  1489. Name: name,
  1490. Etag: etag,
  1491. }
  1492. mockIncident.err = nil
  1493. mockIncident.reqs = nil
  1494. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1495. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1496. var subscription *irmpb.Subscription = &irmpb.Subscription{}
  1497. var request = &irmpb.CreateSubscriptionRequest{
  1498. Parent: formattedParent,
  1499. Subscription: subscription,
  1500. }
  1501. c, err := NewIncidentClient(context.Background(), clientOpt)
  1502. if err != nil {
  1503. t.Fatal(err)
  1504. }
  1505. resp, err := c.CreateSubscription(context.Background(), request)
  1506. if err != nil {
  1507. t.Fatal(err)
  1508. }
  1509. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1510. t.Errorf("wrong request %q, want %q", got, want)
  1511. }
  1512. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1513. t.Errorf("wrong response %q, want %q)", got, want)
  1514. }
  1515. }
  1516. func TestIncidentServiceCreateSubscriptionError(t *testing.T) {
  1517. errCode := codes.PermissionDenied
  1518. mockIncident.err = gstatus.Error(errCode, "test error")
  1519. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1520. var subscription *irmpb.Subscription = &irmpb.Subscription{}
  1521. var request = &irmpb.CreateSubscriptionRequest{
  1522. Parent: formattedParent,
  1523. Subscription: subscription,
  1524. }
  1525. c, err := NewIncidentClient(context.Background(), clientOpt)
  1526. if err != nil {
  1527. t.Fatal(err)
  1528. }
  1529. resp, err := c.CreateSubscription(context.Background(), request)
  1530. if st, ok := gstatus.FromError(err); !ok {
  1531. t.Errorf("got error %v, expected grpc error", err)
  1532. } else if c := st.Code(); c != errCode {
  1533. t.Errorf("got error code %q, want %q", c, errCode)
  1534. }
  1535. _ = resp
  1536. }
  1537. func TestIncidentServiceUpdateSubscription(t *testing.T) {
  1538. var name string = "name3373707"
  1539. var etag string = "etag3123477"
  1540. var expectedResponse = &irmpb.Subscription{
  1541. Name: name,
  1542. Etag: etag,
  1543. }
  1544. mockIncident.err = nil
  1545. mockIncident.reqs = nil
  1546. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1547. var subscription *irmpb.Subscription = &irmpb.Subscription{}
  1548. var request = &irmpb.UpdateSubscriptionRequest{
  1549. Subscription: subscription,
  1550. }
  1551. c, err := NewIncidentClient(context.Background(), clientOpt)
  1552. if err != nil {
  1553. t.Fatal(err)
  1554. }
  1555. resp, err := c.UpdateSubscription(context.Background(), request)
  1556. if err != nil {
  1557. t.Fatal(err)
  1558. }
  1559. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1560. t.Errorf("wrong request %q, want %q", got, want)
  1561. }
  1562. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1563. t.Errorf("wrong response %q, want %q)", got, want)
  1564. }
  1565. }
  1566. func TestIncidentServiceUpdateSubscriptionError(t *testing.T) {
  1567. errCode := codes.PermissionDenied
  1568. mockIncident.err = gstatus.Error(errCode, "test error")
  1569. var subscription *irmpb.Subscription = &irmpb.Subscription{}
  1570. var request = &irmpb.UpdateSubscriptionRequest{
  1571. Subscription: subscription,
  1572. }
  1573. c, err := NewIncidentClient(context.Background(), clientOpt)
  1574. if err != nil {
  1575. t.Fatal(err)
  1576. }
  1577. resp, err := c.UpdateSubscription(context.Background(), request)
  1578. if st, ok := gstatus.FromError(err); !ok {
  1579. t.Errorf("got error %v, expected grpc error", err)
  1580. } else if c := st.Code(); c != errCode {
  1581. t.Errorf("got error code %q, want %q", c, errCode)
  1582. }
  1583. _ = resp
  1584. }
  1585. func TestIncidentServiceListSubscriptions(t *testing.T) {
  1586. var nextPageToken string = ""
  1587. var subscriptionsElement *irmpb.Subscription = &irmpb.Subscription{}
  1588. var subscriptions = []*irmpb.Subscription{subscriptionsElement}
  1589. var expectedResponse = &irmpb.ListSubscriptionsResponse{
  1590. NextPageToken: nextPageToken,
  1591. Subscriptions: subscriptions,
  1592. }
  1593. mockIncident.err = nil
  1594. mockIncident.reqs = nil
  1595. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1596. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1597. var request = &irmpb.ListSubscriptionsRequest{
  1598. Parent: formattedParent,
  1599. }
  1600. c, err := NewIncidentClient(context.Background(), clientOpt)
  1601. if err != nil {
  1602. t.Fatal(err)
  1603. }
  1604. resp, err := c.ListSubscriptions(context.Background(), request).Next()
  1605. if err != nil {
  1606. t.Fatal(err)
  1607. }
  1608. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1609. t.Errorf("wrong request %q, want %q", got, want)
  1610. }
  1611. want := (interface{})(expectedResponse.Subscriptions[0])
  1612. got := (interface{})(resp)
  1613. var ok bool
  1614. switch want := (want).(type) {
  1615. case proto.Message:
  1616. ok = proto.Equal(want, got.(proto.Message))
  1617. default:
  1618. ok = want == got
  1619. }
  1620. if !ok {
  1621. t.Errorf("wrong response %q, want %q)", got, want)
  1622. }
  1623. }
  1624. func TestIncidentServiceListSubscriptionsError(t *testing.T) {
  1625. errCode := codes.PermissionDenied
  1626. mockIncident.err = gstatus.Error(errCode, "test error")
  1627. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1628. var request = &irmpb.ListSubscriptionsRequest{
  1629. Parent: formattedParent,
  1630. }
  1631. c, err := NewIncidentClient(context.Background(), clientOpt)
  1632. if err != nil {
  1633. t.Fatal(err)
  1634. }
  1635. resp, err := c.ListSubscriptions(context.Background(), request).Next()
  1636. if st, ok := gstatus.FromError(err); !ok {
  1637. t.Errorf("got error %v, expected grpc error", err)
  1638. } else if c := st.Code(); c != errCode {
  1639. t.Errorf("got error code %q, want %q", c, errCode)
  1640. }
  1641. _ = resp
  1642. }
  1643. func TestIncidentServiceDeleteSubscription(t *testing.T) {
  1644. var expectedResponse *emptypb.Empty = &emptypb.Empty{}
  1645. mockIncident.err = nil
  1646. mockIncident.reqs = nil
  1647. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1648. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/subscriptions/%s", "[PROJECT]", "[INCIDENT]", "[SUBSCRIPTION]")
  1649. var request = &irmpb.DeleteSubscriptionRequest{
  1650. Name: formattedName,
  1651. }
  1652. c, err := NewIncidentClient(context.Background(), clientOpt)
  1653. if err != nil {
  1654. t.Fatal(err)
  1655. }
  1656. err = c.DeleteSubscription(context.Background(), request)
  1657. if err != nil {
  1658. t.Fatal(err)
  1659. }
  1660. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1661. t.Errorf("wrong request %q, want %q", got, want)
  1662. }
  1663. }
  1664. func TestIncidentServiceDeleteSubscriptionError(t *testing.T) {
  1665. errCode := codes.PermissionDenied
  1666. mockIncident.err = gstatus.Error(errCode, "test error")
  1667. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/subscriptions/%s", "[PROJECT]", "[INCIDENT]", "[SUBSCRIPTION]")
  1668. var request = &irmpb.DeleteSubscriptionRequest{
  1669. Name: formattedName,
  1670. }
  1671. c, err := NewIncidentClient(context.Background(), clientOpt)
  1672. if err != nil {
  1673. t.Fatal(err)
  1674. }
  1675. err = c.DeleteSubscription(context.Background(), request)
  1676. if st, ok := gstatus.FromError(err); !ok {
  1677. t.Errorf("got error %v, expected grpc error", err)
  1678. } else if c := st.Code(); c != errCode {
  1679. t.Errorf("got error code %q, want %q", c, errCode)
  1680. }
  1681. }
  1682. func TestIncidentServiceCreateIncidentRoleAssignment(t *testing.T) {
  1683. var name string = "name3373707"
  1684. var etag string = "etag3123477"
  1685. var expectedResponse = &irmpb.IncidentRoleAssignment{
  1686. Name: name,
  1687. Etag: etag,
  1688. }
  1689. mockIncident.err = nil
  1690. mockIncident.reqs = nil
  1691. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1692. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1693. var incidentRoleAssignment *irmpb.IncidentRoleAssignment = &irmpb.IncidentRoleAssignment{}
  1694. var request = &irmpb.CreateIncidentRoleAssignmentRequest{
  1695. Parent: formattedParent,
  1696. IncidentRoleAssignment: incidentRoleAssignment,
  1697. }
  1698. c, err := NewIncidentClient(context.Background(), clientOpt)
  1699. if err != nil {
  1700. t.Fatal(err)
  1701. }
  1702. resp, err := c.CreateIncidentRoleAssignment(context.Background(), request)
  1703. if err != nil {
  1704. t.Fatal(err)
  1705. }
  1706. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1707. t.Errorf("wrong request %q, want %q", got, want)
  1708. }
  1709. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1710. t.Errorf("wrong response %q, want %q)", got, want)
  1711. }
  1712. }
  1713. func TestIncidentServiceCreateIncidentRoleAssignmentError(t *testing.T) {
  1714. errCode := codes.PermissionDenied
  1715. mockIncident.err = gstatus.Error(errCode, "test error")
  1716. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1717. var incidentRoleAssignment *irmpb.IncidentRoleAssignment = &irmpb.IncidentRoleAssignment{}
  1718. var request = &irmpb.CreateIncidentRoleAssignmentRequest{
  1719. Parent: formattedParent,
  1720. IncidentRoleAssignment: incidentRoleAssignment,
  1721. }
  1722. c, err := NewIncidentClient(context.Background(), clientOpt)
  1723. if err != nil {
  1724. t.Fatal(err)
  1725. }
  1726. resp, err := c.CreateIncidentRoleAssignment(context.Background(), request)
  1727. if st, ok := gstatus.FromError(err); !ok {
  1728. t.Errorf("got error %v, expected grpc error", err)
  1729. } else if c := st.Code(); c != errCode {
  1730. t.Errorf("got error code %q, want %q", c, errCode)
  1731. }
  1732. _ = resp
  1733. }
  1734. func TestIncidentServiceDeleteIncidentRoleAssignment(t *testing.T) {
  1735. var expectedResponse *emptypb.Empty = &emptypb.Empty{}
  1736. mockIncident.err = nil
  1737. mockIncident.reqs = nil
  1738. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1739. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/roleAssignments/%s", "[PROJECT]", "[INCIDENT]", "[ROLE_ASSIGNMENT]")
  1740. var request = &irmpb.DeleteIncidentRoleAssignmentRequest{
  1741. Name: formattedName,
  1742. }
  1743. c, err := NewIncidentClient(context.Background(), clientOpt)
  1744. if err != nil {
  1745. t.Fatal(err)
  1746. }
  1747. err = c.DeleteIncidentRoleAssignment(context.Background(), request)
  1748. if err != nil {
  1749. t.Fatal(err)
  1750. }
  1751. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1752. t.Errorf("wrong request %q, want %q", got, want)
  1753. }
  1754. }
  1755. func TestIncidentServiceDeleteIncidentRoleAssignmentError(t *testing.T) {
  1756. errCode := codes.PermissionDenied
  1757. mockIncident.err = gstatus.Error(errCode, "test error")
  1758. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/roleAssignments/%s", "[PROJECT]", "[INCIDENT]", "[ROLE_ASSIGNMENT]")
  1759. var request = &irmpb.DeleteIncidentRoleAssignmentRequest{
  1760. Name: formattedName,
  1761. }
  1762. c, err := NewIncidentClient(context.Background(), clientOpt)
  1763. if err != nil {
  1764. t.Fatal(err)
  1765. }
  1766. err = c.DeleteIncidentRoleAssignment(context.Background(), request)
  1767. if st, ok := gstatus.FromError(err); !ok {
  1768. t.Errorf("got error %v, expected grpc error", err)
  1769. } else if c := st.Code(); c != errCode {
  1770. t.Errorf("got error code %q, want %q", c, errCode)
  1771. }
  1772. }
  1773. func TestIncidentServiceListIncidentRoleAssignments(t *testing.T) {
  1774. var nextPageToken string = ""
  1775. var incidentRoleAssignmentsElement *irmpb.IncidentRoleAssignment = &irmpb.IncidentRoleAssignment{}
  1776. var incidentRoleAssignments = []*irmpb.IncidentRoleAssignment{incidentRoleAssignmentsElement}
  1777. var expectedResponse = &irmpb.ListIncidentRoleAssignmentsResponse{
  1778. NextPageToken: nextPageToken,
  1779. IncidentRoleAssignments: incidentRoleAssignments,
  1780. }
  1781. mockIncident.err = nil
  1782. mockIncident.reqs = nil
  1783. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1784. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1785. var request = &irmpb.ListIncidentRoleAssignmentsRequest{
  1786. Parent: formattedParent,
  1787. }
  1788. c, err := NewIncidentClient(context.Background(), clientOpt)
  1789. if err != nil {
  1790. t.Fatal(err)
  1791. }
  1792. resp, err := c.ListIncidentRoleAssignments(context.Background(), request).Next()
  1793. if err != nil {
  1794. t.Fatal(err)
  1795. }
  1796. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1797. t.Errorf("wrong request %q, want %q", got, want)
  1798. }
  1799. want := (interface{})(expectedResponse.IncidentRoleAssignments[0])
  1800. got := (interface{})(resp)
  1801. var ok bool
  1802. switch want := (want).(type) {
  1803. case proto.Message:
  1804. ok = proto.Equal(want, got.(proto.Message))
  1805. default:
  1806. ok = want == got
  1807. }
  1808. if !ok {
  1809. t.Errorf("wrong response %q, want %q)", got, want)
  1810. }
  1811. }
  1812. func TestIncidentServiceListIncidentRoleAssignmentsError(t *testing.T) {
  1813. errCode := codes.PermissionDenied
  1814. mockIncident.err = gstatus.Error(errCode, "test error")
  1815. var formattedParent string = fmt.Sprintf("projects/%s/incidents/%s", "[PROJECT]", "[INCIDENT]")
  1816. var request = &irmpb.ListIncidentRoleAssignmentsRequest{
  1817. Parent: formattedParent,
  1818. }
  1819. c, err := NewIncidentClient(context.Background(), clientOpt)
  1820. if err != nil {
  1821. t.Fatal(err)
  1822. }
  1823. resp, err := c.ListIncidentRoleAssignments(context.Background(), request).Next()
  1824. if st, ok := gstatus.FromError(err); !ok {
  1825. t.Errorf("got error %v, expected grpc error", err)
  1826. } else if c := st.Code(); c != errCode {
  1827. t.Errorf("got error code %q, want %q", c, errCode)
  1828. }
  1829. _ = resp
  1830. }
  1831. func TestIncidentServiceRequestIncidentRoleHandover(t *testing.T) {
  1832. var name2 string = "name2-1052831874"
  1833. var etag string = "etag3123477"
  1834. var expectedResponse = &irmpb.IncidentRoleAssignment{
  1835. Name: name2,
  1836. Etag: etag,
  1837. }
  1838. mockIncident.err = nil
  1839. mockIncident.reqs = nil
  1840. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1841. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/roleAssignments/%s", "[PROJECT]", "[INCIDENT]", "[ROLE_ASSIGNMENT]")
  1842. var newAssignee *irmpb.User = &irmpb.User{}
  1843. var request = &irmpb.RequestIncidentRoleHandoverRequest{
  1844. Name: formattedName,
  1845. NewAssignee: newAssignee,
  1846. }
  1847. c, err := NewIncidentClient(context.Background(), clientOpt)
  1848. if err != nil {
  1849. t.Fatal(err)
  1850. }
  1851. resp, err := c.RequestIncidentRoleHandover(context.Background(), request)
  1852. if err != nil {
  1853. t.Fatal(err)
  1854. }
  1855. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1856. t.Errorf("wrong request %q, want %q", got, want)
  1857. }
  1858. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1859. t.Errorf("wrong response %q, want %q)", got, want)
  1860. }
  1861. }
  1862. func TestIncidentServiceRequestIncidentRoleHandoverError(t *testing.T) {
  1863. errCode := codes.PermissionDenied
  1864. mockIncident.err = gstatus.Error(errCode, "test error")
  1865. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/roleAssignments/%s", "[PROJECT]", "[INCIDENT]", "[ROLE_ASSIGNMENT]")
  1866. var newAssignee *irmpb.User = &irmpb.User{}
  1867. var request = &irmpb.RequestIncidentRoleHandoverRequest{
  1868. Name: formattedName,
  1869. NewAssignee: newAssignee,
  1870. }
  1871. c, err := NewIncidentClient(context.Background(), clientOpt)
  1872. if err != nil {
  1873. t.Fatal(err)
  1874. }
  1875. resp, err := c.RequestIncidentRoleHandover(context.Background(), request)
  1876. if st, ok := gstatus.FromError(err); !ok {
  1877. t.Errorf("got error %v, expected grpc error", err)
  1878. } else if c := st.Code(); c != errCode {
  1879. t.Errorf("got error code %q, want %q", c, errCode)
  1880. }
  1881. _ = resp
  1882. }
  1883. func TestIncidentServiceConfirmIncidentRoleHandover(t *testing.T) {
  1884. var name2 string = "name2-1052831874"
  1885. var etag string = "etag3123477"
  1886. var expectedResponse = &irmpb.IncidentRoleAssignment{
  1887. Name: name2,
  1888. Etag: etag,
  1889. }
  1890. mockIncident.err = nil
  1891. mockIncident.reqs = nil
  1892. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1893. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/roleAssignments/%s", "[PROJECT]", "[INCIDENT]", "[ROLE_ASSIGNMENT]")
  1894. var newAssignee *irmpb.User = &irmpb.User{}
  1895. var request = &irmpb.ConfirmIncidentRoleHandoverRequest{
  1896. Name: formattedName,
  1897. NewAssignee: newAssignee,
  1898. }
  1899. c, err := NewIncidentClient(context.Background(), clientOpt)
  1900. if err != nil {
  1901. t.Fatal(err)
  1902. }
  1903. resp, err := c.ConfirmIncidentRoleHandover(context.Background(), request)
  1904. if err != nil {
  1905. t.Fatal(err)
  1906. }
  1907. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1908. t.Errorf("wrong request %q, want %q", got, want)
  1909. }
  1910. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1911. t.Errorf("wrong response %q, want %q)", got, want)
  1912. }
  1913. }
  1914. func TestIncidentServiceConfirmIncidentRoleHandoverError(t *testing.T) {
  1915. errCode := codes.PermissionDenied
  1916. mockIncident.err = gstatus.Error(errCode, "test error")
  1917. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/roleAssignments/%s", "[PROJECT]", "[INCIDENT]", "[ROLE_ASSIGNMENT]")
  1918. var newAssignee *irmpb.User = &irmpb.User{}
  1919. var request = &irmpb.ConfirmIncidentRoleHandoverRequest{
  1920. Name: formattedName,
  1921. NewAssignee: newAssignee,
  1922. }
  1923. c, err := NewIncidentClient(context.Background(), clientOpt)
  1924. if err != nil {
  1925. t.Fatal(err)
  1926. }
  1927. resp, err := c.ConfirmIncidentRoleHandover(context.Background(), request)
  1928. if st, ok := gstatus.FromError(err); !ok {
  1929. t.Errorf("got error %v, expected grpc error", err)
  1930. } else if c := st.Code(); c != errCode {
  1931. t.Errorf("got error code %q, want %q", c, errCode)
  1932. }
  1933. _ = resp
  1934. }
  1935. func TestIncidentServiceForceIncidentRoleHandover(t *testing.T) {
  1936. var name2 string = "name2-1052831874"
  1937. var etag string = "etag3123477"
  1938. var expectedResponse = &irmpb.IncidentRoleAssignment{
  1939. Name: name2,
  1940. Etag: etag,
  1941. }
  1942. mockIncident.err = nil
  1943. mockIncident.reqs = nil
  1944. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1945. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/roleAssignments/%s", "[PROJECT]", "[INCIDENT]", "[ROLE_ASSIGNMENT]")
  1946. var newAssignee *irmpb.User = &irmpb.User{}
  1947. var request = &irmpb.ForceIncidentRoleHandoverRequest{
  1948. Name: formattedName,
  1949. NewAssignee: newAssignee,
  1950. }
  1951. c, err := NewIncidentClient(context.Background(), clientOpt)
  1952. if err != nil {
  1953. t.Fatal(err)
  1954. }
  1955. resp, err := c.ForceIncidentRoleHandover(context.Background(), request)
  1956. if err != nil {
  1957. t.Fatal(err)
  1958. }
  1959. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  1960. t.Errorf("wrong request %q, want %q", got, want)
  1961. }
  1962. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  1963. t.Errorf("wrong response %q, want %q)", got, want)
  1964. }
  1965. }
  1966. func TestIncidentServiceForceIncidentRoleHandoverError(t *testing.T) {
  1967. errCode := codes.PermissionDenied
  1968. mockIncident.err = gstatus.Error(errCode, "test error")
  1969. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/roleAssignments/%s", "[PROJECT]", "[INCIDENT]", "[ROLE_ASSIGNMENT]")
  1970. var newAssignee *irmpb.User = &irmpb.User{}
  1971. var request = &irmpb.ForceIncidentRoleHandoverRequest{
  1972. Name: formattedName,
  1973. NewAssignee: newAssignee,
  1974. }
  1975. c, err := NewIncidentClient(context.Background(), clientOpt)
  1976. if err != nil {
  1977. t.Fatal(err)
  1978. }
  1979. resp, err := c.ForceIncidentRoleHandover(context.Background(), request)
  1980. if st, ok := gstatus.FromError(err); !ok {
  1981. t.Errorf("got error %v, expected grpc error", err)
  1982. } else if c := st.Code(); c != errCode {
  1983. t.Errorf("got error code %q, want %q", c, errCode)
  1984. }
  1985. _ = resp
  1986. }
  1987. func TestIncidentServiceCancelIncidentRoleHandover(t *testing.T) {
  1988. var name2 string = "name2-1052831874"
  1989. var etag string = "etag3123477"
  1990. var expectedResponse = &irmpb.IncidentRoleAssignment{
  1991. Name: name2,
  1992. Etag: etag,
  1993. }
  1994. mockIncident.err = nil
  1995. mockIncident.reqs = nil
  1996. mockIncident.resps = append(mockIncident.resps[:0], expectedResponse)
  1997. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/roleAssignments/%s", "[PROJECT]", "[INCIDENT]", "[ROLE_ASSIGNMENT]")
  1998. var newAssignee *irmpb.User = &irmpb.User{}
  1999. var request = &irmpb.CancelIncidentRoleHandoverRequest{
  2000. Name: formattedName,
  2001. NewAssignee: newAssignee,
  2002. }
  2003. c, err := NewIncidentClient(context.Background(), clientOpt)
  2004. if err != nil {
  2005. t.Fatal(err)
  2006. }
  2007. resp, err := c.CancelIncidentRoleHandover(context.Background(), request)
  2008. if err != nil {
  2009. t.Fatal(err)
  2010. }
  2011. if want, got := request, mockIncident.reqs[0]; !proto.Equal(want, got) {
  2012. t.Errorf("wrong request %q, want %q", got, want)
  2013. }
  2014. if want, got := expectedResponse, resp; !proto.Equal(want, got) {
  2015. t.Errorf("wrong response %q, want %q)", got, want)
  2016. }
  2017. }
  2018. func TestIncidentServiceCancelIncidentRoleHandoverError(t *testing.T) {
  2019. errCode := codes.PermissionDenied
  2020. mockIncident.err = gstatus.Error(errCode, "test error")
  2021. var formattedName string = fmt.Sprintf("projects/%s/incidents/%s/roleAssignments/%s", "[PROJECT]", "[INCIDENT]", "[ROLE_ASSIGNMENT]")
  2022. var newAssignee *irmpb.User = &irmpb.User{}
  2023. var request = &irmpb.CancelIncidentRoleHandoverRequest{
  2024. Name: formattedName,
  2025. NewAssignee: newAssignee,
  2026. }
  2027. c, err := NewIncidentClient(context.Background(), clientOpt)
  2028. if err != nil {
  2029. t.Fatal(err)
  2030. }
  2031. resp, err := c.CancelIncidentRoleHandover(context.Background(), request)
  2032. if st, ok := gstatus.FromError(err); !ok {
  2033. t.Errorf("got error %v, expected grpc error", err)
  2034. } else if c := st.Code(); c != errCode {
  2035. t.Errorf("got error code %q, want %q", c, errCode)
  2036. }
  2037. _ = resp
  2038. }