1#!/usr/bin/perl 2use warnings; 3use strict; 4use Prophet::Test tests => 13; 5use File::Temp 'tempdir'; 6use File::Spec; 7 8my ( $bug_uuid, $pullall_uuid ); 9 10my $alice_published = tempdir( CLEANUP => !$ENV{PROPHET_DEBUG} ); 11 12as_alice { 13 ok( run_command(qw(init)), 'replica init' ); 14 my $out = run_command( 15 qw(create --type Bug -- --status new --from alice --summary), 16 'this is a template test', 17 ); 18 my $expected = qr/Created Bug \d+ \((\S+)\)(?{ $bug_uuid = $1 })/; 19 like( $out, $expected, 'Created a Bug record as alice' ); 20 21 ok( $bug_uuid, "got a uuid for the Bug record" ); 22 23 $out = run_command(qw(search --type Bug --regex .)); 24 $expected = qr/new/; 25 like( $out, $expected, 'Found our record' ); 26 27 ok( 28 run_command( qw(publish --html --to), $alice_published ), 29 'alice publish html', 30 ); 31}; 32 33my $dir = $alice_published; 34 35my $merge_tickets = 36 File::Spec->catdir( $dir => $Prophet::Replica::MERGETICKET_METATYPE ); 37ok( !-e $merge_tickets, "_merge_tickets template directory absent" ); 38 39my $bug = File::Spec->catdir( $dir => 'Bug' ); 40ok( -e $bug, "Bug template directory exists" ); 41 42my $index = Prophet::Util->catfile( $bug => 'index.html' ); 43ok( -e $index, "Bug/index.html exists" ); 44 45my $bug_template = Prophet::Util->catfile( $bug => "$bug_uuid.html" ); 46ok( -e $bug_template, "Bug/$bug_uuid.html exists" ); 47 48my $index_contents = Prophet::Util->slurp($index); 49like( $index_contents, qr/$bug_uuid/, "index contains bug uuid" ); 50like( 51 $index_contents, 52 qr/this is a template test/, 53 "index contains bug summary" 54); 55 56my $bug_contents = Prophet::Util->slurp($bug_template); 57like( $bug_contents, qr/$bug_uuid/, "bug contains bug uuid" ); 58like( $bug_contents, qr/this is a template test/, "bug contains bug summary" ); 59 60