Changeset 4238 for lang/perl/Config-Pit

Show
Ignore:
Timestamp:
01/09/08 01:25:44 (7 years ago)
Author:
cho45
Message:

lang/perl/Config-Pit/trunk/t/01_basic.t:

Append tests about $EDITOR

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Config-Pit/trunk/t/01_basic.t

    r4228 r4238  
    22use warnings; 
    33 
    4 use Test::More tests => 8; 
     4use Test::More tests => 11; 
    55use File::Temp; 
    66use Path::Class; 
     7use YAML::Syck; 
    78 
    89use Config::Pit; 
     
    3536is($config->{bar}, "baz", "get returned value (exported sub)"); 
    3637 
    37 #my $config = Config::Pit::get("test", require => { 
    38 #       "foo" => "foo test", 
    39 #       "bar" => "bar test" 
    40 #}); 
    41 #p $config; 
    42 # TODO 
     38 
     39# EDITOR 
     40# 
     41Config::Pit::set("test", data => {}); 
     42$ENV{EDITOR} = ""; 
     43Config::Pit::set("test"); 
     44is(ref($config), "HASH", "set with unset EDITOR"); 
     45 
     46sub temppath { 
     47        return file(File::Temp->new()->filename) 
     48} 
     49 
     50my $exe = temppath(); 
     51my $tst = temppath(); 
     52 
     53my $fh = $exe->open("w", 0700) or die "open failed."; 
     54print $fh <<'EOF'; 
     55#!/usr/bin/env perl 
     56use strict; 
     57 
     58my $a =  do { local $/; <ARGV> }; 
     59 
     60my $tst = $ENV{TEST_FILE}; 
     61open my $fh, ">$tst"; 
     62print $fh $a; 
     63close $fh; 
     64EOF 
     65undef $fh; 
     66chmod 0700, $exe; 
     67 
     68$ENV{EDITOR}    = $exe; 
     69$ENV{TEST_FILE} = $tst; 
     70#system $exe, "Changes"; 
     71#p $tst->slurp; 
     72 
     73my $data = { 
     74        foo => "0101", 
     75        bar => "0202", 
     76}; 
     77 
     78Config::Pit::set("test", data => $data); 
     79Config::Pit::set("test"); 
     80 
     81my $result = LoadFile($tst); 
     82 
     83is($result->{foo}, $data->{foo}, "editor test"); 
     84is($result->{bar}, $data->{bar}, "editor test"); 
     85 
     86 
     87