Sha256: 164973c90da4eaaae23041c2a69ddf55dd0167f2ea6cd8d0d9e80f3526b93f85

Contents?: true

Size: 1.89 KB

Versions: 1

Compression:

Stored size: 1.89 KB

Contents

require 'spec_helper'

describe Vcloud::DiskLauncher do

  context "DiskLaunch schema validation" do

    it "validates a legal minimal schema" do
      test_config = {
        :independent_disks => [
          :name     =>  "Valid disk name",
          :vdc_name =>  "Some vDC",
          :size     =>  "10GB"
        ]
      }
      validator = Vcloud::Core::ConfigValidator.validate(:base, test_config, Vcloud::DiskLauncher::Schema::DISK_LAUNCH)
      expect(validator.valid?).to be_true
      expect(validator.errors).to be_empty
    end

    it "validates a multiple disks" do
      test_config = {
        :independent_disks => [
          {
            :name     =>  "Valid disk 1",
            :vdc_name =>  "Some vDC",
            :size     =>  "10GB"
          },
          {
            :name     =>  "Valid disk 2",
            :vdc_name =>  "Another vDC",
            :size     =>  "500MB"
          },
        ]
      }
      validator = Vcloud::Core::ConfigValidator.validate(:base, test_config, Vcloud::DiskLauncher::Schema::DISK_LAUNCH)
      expect(validator.valid?).to be_true
      expect(validator.errors).to be_empty
    end

    it "validates an empty disk list" do
      test_config = {
        :independent_disks => []
      }
      validator = Vcloud::Core::ConfigValidator.validate(:base, test_config, Vcloud::DiskLauncher::Schema::DISK_LAUNCH)
      expect(validator.valid?).to be_true
      expect(validator.errors).to be_empty
    end

    it "does not validate an illegal schema" do
      test_config = {
        :no_disks_here => {
          :name => "I am not valid"
        }
      }
      validator = Vcloud::Core::ConfigValidator.validate(:base, test_config, Vcloud::DiskLauncher::Schema::DISK_LAUNCH)
      expect(validator.valid?).to be_false
      expect(validator.errors).to eq(["base: parameter 'no_disks_here' is invalid", "base: missing 'independent_disks' parameter"])
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vcloud-disk_launcher-0.1.0 spec/vcloud/disk_launcher/disk_launch_schema_spec.rb