-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63151b4
commit ee179b4
Showing
4 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ t/admin2.t | |
t/bin.t | ||
t/cities.t | ||
t/comment-spelling.t | ||
t/config.t | ||
t/critic.t | ||
t/dr5hn.t | ||
t/eof.t | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::Most tests => 4; | ||
use File::Temp; | ||
use File::Spec; | ||
|
||
BEGIN { | ||
use_ok('Geo::Coder::Free::Config'); | ||
$ENV{'HOME'} = File::Temp::tempdir(CLEANUP => 1); | ||
} | ||
|
||
# Test for creating a new object | ||
subtest 'Object creation' => sub { | ||
my $config_obj; | ||
|
||
# Check it does not die | ||
lives_ok( | ||
sub { | ||
$config_obj = Geo::Coder::Free::Config->new(); | ||
}, | ||
'Geo::Coder::Free::Config object created without errors' | ||
); | ||
|
||
isa_ok($config_obj, 'Geo::Coder::Free::Config', 'Correct object type'); | ||
}; | ||
|
||
# Test AUTOLOAD functionality | ||
subtest 'AUTOLOAD method' => sub { | ||
my $config_obj = Geo::Coder::Free::Config->new(config => { test_key => 'test_value' }); | ||
|
||
is($config_obj->test_key(), 'test_value', 'AUTOLOAD correctly retrieves a key-value pair'); | ||
|
||
is($config_obj->nonexistent_key(), undef, 'AUTOLOAD returns undef for non-existent keys'); | ||
}; | ||
|
||
# Test config file and environment variable overrides | ||
subtest 'Configuration overrides' => sub { | ||
my $custom_config = { | ||
test_key => 'default_value', | ||
override_key => 'default_override', | ||
}; | ||
|
||
local $ENV{'override_key'} = 'env_override_value'; | ||
|
||
my $config_obj = Geo::Coder::Free::Config->new(config => $custom_config); | ||
|
||
is($config_obj->{test_key}, 'default_value', 'Default configuration loaded correctly'); | ||
|
||
is($config_obj->{override_key}, 'env_override_value', 'Environment variable overrides configuration value'); | ||
}; |