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.
 
 
 

89 lines
2.4 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 errorreporting
  16. import (
  17. clouderrorreportingpb "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1"
  18. )
  19. import (
  20. "context"
  21. "fmt"
  22. "strconv"
  23. "testing"
  24. "time"
  25. "cloud.google.com/go/internal/testutil"
  26. "google.golang.org/api/iterator"
  27. "google.golang.org/api/option"
  28. )
  29. var _ = fmt.Sprintf
  30. var _ = iterator.Done
  31. var _ = strconv.FormatUint
  32. var _ = time.Now
  33. func TestReportErrorsServiceSmoke(t *testing.T) {
  34. if testing.Short() {
  35. t.Skip("skipping smoke test in short mode")
  36. }
  37. ctx := context.Background()
  38. ts := testutil.TokenSource(ctx, DefaultAuthScopes()...)
  39. if ts == nil {
  40. t.Skip("Integration tests skipped. See CONTRIBUTING.md for details")
  41. }
  42. projectId := testutil.ProjID()
  43. _ = projectId
  44. c, err := NewReportErrorsClient(ctx, option.WithTokenSource(ts))
  45. if err != nil {
  46. t.Fatal(err)
  47. }
  48. var formattedProjectName string = fmt.Sprintf("projects/%s", projectId)
  49. var message string = "[MESSAGE]"
  50. var service string = "[SERVICE]"
  51. var serviceContext = &clouderrorreportingpb.ServiceContext{
  52. Service: service,
  53. }
  54. var filePath string = "path/to/file.lang"
  55. var lineNumber int32 = 42
  56. var functionName string = "meaningOfLife"
  57. var reportLocation = &clouderrorreportingpb.SourceLocation{
  58. FilePath: filePath,
  59. LineNumber: lineNumber,
  60. FunctionName: functionName,
  61. }
  62. var context_ = &clouderrorreportingpb.ErrorContext{
  63. ReportLocation: reportLocation,
  64. }
  65. var event = &clouderrorreportingpb.ReportedErrorEvent{
  66. Message: message,
  67. ServiceContext: serviceContext,
  68. Context: context_,
  69. }
  70. var request = &clouderrorreportingpb.ReportErrorEventRequest{
  71. ProjectName: formattedProjectName,
  72. Event: event,
  73. }
  74. if _, err := c.ReportErrorEvent(ctx, request); err != nil {
  75. t.Error(err)
  76. }
  77. }