File: Rakefile

package info (click to toggle)
ruby-marginalia 1.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 140 kB
  • sloc: ruby: 631; makefile: 4
file content (60 lines) | stat: -rwxr-xr-x 1,402 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env rake
require "bundler/gem_tasks"

task :default => ['test:all']

namespace :test do
  desc "test all drivers"
  task :all => [:mysql2, :postgresql, :sqlite]

  desc "test mysql2 driver"
  task :mysql2 do
    sh "DRIVER=mysql2 bundle exec ruby -Ilib -Itest test/*_test.rb"
  end

  desc "test PostgreSQL driver"
  task :postgresql do
    sh "DRIVER=postgresql DB_USERNAME=postgres bundle exec ruby -Ilib -Itest test/*_test.rb"
  end

  desc "test sqlite3 driver"
  task :sqlite do
    sh "DRIVER=sqlite3 bundle exec ruby -Ilib -Itest test/*_test.rb"
  end
end

namespace :db do

  desc "reset all databases"
  task :reset => [:"mysql:reset", :"postgresql:reset"]

  namespace :mysql do
    desc "reset MySQL database"
    task :reset => [:drop, :create]

    desc "create MySQL database"
    task :create do
      sh 'mysql -u root -e "create database marginalia_test;"'
    end

    desc "drop MySQL database"
    task :drop do
      sh 'mysql -u root -e "drop database if exists marginalia_test;"'
    end
  end

  namespace :postgresql do
    desc "reset PostgreSQL database"
    task :reset => [:drop, :create]

    desc "create PostgreSQL database"
    task :create do
      sh 'createdb -U postgres marginalia_test'
    end

    desc "drop PostgreSQL database"
    task :drop do
      sh 'psql -d postgres -U postgres -c "DROP DATABASE IF EXISTS marginalia_test"'
    end
  end
end