update test to expect a default user agent
parent
f1d7b3e200
commit
6afa4fb083
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -134,8 +135,6 @@ func TestClient_UserAgent(t *testing.T) {
|
||||||
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
|
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultUserAgent := receivedUserAgent
|
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
userAgent string
|
userAgent string
|
||||||
|
@ -144,7 +143,7 @@ func TestClient_UserAgent(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Empty user agent",
|
name: "Empty user agent",
|
||||||
userAgent: "",
|
userAgent: "",
|
||||||
expected: defaultUserAgent,
|
expected: "InfluxDBClient/",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Custom user agent",
|
name: "Custom user agent",
|
||||||
|
@ -167,7 +166,7 @@ func TestClient_UserAgent(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
|
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
|
||||||
}
|
}
|
||||||
if receivedUserAgent != test.expected {
|
if !strings.HasPrefix(receivedUserAgent, test.expected) {
|
||||||
t.Fatalf("Unexpected user agent. expected %v, actual %v", test.expected, receivedUserAgent)
|
t.Fatalf("Unexpected user agent. expected %v, actual %v", test.expected, receivedUserAgent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +176,7 @@ func TestClient_UserAgent(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
|
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
|
||||||
}
|
}
|
||||||
if receivedUserAgent != test.expected {
|
if !strings.HasPrefix(receivedUserAgent, test.expected) {
|
||||||
t.Fatalf("Unexpected user agent. expected %v, actual %v", test.expected, receivedUserAgent)
|
t.Fatalf("Unexpected user agent. expected %v, actual %v", test.expected, receivedUserAgent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +185,7 @@ func TestClient_UserAgent(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
|
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
|
||||||
}
|
}
|
||||||
if receivedUserAgent != test.expected {
|
if !strings.HasPrefix(receivedUserAgent, test.expected) {
|
||||||
t.Fatalf("Unexpected user agent. expected %v, actual %v", test.expected, receivedUserAgent)
|
t.Fatalf("Unexpected user agent. expected %v, actual %v", test.expected, receivedUserAgent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue