-
Notifications
You must be signed in to change notification settings - Fork 4
/
telemetry_test.go
53 lines (49 loc) · 1.38 KB
/
telemetry_test.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package notificationhubs
import (
"net/http"
"reflect"
"testing"
)
var tests = []struct {
name string
url string
want *NotificationTelemetry
}{
{
name: "Simple test",
url: "https://test-ns.servicebus.windows.net/testhub/messages/ABCDEFGH?api-version=2015-04",
want: &NotificationTelemetry{
NotificationMessageID: "ABCDEFGH",
},
},
{
name: "More advanced test",
url: "https://messages.servicebus.windows.net/messagebus/messages/3288835312934927344-986564390439048203-1?api-version=2016-10",
want: &NotificationTelemetry{
NotificationMessageID: "3288835312934927344-986564390439048203-1",
},
},
}
func TestNewNotificationTelemetryFromLocationURL(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewNotificationTelemetryFromLocationURL(tt.url); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewNotificationTelemetryFromLocationURL() = %s, want %s", got, tt.want)
}
})
}
}
func TestNewNotificationTelemetryFromHTTPResponse(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
header := http.Header{}
header.Add("Location", tt.url)
response := &http.Response{
Header: header,
}
if got, _ := NewNotificationTelemetryFromHTTPResponse(response); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewNotificationTelemetryFromHTTPResponse() = %v, want %v", got, tt.want)
}
})
}
}