6 use Test::More qw| no_plan|;
8 use SGN::Test::Fixture;
11 my $f = SGN::Test::Fixture->new();
12 my $schema = $f->bcs_schema();
17 my $this_stock_id = 39041;
18 my $other_stock_id = 38844;
20 my $stock = CXGN::Stock->new( { schema => $schema, stock_id => $this_stock_id } );
22 my $initial_counts = get_counts($this_stock_id);
24 # try self merge, should fail:
25 my $error = $stock->merge($this_stock_id);
26 is($error, "Error: cannot merge stock into itself", "merge stock into itself test");
28 my $initial_counts_other = get_counts($other_stock_id);
30 $error = $stock->merge(38844);
31 is($error, undef, "merge stock should give no error");
33 # all data should be transferred, so these need to add up
34 my $combined_counts = get_counts($this_stock_id);
36 $initial_counts_other->{prop_count}++; # take added synonym into account
38 foreach my $k (keys %$combined_counts) {
39 print STDERR "Checking key $k...\n";
40 is($combined_counts->{$k}, ($initial_counts->{$k} + $initial_counts_other->{$k}), "$k test");
44 print STDERR "ERROR = $@\n";
45 $schema->txn_rollback();
52 my $stock_rel_object_id_count = $schema->resultset("Stock::StockRelationship")->search( { object_id => $stock_id })->count();
53 my $stock_rel_subject_id_count = $schema->resultset("Stock::StockRelationship")->search( { subject_id => $stock_id })->count();
54 my $stock_nd_experiment_count = $schema->resultset("NaturalDiversity::NdExperimentStock")->search( { stock_id => $stock_id })->count();
55 my $stock_prop_count = $schema->resultset("Stock::Stockprop")->search( { stock_id => $stock_id })->count();
58 object_id_count => $stock_rel_object_id_count,
59 subject_id_count => $stock_rel_subject_id_count,
60 nd_experiment_count => $stock_nd_experiment_count,
61 prop_count => $stock_prop_count,
64 print STDERR Dumper($data);