summaryrefslogtreecommitdiff
path: root/t/99-versioning.t
blob: e760daee7598de8b08512ed56870be1d6cd9f0d4 (plain)
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Test::More tests => 9;
  5. use LedgerSMB::Form;
  6. my $form = new Form;
  7. ok(defined $form, 'form: defined');
  8. isa_ok($form, 'Form', 'form: correct type');
  9. ok(defined $form->{version}, 'form: version set');
  10. ok(defined $form->{dbversion}, 'form: dbversion set');
  11. $form->{version} =~ s/\s//g;
  12. $form->{dbversion} =~ s/\s//g;
  13. ok(-e 'VERSION', 'VERSION exists');
  14. ok(-s 'VERSION', 'VERSION non-empty');
  15. ok(-r 'VERSION', 'VERSION readable');
  16. open(my $FH, '<', 'VERSION');
  17. my $ver = readline $FH;
  18. close $FH;
  19. chomp $ver;
  20. $ver =~ s/\s//g;
  21. is($form->{version}, $ver, 'Form version matches VERSION');
  22. SKIP: {
  23. skip 'Form is trunk', 1 if $form->{version} =~ /trunk$/i;
  24. my @dparts = split /\./, $form->{dbversion};
  25. my @lparts = split /\./, $form->{version};
  26. my $age = 0;
  27. foreach my $dpart (@dparts) {
  28. my $lpart = shift @lparts;
  29. if (!defined $lpart) {
  30. $age = 1;
  31. last;
  32. } elsif ($lpart > $dpart) {
  33. last;
  34. } elsif ($dpart > $lpart) {
  35. $age = 1;
  36. last;
  37. }
  38. }
  39. ok($age == 0, 'form: version >= dbversion');
  40. }