Jon Perritt | 3ec6cfd | 2014-10-06 16:49:48 -0500 | [diff] [blame] | 1 | package gophercloud |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | th "github.com/rackspace/gophercloud/testhelper" |
| 7 | ) |
| 8 | |
| 9 | func TestAuthenticatedHeaders(t *testing.T) { |
| 10 | p := &ProviderClient{ |
| 11 | TokenID: "1234", |
| 12 | } |
| 13 | expected := map[string]string{"X-Auth-Token": "1234"} |
| 14 | actual := p.AuthenticatedHeaders() |
| 15 | th.CheckDeepEquals(t, expected, actual) |
| 16 | } |
Jon Perritt | 2b5e3e1 | 2015-02-13 12:15:08 -0700 | [diff] [blame] | 17 | |
| 18 | func TestUserAgent(t *testing.T) { |
| 19 | p := &ProviderClient{} |
| 20 | |
| 21 | p.UserAgent.Prepend("custom-user-agent/v2.4") |
| 22 | expected := "custom-user-agent/v2.4 gophercloud/v1.0" |
| 23 | actual := p.UserAgent.Join() |
| 24 | th.CheckEquals(t, expected, actual) |
| 25 | |
| 26 | p.UserAgent.Prepend("another-custom-user-agent/v0.3", "a-third-ua/v5.9") |
| 27 | expected = "another-custom-user-agent/v0.3 a-third-ua/v5.9 custom-user-agent/v2.4 gophercloud/v1.0" |
| 28 | actual = p.UserAgent.Join() |
| 29 | th.CheckEquals(t, expected, actual) |
| 30 | |
| 31 | p.UserAgent = UserAgent{} |
| 32 | expected = "gophercloud/v1.0" |
| 33 | actual = p.UserAgent.Join() |
| 34 | th.CheckEquals(t, expected, actual) |
| 35 | } |