NAME
Test::Clustericious::Config - Test Clustericious::Config
SYNOPSIS
use Test::Clustericious::Config;
use Clustericious::Config;
use Test::More tets => 2;
create_config_ok 'Foo', { url => 'http://localhost:1234' };
my $config = Clustericious::Config->new('Foo');
is $config->url, "http://localhost:1234";
To test against a Clustericious application MyApp:
use Test::Clustericious::Config;
use Test::Clustericious;
use Test::More tests => 3;
create_config_ok 'MyApp', { x => 1, y => 2 };
my $t = Test::Clustericious->new('MyApp');
$t->get_ok('/');
is $t->app->config->x, 1;
DESCRIPTION
This module provides an interface for testing Clustericious configurations, or Clustericious applications which use a Clustericious configuration.
It uses File::HomeDir::Test to isolate your test environment from any configurations you may have in your ~/etc
. Keep in mind that this means that $HOME
and friends will be in a temporary directory and removed after the test runs. It also means that the caveats for File::HomeDir::Test apply when using this module as well (ie. this should be the first module that you use in your test after use strict
and use warnings
).
FUNCTIONS
create_config_ok $name, $config, [$test_name]
Create a Clustericious config with the given $name
. If $config
is a reference then it will create the configuration file with YAML::XS::DumpFile
, if it is a scalar, it will will write the scalar out to the config file. Thus these three examples should create a config with the same values (though in different formats):
hash reference:
create_config_ok 'Foo', { url => 'http://localhost:1234' }];
YAML:
create_config_ok 'Foo', <<EOF;
---
url: http://localhost:1234
EOF
JSON:
create_config_ok 'Foo', <<EOF;
{"url":"http://localhost:1234"}
EOF
In addition to being a test that will produce a ok/not ok result as output, this function will return the full path to the configuration file created.
create_directory_ok $path, [$test_name]
Creates a directory in your test environment home directory. This directory will be recursively removed when your test terminates. This function returns the full path of the directory created.
home_directory_ok [$test_name]
Tests that the temp homedirectory has been created okay. Returns the full path of the home directory.
AUTHOR
Graham Ollis <gollis@sesda3.com>