File: server_test.go

package info (click to toggle)
golang-github-influxdb-usage-client 0.0~git20151204.0.475977e-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 152 kB
  • sloc: makefile: 2
file content (35 lines) | stat: -rw-r--r-- 726 bytes parent folder | download | duplicates (4)
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
package client_test

import (
	"fmt"
	"io/ioutil"
	"testing"

	"github.com/influxdata/usage-client/v1"
	"github.com/stretchr/testify/require"
)

func Test_Server_Implements_Saveable(t *testing.T) {
	r := require.New(t)
	r.Implements((*client.Saveable)(nil), client.Server{})
}

// Example of saving a server to the Usage API
func Example_saveServer() {
	c := client.New("token-goes-here")
	// override the URL for testing
	c.URL = "https://usage.staging.influxdata.com"

	s := client.Server{
		ClusterID: "clus1",
		Host:      "example.com",
		Product:   "jambox",
		Version:   "1.0",
		ServerID:  "serv1",
	}

	res, err := c.Save(s)
	fmt.Printf("err: %s\n", err)
	b, _ := ioutil.ReadAll(res.Body)
	fmt.Printf("b: %s\n", b)
}