...

Source file src/google.golang.org/api/internal/examples/mock/highlevel_test.go

Documentation: google.golang.org/api/internal/examples/mock

     1  // Copyright 2021 Google LLC.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package mock
     6  
     7  import "testing"
     8  
     9  // mockService fulfills the TranslateService interface.
    10  type mockService struct{}
    11  
    12  func (*mockService) TranslateText(text, language string) (string, error) {
    13  	return "Hello World", nil
    14  }
    15  func TestTranslateTextHighLevel(t *testing.T) {
    16  	svc := &mockService{}
    17  	text, err := TranslateTextHighLevel(svc, "Hola Mundo", "en-US")
    18  	if err != nil {
    19  		t.Fatal(err)
    20  	}
    21  	if text != "Hello World" {
    22  		t.Fatalf("got %q, want Hello World", text)
    23  	}
    24  }
    25  

View as plain text