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.
 
 
 

83 lines
2.1 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 vision
  16. import (
  17. visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1"
  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 TestImageAnnotatorSmoke(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 := NewImageAnnotatorClient(ctx, option.WithTokenSource(ts))
  45. if err != nil {
  46. t.Fatal(err)
  47. }
  48. var gcsImageUri string = "gs://gapic-toolkit/President_Barack_Obama.jpg"
  49. var source = &visionpb.ImageSource{
  50. GcsImageUri: gcsImageUri,
  51. }
  52. var image = &visionpb.Image{
  53. Source: source,
  54. }
  55. var type_ visionpb.Feature_Type = visionpb.Feature_FACE_DETECTION
  56. var featuresElement = &visionpb.Feature{
  57. Type: type_,
  58. }
  59. var features = []*visionpb.Feature{featuresElement}
  60. var requestsElement = &visionpb.AnnotateImageRequest{
  61. Image: image,
  62. Features: features,
  63. }
  64. var requests = []*visionpb.AnnotateImageRequest{requestsElement}
  65. var request = &visionpb.BatchAnnotateImagesRequest{
  66. Requests: requests,
  67. }
  68. if _, err := c.BatchAnnotateImages(ctx, request); err != nil {
  69. t.Error(err)
  70. }
  71. }