File: version_tests.rb

package info (click to toggle)
ruby-fog-openstack 1.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,784 kB
  • sloc: ruby: 47,937; makefile: 5; sh: 4
file content (75 lines) | stat: -rw-r--r-- 1,700 bytes parent folder | download
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require "test_helper"

describe "OpenStack | versions, ['openstack']" do
  before do
    @old_mock_value = Excon.defaults[:mock]
    Excon.defaults[:mock] = true
    Excon.stubs.clear

    @body = {
      "versions" => [
        {
          "status" => "CURRENT",
          "id"     => "v2.0",
          "links"  => [
            {
              "href" => "http://example:9292/v2/",
              "rel"  => "self"
            }
          ]
        },
        {
          "status" => "CURRENT",
          "id"     => "v1.1",
          "links"  => [
            {
              "href" => "http://exampple:9292/v1/",
              "rel"  => "self"
            }
          ]
        },
        {
          "status" => "SUPPORTED",
          "id"     => "v1.0",
          "links"  => [
            {
              "href" => "http://example:9292/v1/",
              "rel"  => "self"
            }
          ]
        }
      ]
    }
  end

  it "supported" do
    Excon.stub({:method => 'GET'},
               {:status => 300, :body => Fog::JSON.encode(@body)})

    assert("v1.1") do
      Fog::OpenStack.get_supported_version(/v1(\.(0|1))*/,
                                           URI('http://example/'),
                                           "authtoken")
    end
  end

  it "unsupported" do
    Excon.stub(
      {:method => 'GET'},
      {:status => 300, :body => Fog::JSON.encode(@body)}
    )

    proc do
      Fog::OpenStack.get_supported_version(
        /v3(\.(0|1))*/,
        URI('http://example/'),
        "authtoken"
      )
    end.must_raise Fog::OpenStack::Errors::ServiceUnavailable
  end

  after do
    Excon.stubs.clear
    Excon.defaults[:mock] = @old_mock_value
  end
end