siringa 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
 - data/README.md +2 -4
 - data/app/controllers/siringa/siringa_controller.rb +7 -7
 - data/lib/generators/templates/siringa_initializer.rb +1 -8
 - data/lib/siringa/dumps.rb +53 -8
 - data/lib/siringa/version.rb +1 -1
 - data/test/dummy/config/environments/test.rb +5 -0
 - data/test/dummy/config/initializers/siringa.rb +1 -5
 - data/test/dummy/db/test.sqlite3 +0 -0
 - data/test/dummy/log/test.log +1258 -0
 - data/test/siringa_test.rb +117 -3
 - metadata +4 -4
 - data/app/helpers/siringa/application_helper.rb +0 -4
 
    
        data/test/siringa_test.rb
    CHANGED
    
    | 
         @@ -1,7 +1,121 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'test_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'minitest/spec'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'minitest/mock'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe Siringa do
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              before do
         
     | 
| 
      
 8 
     | 
    
         
            +
                @process = MiniTest::Mock.new
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              describe "#dump_to" do
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                it "run a command when the DB adapter is MySql" do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @process.expect(:success?, true)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  Siringa.stub(:adapter_config, { :adapter => "mysql", :database => "test_database" }) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                    Open3.stub(:capture3, ["", "", @process]) do
         
     | 
| 
      
 17 
     | 
    
         
            +
                      assert_equal({ :status => true,
         
     | 
| 
      
 18 
     | 
    
         
            +
                                     :error => "",
         
     | 
| 
      
 19 
     | 
    
         
            +
                                     :dump_path => "tmp/dumps" }, Siringa.dump_to("tmp/dumps"))
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                it "fail to run a bad command when the DB adapter is MySql" do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  @process.expect(:success?, false)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  Siringa.stub(:adapter_config, { :adapter => "mysql", :database => "test_database" }) do
         
     | 
| 
      
 27 
     | 
    
         
            +
                    Open3.stub(:capture3, ["", "error message", @process]) do
         
     | 
| 
      
 28 
     | 
    
         
            +
                      assert_equal({ :status => false,
         
     | 
| 
      
 29 
     | 
    
         
            +
                                     :error => "error message",
         
     | 
| 
      
 30 
     | 
    
         
            +
                                     :dump_path => "tmp/dumps" }, Siringa.dump_to("tmp/dumps"))
         
     | 
| 
      
 31 
     | 
    
         
            +
                    end
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
               it "run a command when the DB adapter is Sqlite" do
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @process.expect(:success?, true)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  Siringa.stub(:adapter_config, { :adapter => "sqlite3", :database => "test_database" }) do
         
     | 
| 
      
 38 
     | 
    
         
            +
                    Open3.stub(:capture3, ["", "", @process]) do
         
     | 
| 
      
 39 
     | 
    
         
            +
                      assert_equal({ :status => true,
         
     | 
| 
      
 40 
     | 
    
         
            +
                                     :error => "",
         
     | 
| 
      
 41 
     | 
    
         
            +
                                     :dump_path => "tmp/dumps" }, Siringa.dump_to("tmp/dumps"))
         
     | 
| 
      
 42 
     | 
    
         
            +
                    end
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                it "fail to run a bad command when the DB adapter is Sqlite" do
         
     | 
| 
      
 47 
     | 
    
         
            +
                  @process.expect(:success?, false)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  Siringa.stub(:adapter_config, { :adapter => "sqlite3", :database => "test_database" }) do
         
     | 
| 
      
 49 
     | 
    
         
            +
                    Open3.stub(:capture3, ["", "error message", @process]) do
         
     | 
| 
      
 50 
     | 
    
         
            +
                      assert_equal({ :status => false,
         
     | 
| 
      
 51 
     | 
    
         
            +
                                     :error => "error message",
         
     | 
| 
      
 52 
     | 
    
         
            +
                                     :dump_path => "tmp/dumps" }, Siringa.dump_to("tmp/dumps"))
         
     | 
| 
      
 53 
     | 
    
         
            +
                    end
         
     | 
| 
      
 54 
     | 
    
         
            +
                  end
         
     | 
| 
      
 55 
     | 
    
         
            +
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                it "raise an error using a not supported DB adapter" do
         
     | 
| 
      
 58 
     | 
    
         
            +
                  Siringa.stub(:adapter_config, { :adapter => "whateverDB", :database => "test_database" }) do
         
     | 
| 
      
 59 
     | 
    
         
            +
                    exception = assert_raises(NotImplementedError) { Siringa.dump_to("tmp/dumps") }
         
     | 
| 
      
 60 
     | 
    
         
            +
                    assert_equal("Unknown adapter type 'whateverDB'", exception.to_s)
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
       2 
63 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            class SiringaTest < ActiveSupport::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
              test "truth" do
         
     | 
| 
       5 
     | 
    
         
            -
                assert_kind_of Module, Siringa
         
     | 
| 
       6 
64 
     | 
    
         
             
              end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
              describe "#restore_from" do
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                it "run a command when the DB adapter is MySql" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                  @process.expect(:success?, true)
         
     | 
| 
      
 70 
     | 
    
         
            +
                  Siringa.stub(:adapter_config, { :adapter => "mysql", :database => "test_database" }) do
         
     | 
| 
      
 71 
     | 
    
         
            +
                    Open3.stub(:capture3, ["", "", @process]) do
         
     | 
| 
      
 72 
     | 
    
         
            +
                      assert_equal({ :status => true,
         
     | 
| 
      
 73 
     | 
    
         
            +
                                     :error => "",
         
     | 
| 
      
 74 
     | 
    
         
            +
                                     :dump_path => "tmp/dumps/dump.dump" }, Siringa.restore_from("tmp/dumps/dump.dump"))
         
     | 
| 
      
 75 
     | 
    
         
            +
                    end
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                it "fail to run a bad command when the DB adapter is MySql" do
         
     | 
| 
      
 80 
     | 
    
         
            +
                  @process.expect(:success?, false)
         
     | 
| 
      
 81 
     | 
    
         
            +
                  Siringa.stub(:adapter_config, { :adapter => "mysql", :database => "test_database" }) do
         
     | 
| 
      
 82 
     | 
    
         
            +
                    Open3.stub(:capture3, ["", "error message", @process]) do
         
     | 
| 
      
 83 
     | 
    
         
            +
                      assert_equal({ :status => false,
         
     | 
| 
      
 84 
     | 
    
         
            +
                                     :error => "error message",
         
     | 
| 
      
 85 
     | 
    
         
            +
                                     :dump_path => "tmp/dumps/dump.dump" }, Siringa.restore_from("tmp/dumps/dump.dump"))
         
     | 
| 
      
 86 
     | 
    
         
            +
                    end
         
     | 
| 
      
 87 
     | 
    
         
            +
                  end
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                it "run a command when the DB adapter is Sqlite" do
         
     | 
| 
      
 91 
     | 
    
         
            +
                  @process.expect(:success?, true)
         
     | 
| 
      
 92 
     | 
    
         
            +
                  Siringa.stub(:adapter_config, { :adapter => "sqlite3", :database => "test_database" }) do
         
     | 
| 
      
 93 
     | 
    
         
            +
                    Open3.stub(:capture3, ["", "", @process]) do
         
     | 
| 
      
 94 
     | 
    
         
            +
                      assert_equal({ :status => true,
         
     | 
| 
      
 95 
     | 
    
         
            +
                                     :error => "",
         
     | 
| 
      
 96 
     | 
    
         
            +
                                     :dump_path => "tmp/dumps/dump.dump" }, Siringa.restore_from("tmp/dumps/dump.dump"))
         
     | 
| 
      
 97 
     | 
    
         
            +
                    end
         
     | 
| 
      
 98 
     | 
    
         
            +
                  end
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                it "fail to run a bad command when the DB adapter is Sqlite" do
         
     | 
| 
      
 102 
     | 
    
         
            +
                  @process.expect(:success?, false)
         
     | 
| 
      
 103 
     | 
    
         
            +
                  Siringa.stub(:adapter_config, { :adapter => "sqlite3", :database => "test_database" }) do
         
     | 
| 
      
 104 
     | 
    
         
            +
                    Open3.stub(:capture3, ["", "error message", @process]) do
         
     | 
| 
      
 105 
     | 
    
         
            +
                      assert_equal({ :status => false,
         
     | 
| 
      
 106 
     | 
    
         
            +
                                     :error => "error message",
         
     | 
| 
      
 107 
     | 
    
         
            +
                                     :dump_path => "tmp/dumps/dump.dump" }, Siringa.restore_from("tmp/dumps/dump.dump"))
         
     | 
| 
      
 108 
     | 
    
         
            +
                    end
         
     | 
| 
      
 109 
     | 
    
         
            +
                  end
         
     | 
| 
      
 110 
     | 
    
         
            +
                end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                it "raise an error using a not supported DB adapter" do
         
     | 
| 
      
 113 
     | 
    
         
            +
                  Siringa.stub(:adapter_config, { :adapter => "whateverDB", :database => "test_database" }) do
         
     | 
| 
      
 114 
     | 
    
         
            +
                    exception = assert_raises(NotImplementedError) { Siringa.restore_from("tmp/dumps") }
         
     | 
| 
      
 115 
     | 
    
         
            +
                    assert_equal("Unknown adapter type 'whateverDB'", exception.to_s)
         
     | 
| 
      
 116 
     | 
    
         
            +
                  end
         
     | 
| 
      
 117 
     | 
    
         
            +
                end
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
              end
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
       7 
121 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: siringa
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Enrico Stano
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2013- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-10-08 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: sqlite3
         
     | 
| 
         @@ -32,7 +32,6 @@ executables: [] 
     | 
|
| 
       32 
32 
     | 
    
         
             
            extensions: []
         
     | 
| 
       33 
33 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       34 
34 
     | 
    
         
             
            files:
         
     | 
| 
       35 
     | 
    
         
            -
            - app/helpers/siringa/application_helper.rb
         
     | 
| 
       36 
35 
     | 
    
         
             
            - app/controllers/siringa/siringa_controller.rb
         
     | 
| 
       37 
36 
     | 
    
         
             
            - app/controllers/siringa/application_controller.rb
         
     | 
| 
       38 
37 
     | 
    
         
             
            - config/routes.rb
         
     | 
| 
         @@ -91,7 +90,8 @@ files: 
     | 
|
| 
       91 
90 
     | 
    
         
             
            - test/dummy/log/development.log
         
     | 
| 
       92 
91 
     | 
    
         
             
            - test/controllers/siringa_controller_test.rb
         
     | 
| 
       93 
92 
     | 
    
         
             
            homepage: https://github.com/enricostano/siringa
         
     | 
| 
       94 
     | 
    
         
            -
            licenses: 
     | 
| 
      
 93 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 94 
     | 
    
         
            +
            - MIT
         
     | 
| 
       95 
95 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       96 
96 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       97 
97 
     | 
    
         
             
            rdoc_options: []
         
     |