Tests: restructure to more closely mirror the sources
t/ had lots of directories and files mirroring src/lib/Hydra. This moves those files under t/Hydra
This commit is contained in:
88
t/Hydra/Config/hydra-notify.t
Normal file
88
t/Hydra/Config/hydra-notify.t
Normal file
@ -0,0 +1,88 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Setup;
|
||||
|
||||
my %ctx = test_init(hydra_config => q|
|
||||
<hydra_notify>
|
||||
<prometheus>
|
||||
listen_address = 127.0.0.1
|
||||
port = 9199
|
||||
</prometheus>
|
||||
</hydra_notify>
|
||||
|);
|
||||
|
||||
require Hydra::Helper::Nix;
|
||||
use Test2::V0;
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraNotifyPrometheusConfig(Hydra::Helper::Nix::getHydraConfig()), {
|
||||
'listen_address' => "127.0.0.1",
|
||||
'port' => 9199
|
||||
}, "Reading specific configuration from the hydra.conf works");
|
||||
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraNotifyPrometheusConfig({
|
||||
"hydra_notify" => ":)"
|
||||
}), undef, "Invalid (hydra_notify is a string) configuration options are undef");
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraNotifyPrometheusConfig({
|
||||
"hydra_notify" => []
|
||||
}), undef, "Invalid (hydra_notify is a list) configuration options are undef");
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraNotifyPrometheusConfig({
|
||||
"hydra_notify" => {}
|
||||
}), undef, "Invalid (hydra_notify is an empty hash) configuration options are undef");
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraNotifyPrometheusConfig({
|
||||
"hydra_notify" => {
|
||||
"prometheus" => ":)"
|
||||
}
|
||||
}), undef, "Invalid (hydra_notify.prometheus is a string) configuration options are undef");
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraNotifyPrometheusConfig({
|
||||
"hydra_notify" => {
|
||||
"prometheus" => {}
|
||||
}
|
||||
}), undef, "Invalid (hydra_notify.prometheus is an empty hash) configuration options are undef");
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraNotifyPrometheusConfig({
|
||||
"hydra_notify" => {
|
||||
"prometheus" => {
|
||||
"listen_address" => "0.0.0.0"
|
||||
}
|
||||
}
|
||||
}), undef, "Invalid (hydra_notify.prometheus.port is missing) configuration options are undef");
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraNotifyPrometheusConfig({
|
||||
"hydra_notify" => {
|
||||
"prometheus" => {
|
||||
"port" => 1234
|
||||
}
|
||||
}
|
||||
}), undef, "Invalid (hydra_notify.prometheus.listen_address is missing) configuration options are undef");
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraNotifyPrometheusConfig({
|
||||
"hydra_notify" => {
|
||||
"prometheus" => {
|
||||
"listen_address" => "127.0.0.1",
|
||||
"port" => 1234
|
||||
}
|
||||
}
|
||||
}), {
|
||||
"listen_address" => "127.0.0.1",
|
||||
"port" => 1234
|
||||
}, "Fully specified hydra_notify.prometheus config is valid and returned");
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraNotifyPrometheusConfig({
|
||||
"hydra_notify" => {
|
||||
"prometheus" => {
|
||||
"listen_address" => "127.0.0.1",
|
||||
"port" => 1234,
|
||||
"extra_keys" => "meh",
|
||||
}
|
||||
}
|
||||
}), {
|
||||
"listen_address" => "127.0.0.1",
|
||||
"port" => 1234
|
||||
}, "extra configuration in hydra_notify.prometheus is not returned");
|
||||
|
||||
done_testing;
|
27
t/Hydra/Config/include.t
Normal file
27
t/Hydra/Config/include.t
Normal file
@ -0,0 +1,27 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Setup;
|
||||
|
||||
my %ctx = test_init(
|
||||
use_external_destination_store => 0,
|
||||
hydra_config => "include foo.conf"
|
||||
);
|
||||
|
||||
write_file($ctx{'tmpdir'} . "/foo.conf", q|
|
||||
<foo>
|
||||
include bar.conf
|
||||
</foo>
|
||||
|);
|
||||
|
||||
write_file($ctx{'tmpdir'} . "/bar.conf", q|
|
||||
bar = baz
|
||||
|);
|
||||
|
||||
require Hydra::Helper::Nix;
|
||||
use Test2::V0;
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraConfig(), {
|
||||
foo => { bar => "baz" }
|
||||
}, "Nested includes work.");
|
||||
|
||||
done_testing;
|
62
t/Hydra/Config/statsd.t
Normal file
62
t/Hydra/Config/statsd.t
Normal file
@ -0,0 +1,62 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Setup;
|
||||
|
||||
my %ctx = test_init(hydra_config => q|
|
||||
<statsd>
|
||||
host = foo.bar
|
||||
port = 18125
|
||||
</statsd>
|
||||
|);
|
||||
|
||||
require Hydra::Helper::Nix;
|
||||
use Test2::V0;
|
||||
|
||||
is(Hydra::Helper::Nix::getStatsdConfig(Hydra::Helper::Nix::getHydraConfig()), {
|
||||
'host' => "foo.bar",
|
||||
'port' => 18125
|
||||
}, "Reading specific configuration from the hydra.conf works");
|
||||
|
||||
is(Hydra::Helper::Nix::getStatsdConfig(), {
|
||||
'host' => "localhost",
|
||||
'port' => 8125
|
||||
}, "A totally empty configuration yields default options");
|
||||
|
||||
is(Hydra::Helper::Nix::getStatsdConfig({
|
||||
"statsd" => {
|
||||
|
||||
}
|
||||
}), {
|
||||
'host' => "localhost",
|
||||
'port' => 8125
|
||||
}, "A empty statsd block yields default options");
|
||||
|
||||
is(Hydra::Helper::Nix::getStatsdConfig({
|
||||
"statsd" => {
|
||||
'host' => "statsdhost"
|
||||
}
|
||||
}), {
|
||||
'host' => "statsdhost",
|
||||
'port' => 8125
|
||||
}, "An overridden statsd host propogates, but the other defaults are returned");
|
||||
|
||||
is(Hydra::Helper::Nix::getStatsdConfig({
|
||||
"statsd" => {
|
||||
'port' => 5218
|
||||
}
|
||||
}), {
|
||||
'host' => "localhost",
|
||||
'port' => 5218
|
||||
}, "An overridden statsd port propogates, but the other defaults are returned");
|
||||
|
||||
is(Hydra::Helper::Nix::getStatsdConfig({
|
||||
"statsd" => {
|
||||
'host' => 'my.statsd.host',
|
||||
'port' => 5218
|
||||
}
|
||||
}), {
|
||||
'host' => "my.statsd.host",
|
||||
'port' => 5218
|
||||
}, "An overridden statsd port and host propogate");
|
||||
|
||||
done_testing;
|
Reference in New Issue
Block a user