Sha256: eaad272ed1b1297879d4517b08bdce77b05c2d73dbef14ddeefcc6c3a41f5593

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

class TestVolume < TestYaoResource
  def test_volume
    params = {
        'name' => 'cinder',
        'size' => 10
    }

    volume = Yao::Volume.new(params)
    assert_equal('cinder', volume.name)
    assert_equal(10, volume.size)
  end

  def test_list
    # https://docs.openstack.org/api-ref/block-storage/v3/index.html?expanded=#volumes-volumes
    stub = stub_request(:get, "https://example.com:12345/volumes/detail").
      to_return(
        status: 200,
        body: <<-JSON,
        {
            "volumes": [
                {
                    "id": "00000000-0000-0000-0000-000000000000"
                }
            ]
        }
        JSON
        headers: {'Content-Type' => 'application/json'}
      )

    assert(Yao::Volume.resources_detail_available)

    volumes = Yao::Volume.list
    assert_instance_of(Yao::Volume, volumes.first)
    assert_equal(volumes.first.id, "00000000-0000-0000-0000-000000000000")

    assert_requested(stub)
  end

  def test_list_detail
    assert_equal(Yao::Volume.method(:list_detail), Yao::Volume.method(:list))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yao-0.8.0 test/yao/resources/test_volume.rb