Debian Codegraph @

v1/registration_test.go

raw
1 package client_test
2
3 import (
4 "fmt"
5 "testing"
6
7 "github.com/influxdb/enterprise-client/v1"
8 "github.com/stretchr/testify/require"
9 )
10
11 func Test_Client_RegistrationURL(t *testing.T) {
12 r := require.New(t)
13 c := client.New("foo")
14 u, _ := c.RegistrationURL(client.Registration{
15 ClusterID: "clus1",
16 Product: "chronograf",
17 RedirectURL: "http://example.com",
18 })
19 r.Equal("https://enterprise.influxdata.com/start?cluster_id=clus1&product=chronograf&redirect_url=http%3A%2F%2Fexample.com", u)
20 }
21
22 func Test_Registration_IsValid(t *testing.T) {
23 r := require.New(t)
24 reg := client.Registration{}
25 err := reg.IsValid()
26 r.Error(err)
27
28 reg.ClusterID = "clus1"
29 err = reg.IsValid()
30 r.Error(err)
31
32 reg.ClusterID = ""
33 reg.Product = "foo"
34 err = reg.IsValid()
35 r.Error(err)
36
37 reg.ClusterID = "clus1"
38 reg.Product = "foo"
39 err = reg.IsValid()
40 r.NoError(err)
41 }
42
43 // Example of getting a registration URL for a product
44 func Example_registrationURL() {
45 c := client.New("")
46 r := client.Registration{
47 ClusterID: "clus1",
48 Product: "chronograf",
49 RedirectURL: "http://example.com",
50 }
51
52 s, _ := c.RegistrationURL(r)
53 fmt.Printf("s: %s\n", s)
54 // https://enterprise.influxdata.com/start?cluster_id=clus1&product=chronograf&redirect_url=http%3A%2F%2Fexample.com
55 }