summaryrefslogtreecommitdiff
path: root/t/99-versioning.t
blob: 3259e07df011a5ee98cfe218617fbd6f1f5c5324 (plain)
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Test::More tests => 17;
  5. use LedgerSMB;
  6. use LedgerSMB::Form;
  7. my $lsmb = new LedgerSMB;
  8. ok(defined $lsmb, 'lsmb: defined');
  9. isa_ok($lsmb, 'LedgerSMB', 'lsmb: correct type');
  10. ok(defined $lsmb->{version}, 'lsmb: version set');
  11. ok(defined $lsmb->{dbversion}, 'lsmb: dbversion set');
  12. my $form = new Form;
  13. ok(defined $form, 'form: defined');
  14. isa_ok($form, 'Form', 'form: correct type');
  15. ok(defined $form->{version}, 'form: version set');
  16. ok(defined $form->{dbversion}, 'form: dbversion set');
  17. is($lsmb->{version}, $form->{version}, 'LedgerSMB and Form versions match');
  18. is($lsmb->{dbversion}, $form->{dbversion}, 'LedgerSMB and Form dbversions match');
  19. ok(-e 'VERSION', 'VERSION exists');
  20. ok(-s 'VERSION', 'VERSION non-empty');
  21. ok(-r 'VERSION', 'VERSION readable');
  22. open(my $FH, '<', 'VERSION');
  23. my $ver = readline $FH;
  24. close $FH;
  25. chomp $ver;
  26. is($lsmb->{version}, $ver, 'LedgerSMB version matches VERSION');
  27. is($form->{version}, $ver, 'Form version matches VERSION');
  28. my @dparts;
  29. my @lparts;
  30. my $age;
  31. SKIP: {
  32. skip 'LedgerSMB is trunk', 1 if $lsmb->{version} =~ /trunk$/i;
  33. @dparts = split /\./, $lsmb->{dbversion};
  34. @lparts = split /\./, $lsmb->{version};
  35. $age = 0;
  36. foreach my $dpart (@dparts) {
  37. my $lpart = shift @lparts;
  38. if (!defined $lpart) {
  39. $age = 1;
  40. last;
  41. } elsif ($lpart > $dpart) {
  42. last;
  43. } elsif ($dpart > $lpart) {
  44. $age = 1;
  45. last;
  46. }
  47. }
  48. ok($age == 0, 'lsmb: version >= dbversion');
  49. }
  50. SKIP: {
  51. skip 'Form is trunk', 1 if $form->{version} =~ /trunk$/i;
  52. @dparts = split /\./, $form->{dbversion};
  53. @lparts = split /\./, $form->{version};
  54. $age = 0;
  55. foreach my $dpart (@dparts) {
  56. my $lpart = shift @lparts;
  57. if (!defined $lpart) {
  58. $age = 1;
  59. last;
  60. } elsif ($lpart > $dpart) {
  61. last;
  62. } elsif ($dpart > $lpart) {
  63. $age = 1;
  64. last;
  65. }
  66. }
  67. ok($age == 0, 'form: version >= dbversion');
  68. }