...
1
2
3 package storageservice
4
5
6
7
8 import (
9 "encoding/xml"
10 "testing"
11 )
12
13 func Test_StorageServiceKeysResponse_Unmarshal(t *testing.T) {
14
15 response := []byte(`<?xml version="1.0" encoding="utf-8"?>
16 <StorageService xmlns="http://schemas.microsoft.com/windowsazure">
17 <Url>storage-service-url</Url>
18 <StorageServiceKeys>
19 <Primary>primary-key</Primary>
20 <Secondary>secondary-key</Secondary>
21 </StorageServiceKeys>
22 </StorageService>`)
23
24 keysResponse := GetStorageServiceKeysResponse{}
25 err := xml.Unmarshal(response, &keysResponse)
26 if err != nil {
27 t.Fatal(err)
28 }
29
30 if expected := "primary-key"; keysResponse.PrimaryKey != expected {
31 t.Fatalf("Expected %q but got %q", expected, keysResponse.PrimaryKey)
32 }
33 if expected := "secondary-key"; keysResponse.SecondaryKey != expected {
34 t.Fatalf("Expected %q but got %q", expected, keysResponse.SecondaryKey)
35 }
36 }
37
View as plain text