diff --git a/influxclient/examples_test.go b/influxclient/examples_test.go index 00afddfc..9d440127 100644 --- a/influxclient/examples_test.go +++ b/influxclient/examples_test.go @@ -7,6 +7,7 @@ package influxclient_test import ( "context" "fmt" + "os" "github.com/influxdata/influxdb-client-go/influxclient" "github.com/influxdata/influxdb-client-go/influxclient/model" @@ -15,8 +16,8 @@ import ( func ExampleClient_newClient() { // Create a new client using an InfluxDB server base URL and an authentication token client, err := influxclient.New(influxclient.Params{ - ServerURL: "http://localhost:8086", - AuthToken: "my-token"}) + ServerURL: serverURL, + AuthToken: authToken}) _ = err _ = client @@ -28,8 +29,8 @@ func ExampleClient_newClientWithOptions() { // Create a new client using an InfluxDB server base URL and an authentication token // Create client and set batch size to 20 client, err := influxclient.New(influxclient.Params{ - ServerURL: "http://localhost:8086", - AuthToken: "my-token", + ServerURL: serverURL, + AuthToken: authToken, BatchSize: 20}) _ = err @@ -44,20 +45,20 @@ func ExampleClient_customServerAPICall() { // Create client. You need an admin token for creating DBRP mapping client, err := influxclient.New(influxclient.Params{ - ServerURL: "http://localhost:8086", - AuthToken: "my-token"}) + ServerURL: serverURL, + AuthToken: authToken}) // Get generated client for server API calls apiClient := client.APIClient() ctx := context.Background() // Get a bucket we would like to query using InfluxQL - b, err := client.BucketsAPI().FindOne(ctx, &influxclient.Filter{Name: "my-bucket"}) + b, err := client.BucketsAPI().FindOne(ctx, &influxclient.Filter{Name: bucketName}) if err != nil { panic(err) } // Get an organization that will own the mapping - o, err := client.OrganizationAPI().FindOne(ctx, &influxclient.Filter{Name: "my-org"}) + o, err := client.OrganizationAPI().FindOne(ctx, &influxclient.Filter{Name: orgName}) if err != nil { panic(err) } @@ -66,7 +67,7 @@ func ExampleClient_customServerAPICall() { // Fill required fields of the DBRP struct dbrp := model.DBRPCreate{ BucketID: *b.Id, - Database: "my-bucket", + Database: b.Name, Default: &yes, OrgID: o.Id, RetentionPolicy: "autogen", @@ -81,8 +82,8 @@ func ExampleClient_customServerAPICall() { panic(err) } - // Check generated response errors - fmt.Printf("Created DBRP: %#v\n", newDbrp) + // Check generated response + fmt.Fprintf(os.Stderr, "Created DBRP: %#v\n", newDbrp) // Output: }