forked from GoogleCloudPlatform/golang-samples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlistresources_test.go
45 lines (37 loc) · 937 Bytes
/
listresources_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package main
import (
"io/ioutil"
"log"
"os"
"testing"
"time"
"golang.org/x/net/context"
"github.com/GoogleCloudPlatform/golang-samples/internal/testutil"
)
func TestMain(m *testing.M) {
// These functions are noisy.
log.SetOutput(ioutil.Discard)
s := m.Run()
log.SetOutput(os.Stderr)
os.Exit(s)
}
func TestListResources(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 := listMonitoredResourceDescriptors(s, hc.ProjectID); err != nil {
log.Fatal(err)
}
if err := listMetricDescriptors(s, hc.ProjectID); err != nil {
log.Fatal(err)
}
if err := listTimeSeries(s, hc.ProjectID); err != nil {
log.Fatal(err)
}
}