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 | |
Jamie Hannaford | b134f4c | 2015-04-07 12:05:18 +0200 | [diff] [blame] | 21 | p.UserAgent.Prepend("custom-user-agent/2.4.0") |
| 22 | expected := "custom-user-agent/2.4.0 gophercloud/1.0.0" |
Jon Perritt | 2b5e3e1 | 2015-02-13 12:15:08 -0700 | [diff] [blame] | 23 | actual := p.UserAgent.Join() |
| 24 | th.CheckEquals(t, expected, actual) |
| 25 | |
Jamie Hannaford | b134f4c | 2015-04-07 12:05:18 +0200 | [diff] [blame] | 26 | p.UserAgent.Prepend("another-custom-user-agent/0.3.0", "a-third-ua/5.9.0") |
| 27 | expected = "another-custom-user-agent/0.3.0 a-third-ua/5.9.0 custom-user-agent/2.4.0 gophercloud/1.0.0" |
Jon Perritt | 2b5e3e1 | 2015-02-13 12:15:08 -0700 | [diff] [blame] | 28 | actual = p.UserAgent.Join() |
| 29 | th.CheckEquals(t, expected, actual) |
| 30 | |
| 31 | p.UserAgent = UserAgent{} |
Jamie Hannaford | b134f4c | 2015-04-07 12:05:18 +0200 | [diff] [blame] | 32 | expected = "gophercloud/1.0.0" |
Jon Perritt | 2b5e3e1 | 2015-02-13 12:15:08 -0700 | [diff] [blame] | 33 | actual = p.UserAgent.Join() |
| 34 | th.CheckEquals(t, expected, actual) |
| 35 | } |