Debian Codegraph @

v1/usage_test.go

raw
1 package client_test
2
3 import (
4 "fmt"
5 "io/ioutil"
6 "testing"
7
8 "github.com/influxdb/enterprise-client/v1"
9 "github.com/stretchr/testify/require"
10 )
11
12 func Test_Usage_Path(t *testing.T) {
13 r := require.New(t)
14 u := client.Usage{Product: "influxdb"}
15 r.Equal("/usage/influxdb", u.Path())
16 }
17
18 // Example of saving Usage data to Enterprise
19 func Example_saveUsage() {
20 c := client.New("token-goes-here")
21 // override the URL for testing
22 c.URL = "https://enterprise.staging.influxdata.com"
23
24 u := client.Usage{
25 Product: "influxdb",
26 Data: []client.UsageData{
27 {
28 Tags: client.Tags{
29 "version": "0.9.5",
30 "arch": "amd64",
31 "os": "linux",
32 },
33 Values: client.Values{
34 "cluster_id": "23423",
35 "server_id": "1",
36 "num_databases": 3,
37 "num_measurements": 2342,
38 "num_series": 87232,
39 },
40 },
41 },
42 }
43
44 res, err := c.Save(u)
45 fmt.Printf("err: %s\n", err)
46 b, _ := ioutil.ReadAll(res.Body)
47 fmt.Printf("b: %s\n", b)
48 }