mostly fix "not" stuff
[scpubgit/DKit.git] / t / dot_ssh.t
index 1ac8b04..6557838 100644 (file)
@@ -65,9 +65,8 @@ $solver->add_rule(@$_) for (
   [ path => [ qw(PS P) ],
     [ prop => 'PS', \'path', 'P' ] ],
   [ info_prop => [ qw(PS N V) ],
-    [ exists => [ qw(PSI) ],
-      [ prop => 'PS', \'info', 'PSI' ],
-      [ prop => 'PSI', 'N', 'V' ] ] ],
+    [ prop => 'PS', \'info', 'PSI' ],
+    [ prop => 'PSI', 'N', 'V' ] ],
   [ mode => [ qw(PS M) ],
     [ info_prop => 'PS', \'mode', 'M' ] ],
   [ exists_path => [ qw(PS) ],
@@ -83,8 +82,8 @@ $solver->add_rule(@$_) for (
 %path_status = %protos;
 
 sub paths_for_simple {
-  join ' ', map $_->value_for('PS')->path, $solver->query(
-    [ qw(PS) ], [ path_status => 'PS' ], @_
+  join ' ', map $_->value_for('PS')->path, $solver->solve(
+    [ path_status => 'PS' ], @_
   )->results;
 }
 
@@ -94,7 +93,7 @@ is(paths_for_simple([ is_directory => 'PS' ]), '.ssh');
 
 is(paths_for_simple([ is_file => 'PS' ]), '.ssh/authorized_keys');
 
-is(paths_for_simple([ mode => 'PS', [ value => '0755' ] ]), '.ssh');
+is(paths_for_simple([ mode => 'PS', \'0755' ]), '.ssh');
 
 $solver->add_rule(
   path_status_at => [ 'PS', 'P' ],
@@ -107,9 +106,8 @@ $solver->add_rule(
 );
 
 throws_ok {
-  $solver->query(
-    [ qw(PS) ],
-      [ path_status_at => 'PS', [ value => '.ssh' ] ]
+  $solver->solve(
+    [ path_status_at => 'PS', \'.ssh' ]
   )->results
 } qr/ARGH/;
 
@@ -129,9 +127,8 @@ $solver->add_rule(
 my @res;
 
 lives_ok {
-  @res = $solver->query(
-    [ qw(PS) ],
-      [ path_status_at => 'PS', [ value => '.ssh' ] ]
+  @res = $solver->solve(
+    [ path_status_at => 'PS', \'.ssh' ]
   )->results
 };
 
@@ -167,22 +164,22 @@ $solver->add_rule(
 $ob_res{'.ssh'} = $protos{'.ssh'};
 
 sub paths_for {
-  join ' ', map $_->value_for('PS')->path, $solver->query([ 'PS' ], @_)->results;
+  join ' ', map $_->value_for('PS')->path, $solver->solve(@_)->results;
 }
 
 is(
-  paths_for([ path_status => 'PS' ], [ path => 'PS', [ value => '.ssh' ] ]),
+  paths_for([ path_status => 'PS' ], [ path => 'PS', \'.ssh' ]),
   '',
   'no .ssh entry'
 );
 
-throws_ok { paths_for([ path_status_at => 'PS', [ value => '.ssh' ] ]) }
+throws_ok { paths_for([ path_status_at => 'PS', \'.ssh' ]) }
   qr/refused/;
 
 $solver->{observation_policy} = sub { 1 };
 
 is(
-  paths_for([ path_status_at => 'PS', [ value => '.ssh' ] ]),
+  paths_for([ path_status_at => 'PS', \'.ssh' ]),
   '.ssh',
   'observation'
 );
@@ -191,13 +188,13 @@ is($path_status{'.ssh'}, $ob_res{'.ssh'});
 
 delete $solver->{observation_policy};
 
-lives_ok { paths_for([ path_status_at => 'PS', [ value => '.ssh' ] ]) }
+lives_ok { paths_for([ path_status_at => 'PS', \'.ssh' ]) }
   'No observation required anymore';
 
 $path_status{'.ssh/authorized_keys'} = $protos{'.ssh/authorized_keys'};
 
 is(
-  paths_for([ path_status => 'PS' ], [ not => [ is_directory => 'PS' ] ]),
+  paths_for([ path_status => 'PS' ], [ not => [ [ is_directory => 'PS' ] ] ]),
   '.ssh/authorized_keys',
   'Negation'
 );
@@ -220,7 +217,7 @@ $ob_res{'.ssh'} = $empty{'.ssh'};
 $solver->{observation_policy} = sub { 1 };
 
 sub dot_ssh_query {
-  $solver->query([ 'PS' ], [ directory_at => 'PS' => [ value => '.ssh' ] ]);
+  $solver->solve([ directory_at => 'PS' => \'.ssh' ]);
 }
 
 is_deeply(
@@ -228,11 +225,11 @@ is_deeply(
   []
 );
 
-#::Dwarn(paths_for([ directory_at => 'PS', [ value => '.ssh' ] ]));
+#::Dwarn(paths_for([ directory_at => 'PS', \'.ssh' ]));
 
 $solver->add_rule(@$_) for (
   [ is_directory => [ qw(PS) ],
-    [ not => [ exists_path => 'PS' ] ],
+    [ not => [ [ exists_path => 'PS' ] ] ],
     [ act => [ 'PS' ],
         sub {
           my ($value) = @_;
@@ -287,13 +284,11 @@ $solver->add_predicate(
 $solver->add_rule(@$_) for (
   [ file_in => [ qw(DirStatus FileName FileStatus) ],
     [ is_directory => qw(DirStatus) ],
-    [ exists => [ qw(DirPath) ],
-      [ path => qw(DirStatus DirPath) ],
-      [ exists => [ qw(FilePath) ],
-        [ catfile => qw(DirPath FileName FilePath) ],
-        [ file_at => qw(FileStatus FilePath) ] ] ] ],
+    [ path => qw(DirStatus DirPath) ],
+    [ catfile => qw(DirPath FileName FilePath) ],
+    [ file_at => qw(FileStatus FilePath) ] ],
   [ is_file => [ qw(PS) ],
-    [ not => [ exists_path => 'PS' ] ],
+    [ not => [ [ exists_path => 'PS' ] ] ],
     [ act => [ 'PS' ],
         sub {
           my ($value) = @_;
@@ -318,7 +313,7 @@ $solver->add_rule(@$_) for (
 %ob_res = %empty;
 
 sub keys_file {
-  $solver->query([ qw(D F) ],
+  $solver->solve(
      [ directory_at => 'D' => \'.ssh' ],
      [ file_in => 'D' => \'authorized_keys' => 'F' ],
    );