Conch API

Logo

Datacenter build and management service

View the Project on GitHub joyent/conch-api

NAME

Test::Conch::Validation - Test Conch Validations

METHODS

test_validation

A function to test a Conch Validation using a collection of provided test cases.

This function performs the following tests:

The required arguments are the Conch Validation module as a string, keyword arguments specifying optional models available to the Validation, and a keyword argument specifying the cases for the test to use.

The available models are hardware_product, device_location, device_settings, and device. Their attributes are defined with a hashref, which will be constructed to the correct classes in the body of “test_validation”. For example:

test_validation(
    'Conch::Validation::TestValidation',
    hardware_product => {
        name => 'Product Name',
        vendor => 'Product Vendor',
        hardware_product_profile => {
            num_cpu => 2
        }
    },
    device_location => {
        rack_unit       => 2,
        rack => {
            rack_layouts => [
                { rack_unit_start => 1 },
                { rack_unit_start => 2 },
                { rack_unit_start => 3 },
            ],
        },
    },
    device_settings => {
        foo => 'bar'
    },
    device => {
        triton_setup => 1,
    },

    cases => [ ... ]
);

cases is a list of hashrefs defining each of the test cases. Each case specifies the input data and attributes representing the expected results. Each test case may raise an error (die) or may produce 0 or more validation results. A test case is specified with a hashref with the attributes:

Example:

test_validation(
    'Conch::Validation::TestValidation',
    cases => [
        {
            data        => { hello => 'world' },
            success_num => 3,
            failure_num => 3,
            description => 'Hello world test case',
            debug       => 1
        }
    ]
);

LICENSING

Copyright Joyent, Inc.

This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.