|
Revision 164, 1.3 kB
(checked in by miyagawa, 7 months ago)
|
|
PostgreSQL patch from clkao
|
| Line | |
|---|
| 1 | # $Id$ |
|---|
| 2 | # -*-perl-*- |
|---|
| 3 | |
|---|
| 4 | use strict; |
|---|
| 5 | use warnings; |
|---|
| 6 | |
|---|
| 7 | require 't/lib/db-common.pl'; |
|---|
| 8 | |
|---|
| 9 | use TheSchwartz; |
|---|
| 10 | use Test::More tests => 18; |
|---|
| 11 | |
|---|
| 12 | #use Data::ObjectDriver; |
|---|
| 13 | #$Data::ObjectDriver::DEBUG = 1; |
|---|
| 14 | |
|---|
| 15 | run_tests(6, sub { |
|---|
| 16 | my $client = test_client(dbs => ['ts1']); |
|---|
| 17 | my ($job, $handle); |
|---|
| 18 | |
|---|
| 19 | # insert a job with unique |
|---|
| 20 | $job = TheSchwartz::Job->new( |
|---|
| 21 | funcname => 'feed', |
|---|
| 22 | uniqkey => "major", |
|---|
| 23 | ); |
|---|
| 24 | ok($job, "made first feed major job"); |
|---|
| 25 | $handle = $client->insert($job); |
|---|
| 26 | isa_ok $handle, 'TheSchwartz::JobHandle'; |
|---|
| 27 | |
|---|
| 28 | # insert again (notably to same db) and see it fails |
|---|
| 29 | $job = TheSchwartz::Job->new( |
|---|
| 30 | funcname => 'feed', |
|---|
| 31 | uniqkey => "major", |
|---|
| 32 | ); |
|---|
| 33 | ok($job, "made another feed major job"); |
|---|
| 34 | $handle = $client->insert($job); |
|---|
| 35 | ok(! $handle, 'no handle'); |
|---|
| 36 | |
|---|
| 37 | # insert same uniqkey, but different func |
|---|
| 38 | $job = TheSchwartz::Job->new( |
|---|
| 39 | funcname => 'scratch', |
|---|
| 40 | uniqkey => "major", |
|---|
| 41 | ); |
|---|
| 42 | ok($job, "made scratch major job"); |
|---|
| 43 | $handle = $client->insert($job); |
|---|
| 44 | isa_ok $handle, 'TheSchwartz::JobHandle'; |
|---|
| 45 | |
|---|
| 46 | }); |
|---|