monitorying/uptime: add retries to TestCreate
@@ -19,22 +19,26 @@ import (
"io/ioutil"
"strings"
"testing"
+ "time"
"github.com/GoogleCloudPlatform/golang-samples/internal/testutil"
)
func TestCreate(t *testing.T) {
c := testutil.SystemTest(t)
+ testutil.Retry(t, 5, 5*time.Second, func(r *testutil.R) {
buf := new(bytes.Buffer)
config, err := create(buf, c.ProjectID)
if err != nil {
- t.Fatalf("create: %v", err)
+ r.Errorf("create: %v", err)
+ return
}
want := "Successfully"
if got := buf.String(); !strings.Contains(got, want) {
- t.Errorf("%q not found in output: %q", want, got)
+ r.Errorf("%q not found in output: %q", want, got)
}
delete(ioutil.Discard, config.GetName())
+ })
}
func TestList(t *testing.T) {
