当前位置: 首页>>代码示例>>Golang>>正文


Golang testutil.SystemTest函数代码示例

本文整理汇总了Golang中github.com/GoogleCloudPlatform/golang-samples/internal/testutil.SystemTest函数的典型用法代码示例。如果您正苦于以下问题:Golang SystemTest函数的具体用法?Golang SystemTest怎么用?Golang SystemTest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SystemTest函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestList

func TestList(t *testing.T) {
	t.Skip("Flaky. Eventual consistency. Re-enable once the datastore emulator works with gRPC.")

	testutil.SystemTest(t)
	ctx := context.Background()

	desc := makeDesc()

	k, err := AddTask(ctx, client, desc)
	if err != nil {
		t.Fatal(err)
	}

	foundTask := listAndGetTask(t, desc)
	if got, want := foundTask.id, k.ID; got != want {
		t.Errorf("k.ID: got %d, want %d", got, want)
	}

	if err := MarkDone(ctx, client, foundTask.id); err != nil {
		t.Fatal(err)
	}

	foundTask = listAndGetTask(t, desc)
	if !foundTask.Done {
		t.Error("foundTask.Done: got false, want true")
	}

	if err := DeleteTask(ctx, client, foundTask.id); err != nil {
		t.Fatal(err)
	}
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:31,代码来源:tasks_test.go

示例2: TestCustomMetric

func TestCustomMetric(t *testing.T) {
	hc := testutil.SystemTest(t)
	ctx, _ := context.WithTimeout(context.Background(), time.Second*30)

	s, err := createService(ctx)
	if err != nil {
		t.Fatal(err)
	}

	if err := createCustomMetric(s, hc.ProjectID, metricType); err != nil {
		t.Fatal(err)
	}

	for {
		_, err = getCustomMetric(s, hc.ProjectID, metricType)
		if err == nil {
			break
		}
		time.Sleep(2 * time.Second)
	}
	if err != nil {
		t.Fatal(err)
	}

	time.Sleep(2 * time.Second)

	if err := writeTimeSeriesValue(s, hc.ProjectID, metricType); err != nil {
		t.Error(err)
	}

	if err := readTimeSeriesValue(s, hc.ProjectID, metricType); err != nil {
		t.Error(err)
	}
}
开发者ID:jeffmendoza,项目名称:golang-samples,代码行数:34,代码来源:custommetric_test.go

示例3: TestCreate

func TestCreate(t *testing.T) {
	tc := testutil.SystemTest(t)
	c := setup(t)
	if err := create(c, tc.ProjectID, bucketName); err != nil {
		t.Fatalf("failed to create bucket (%q): %v", bucketName, err)
	}
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:7,代码来源:main_test.go

示例4: TestRecognize

func TestRecognize(t *testing.T) {
	testutil.SystemTest(t)

	ctx := context.Background()
	client, err := speech.NewClient(ctx)
	if err != nil {
		t.Fatal(err)
	}

	opName, err := send(client, "./quit.raw")
	if err != nil {
		t.Fatal(err)
	}
	if opName == "" {
		t.Fatal("got no op name; want one")
	}
	resp, err := wait(client, opName)
	if err != nil {
		t.Fatal(err)
	}
	if len(resp.Results) == 0 {
		t.Fatal("got no results; want at least one")
	}
	result := resp.Results[0]
	if len(result.Alternatives) < 1 {
		t.Fatal("got no alternatives; want at least one")
	}
	if got, want := result.Alternatives[0].Transcript, "quit"; got != want {
		t.Errorf("Transcript: got %q; want %q", got, want)
	}
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:31,代码来源:captionasync_test.go

示例5: TestSimplelog

func TestSimplelog(t *testing.T) {
	tc := testutil.SystemTest(t)
	ctx := context.Background()

	client, err := logging.NewClient(ctx, tc.ProjectID)
	if err != nil {
		t.Fatalf("logging.NewClient: %v", err)
	}
	adminClient, err := logadmin.NewClient(ctx, tc.ProjectID)
	if err != nil {
		t.Fatalf("logadmin.NewClient: %v", err)
	}
	defer func() {
		if err := client.Close(); err != nil {
			t.Errorf("Close: %v", err)
		}
	}()

	defer func() {
		testutil.Retry(t, 10, time.Second, func(r *testutil.R) {
			if err := deleteLog(adminClient); err != nil {
				r.Errorf("deleteLog: %v", err)
			}
		})
	}()

	client.OnError = func(err error) {
		t.Errorf("OnError: %v", err)
	}

	writeEntry(client)
	structuredWrite(client)

	testutil.Retry(t, 10, time.Second, func(r *testutil.R) {
		entries, err := getEntries(adminClient, tc.ProjectID)
		if err != nil {
			r.Errorf("getEntries: %v", err)
			return
		}

		if got, want := len(entries), 2; got != want {
			r.Errorf("len(entries) = %d; want %d", got, want)
			return
		}

		wantContain := map[string]*logging.Entry{
			"Anything":                            entries[0],
			"The payload can be any type!":        entries[0],
			"infolog is a standard Go log.Logger": entries[1],
		}

		for want, entry := range wantContain {
			msg := fmt.Sprintf("%s", entry.Payload)
			if !strings.Contains(msg, want) {
				r.Errorf("want %q to contain %q", msg, want)
			}
		}
	})
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:59,代码来源:simplelog_test.go

示例6: TestDelete

func TestDelete(t *testing.T) {
	testutil.SystemTest(t)

	c := setup(t)
	if err := delete(c, bucketName); err != nil {
		t.Fatalf("failed to delete bucket (%q): %v", bucketName, err)
	}
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:8,代码来源:main_test.go

示例7: TestListInstances

func TestListInstances(t *testing.T) {
	tc := testutil.SystemTest(t)

	// Just check the call succeeds.
	_, err := ListInstances(tc.ProjectID)
	if err != nil {
		t.Fatal(err)
	}
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:9,代码来源:listinstances_test.go

示例8: setup

func setup(t *testing.T) *pubsub.Client {
	ctx := context.Background()
	tc := testutil.SystemTest(t)

	client, err := pubsub.NewClient(ctx, tc.ProjectID)
	if err != nil {
		t.Fatalf("failed to create client: %v", err)
	}
	return client
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:10,代码来源:main_test.go

示例9: TestListBuckets

func TestListBuckets(t *testing.T) {
	tc := testutil.SystemTest(t)

	buckets, err := ListBuckets(tc.ProjectID)
	if err != nil {
		t.Errorf("error while listing buckets: %s", err)
	}
	if len(buckets) <= 0 {
		t.Error("want non-empty list of buckets")
	}
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:11,代码来源:listbuckets_test.go

示例10: TestCreateWithAttrs

func TestCreateWithAttrs(t *testing.T) {
	tc := testutil.SystemTest(t)
	c := setup(t)
	name := bucketName + "-attrs"
	if err := createWithAttrs(c, tc.ProjectID, name); err != nil {
		t.Fatalf("failed to create bucket (%q): %v", bucketName, err)
	}
	if err := delete(c, name); err != nil {
		t.Fatalf("failed to delete bucket (%q): %v", bucketName, err)
	}
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:11,代码来源:main_test.go

示例11: TestListSupported

func TestListSupported(t *testing.T) {
	testutil.SystemTest(t)

	buf := &bytes.Buffer{}
	if err := listSupportedLanguages(buf, "th"); err != nil {
		t.Fatal(err)
	}
	if got, want := buf.String(), `"en":`; !strings.Contains(got, want) {
		t.Errorf("listSupportedLanguages(th): want %q in %q", want, got)
	}
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:11,代码来源:snippet_test.go

示例12: TestLabel

func TestLabel(t *testing.T) {
	testutil.SystemTest(t)

	labels, err := findLabels("../testdata/cat.jpg")
	if err != nil {
		t.Fatalf("got %v, want nil err", err)
	}
	if len(labels) == 0 {
		t.Fatalf("want non-empty slice of labels")
	}
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:11,代码来源:label_test.go

示例13: TestTranslateText

func TestTranslateText(t *testing.T) {
	testutil.SystemTest(t)

	got, err := translateText("ja", "The Go Gopher is cute")
	if err != nil {
		t.Fatalf("translateText: %v", err)
	}
	if want := "可愛い"; !strings.Contains(got, want) {
		t.Errorf("translateText(Gophers are cute)=%q; want to contain %q", got, want)
	}
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:11,代码来源:snippet_test.go

示例14: TestListInstances

func TestListInstances(t *testing.T) {
	tc := testutil.SystemTest(t)

	instances, err := ListInstances(tc.ProjectID)
	if err != nil {
		t.Fatal(err)
	}
	if len(instances) == 0 {
		t.Fatalf("want non-zero SQL instances in project %q", tc.ProjectID)
	}
}
开发者ID:jeffmendoza,项目名称:golang-samples,代码行数:11,代码来源:listinstances_test.go

示例15: TestAll

func TestAll(t *testing.T) {
	tc := testutil.SystemTest(t)
	ctx := context.Background()

	client, err := bigquery.NewClient(ctx, tc.ProjectID)
	if err != nil {
		t.Fatal(err)
	}
	datasetID := fmt.Sprintf("golang_example_dataset_%d", time.Now().Unix())
	if err := createDataset(client, datasetID); err != nil {
		t.Errorf("failed to create dataset: %v", err)
	}
	if err := listDatasets(client); err != nil {
		t.Errorf("failed to create dataset: %v", err)
	}

	tableID := fmt.Sprintf("golang_example_table_%d", time.Now().Unix())
	if err := createTable(client, datasetID, tableID); err != nil {
		t.Errorf("failed to create table: %v", err)
	}
	buf := &bytes.Buffer{}
	if err := listTables(client, buf, datasetID); err != nil {
		t.Errorf("failed to list tables: %v", err)
	}
	if got := buf.String(); !strings.Contains(got, tableID) {
		t.Errorf("want table list %q to contain table %q", got, tableID)
	}
	if err := insertRows(client, datasetID, tableID); err != nil {
		t.Errorf("failed to insert rows: %v", err)
	}
	if err := listRows(client, datasetID, tableID); err != nil {
		t.Errorf("failed to list rows: %v", err)
	}
	if err := browseTable(client, datasetID, tableID); err != nil {
		t.Errorf("failed to list rows: %v", err)
	}
	if err := asyncQuery(client, datasetID, tableID); err != nil {
		t.Errorf("failed to async query: %v", err)
	}

	dstTableID := fmt.Sprintf("golang_example_tabledst_%d", time.Now().Unix())
	if err := copyTable(client, datasetID, tableID, dstTableID); err != nil {
		t.Errorf("failed to copy table: %v", err)
	}
	if err := deleteTable(client, datasetID, tableID); err != nil {
		t.Errorf("failed to delete table: %v", err)
	}
	if err := deleteTable(client, datasetID, dstTableID); err != nil {
		t.Errorf("failed to delete table: %v", err)
	}

	deleteDataset(t, ctx, datasetID)
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:53,代码来源:snippet_test.go


注:本文中的github.com/GoogleCloudPlatform/golang-samples/internal/testutil.SystemTest函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。