2019-02-05 04:28:43 +08:00
|
|
|
package kube_inventory
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
"time"
|
|
|
|
|
|
2020-06-26 02:44:22 +08:00
|
|
|
"github.com/influxdata/telegraf/plugins/common/tls"
|
2021-04-09 00:43:39 +08:00
|
|
|
"github.com/stretchr/testify/require"
|
2019-02-05 04:28:43 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type mockHandler struct {
|
|
|
|
|
responseMap map[string]interface{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func toStrPtr(s string) *string {
|
|
|
|
|
return &s
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func toInt32Ptr(i int32) *int32 {
|
|
|
|
|
return &i
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func toBoolPtr(b bool) *bool {
|
|
|
|
|
return &b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestNewClient(t *testing.T) {
|
2022-08-03 05:29:33 +08:00
|
|
|
_, err := newClient("https://127.0.0.1:443/", "default", "", "abc123", time.Second, tls.ClientConfig{})
|
2024-09-04 00:40:34 +08:00
|
|
|
require.NoErrorf(t, err, "Failed to create new client: %v", err)
|
2022-08-03 05:29:33 +08:00
|
|
|
|
|
|
|
|
_, err = newClient("https://127.0.0.1:443/", "default", "nonexistantFile", "", time.Second, tls.ClientConfig{})
|
2024-09-04 00:40:34 +08:00
|
|
|
require.Errorf(t, err, "Failed to read token file \"file\": open file: no such file or directory: %v", err)
|
2019-02-05 04:28:43 +08:00
|
|
|
}
|