1// +build go1.7
2
3package storageservice
4
5// Copyright (c) Microsoft Corporation. All rights reserved.
6// Licensed under the MIT License. See License.txt in the project root for license information.
7
8import (
9	"encoding/xml"
10	"testing"
11)
12
13func Test_StorageServiceKeysResponse_Unmarshal(t *testing.T) {
14	// from https://msdn.microsoft.com/en-us/library/azure/ee460785.aspx
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