diff options
| author | yo mama <pepper@scannerjammer.com> | 2014-09-25 19:09:06 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2014-09-25 19:09:06 -0700 |
| commit | f68564b88dfb3ac08df2d01f883a0276883b96aa (patch) | |
| tree | 550edd360bb71c540894216d887bf046a4f20570 /DBIC_tests.pl | |
| parent | f7b29b9ff4658be13c8573ce4303240b572c4e57 (diff) | |
added2
Diffstat (limited to 'DBIC_tests.pl')
| -rw-r--r-- | DBIC_tests.pl | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/DBIC_tests.pl b/DBIC_tests.pl new file mode 100644 index 0000000..ec532d4 --- /dev/null +++ b/DBIC_tests.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl +use Data::Dumper; +use DateTime;#is that what was missing? could be +use lib 'lib'; +use JournalApp::Schema; + +my $entry = { + id => 12, + fulltext => "hello world test test test", + image_url => "http://myimage.com/new.png", + date => DateTime->now()->epoch, +}; +#our $schema = JournalApp::Schema->connect( 'dbi:SQLite:./journals.db', '', ''); +our $schema = JournalApp::Schema->connect( 'dbi:mysql:database=journal;host=localhost;port=3306', 'journal_user', 'journal_password', { + quote_names => 1 +}); + +sub test_remove_from_db{ + #delete by id + my $journalentry = $schema->resultset('Journal')->find({ id => $entry->{id} }); + +$journalentry->delete(); +} + + + +sub test_get_entry_by_date{ + my $res = $schema->resultset('Journal')->search({ + -and => [ + date => { '>', DateTime->now()->epoch - 3600 * 24 * 2 }, + date => { '<=', DateTime->now()->epoch }, + ] + }, { + order_by => "date" + } + ); + foreach my $row ($res->all){ + print Dumper $row->id; #so it just didn't find anything? looks so yeah just needed <= + } + +} + +sub test_add_journal_entry{ + my $journalentry = $schema->resultset('Journal')->create($entry); + if ($journalentry){ print "added sucessfully\n"} else { "add failed\n" }; + return $journalentry; +} + +#how do I connect? + +sub main{ + test_add_journal_entry; + test_get_entry_by_date; + test_remove_from_db; +} +main(); |
