From 77b0c36408113a9719397f5acbbd73a5f431e7d6 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 22 May 2011 20:08:18 -0700 Subject: Rename trigger script --- scripts/post_to_hook.pl | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ scripts/trigger_hook | 56 ------------------------------------------------- 2 files changed, 56 insertions(+), 56 deletions(-) create mode 100644 scripts/post_to_hook.pl delete mode 100644 scripts/trigger_hook (limited to 'scripts') diff --git a/scripts/post_to_hook.pl b/scripts/post_to_hook.pl new file mode 100644 index 0000000..2e2f717 --- /dev/null +++ b/scripts/post_to_hook.pl @@ -0,0 +1,56 @@ +use strict; +use warnings; + +use jitterbug; +use jitterbug::Schema; + +use JSON; +use YAML qw/LoadFile Dump/; + +use File::Temp qw/tempdir/; + +use Dancer::Test; +use Dancer::Config qw/setting/; +use File::Spec::Functions; + +my $content = LoadFile(catfile(qw/t data hook_data.yml/)); +my $db_file = catfile( qw/t data jitterbug.db/ ); +my $dsn = 'dbi:SQLite:dbname=' . $db_file; +my $schema = jitterbug::Schema->connect($dsn); +# assume we have a deployed schema +# $schema->deploy; + +setting plugins => { + DBIC => { + schema => { + skip_automake => 1, + pckg => "jitterbug::Schema", + connect_info => [$dsn] + } + } +}; + +{ + my $response = dancer_response( + POST => '/hook/', + { + headers => + [ 'Content-Type' => 'application/x-www-form-urlencoded' ], + body => _generate_post_request($content), + } + ); + + printf "Response was: %s\n", $response->{status}; +} + +sub _generate_post_request { + my $content = shift; + my $payload = "payload=" . JSON::encode_json($content); + open my $in, '<', \$payload; + + $ENV{'CONTENT_LENGTH'} = length($payload); + $ENV{'CONTENT_TYPE'} = 'application/x-www-form-urlencoded'; + $ENV{'psgi.input'} = $in; + return $payload; +} + diff --git a/scripts/trigger_hook b/scripts/trigger_hook deleted file mode 100644 index 2e2f717..0000000 --- a/scripts/trigger_hook +++ /dev/null @@ -1,56 +0,0 @@ -use strict; -use warnings; - -use jitterbug; -use jitterbug::Schema; - -use JSON; -use YAML qw/LoadFile Dump/; - -use File::Temp qw/tempdir/; - -use Dancer::Test; -use Dancer::Config qw/setting/; -use File::Spec::Functions; - -my $content = LoadFile(catfile(qw/t data hook_data.yml/)); -my $db_file = catfile( qw/t data jitterbug.db/ ); -my $dsn = 'dbi:SQLite:dbname=' . $db_file; -my $schema = jitterbug::Schema->connect($dsn); -# assume we have a deployed schema -# $schema->deploy; - -setting plugins => { - DBIC => { - schema => { - skip_automake => 1, - pckg => "jitterbug::Schema", - connect_info => [$dsn] - } - } -}; - -{ - my $response = dancer_response( - POST => '/hook/', - { - headers => - [ 'Content-Type' => 'application/x-www-form-urlencoded' ], - body => _generate_post_request($content), - } - ); - - printf "Response was: %s\n", $response->{status}; -} - -sub _generate_post_request { - my $content = shift; - my $payload = "payload=" . JSON::encode_json($content); - open my $in, '<', \$payload; - - $ENV{'CONTENT_LENGTH'} = length($payload); - $ENV{'CONTENT_TYPE'} = 'application/x-www-form-urlencoded'; - $ENV{'psgi.input'} = $in; - return $payload; -} - -- cgit v1.2.3