gtt-project / redmine_supply

Redmine plugin to enable supply management for issues.
GNU General Public License v3.0
1 stars 1 forks source link

SupplyItemTest#test_deletion_of_project_should_delete_supply_items failed randomly when using S3 plugin with dummy test configuration #10

Open sanak opened 2 years ago

sanak commented 2 years ago

Problem When using redmica_s3 plugin with dummy test configuration,

--- a/config/s3.yml
+++ b/config/s3.yml
+
+# Uncomment this to run plugin tests with standard redmine script
+test:
+  access_key_id: S3_ACCESS_KEY_ID
+  secret_access_key: S3_SECRET_ACCESS_KEY
+  bucket: S3_BUCKET_NAME

I encountered the following error.

% RAILS_ENV=test NAME=redmine_supply bundle exec rake redmine:plugins:test
Unknown database adapter `postgis` found in config/database.yml, use Gemfile.local to load your own database gems
Run options: --seed 14332

# Running:

.................E

Error:
SupplyItemTest#test_deletion_of_project_should_delete_supply_items:
Aws::S3::Errors::PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
    plugins/redmica_s3/lib/redmica_s3/connection.rb:79:in `delete'
    plugins/redmica_s3/lib/redmica_s3/attachment_patch.rb:244:in `delete_from_disk!'
    app/models/attachment.rb:172:in `delete_from_disk'
    plugins/redmine_supply/test/unit/supply_item_test.rb:59:in `block (2 levels) in <class:SupplyItemTest>'
    plugins/redmine_supply/test/unit/supply_item_test.rb:58:in `block in <class:SupplyItemTest>'

rails test plugins/redmine_supply/test/unit/supply_item_test.rb:56
:

To Reproduce Execute the following command with using redmica_s3 plugin's dummy test configuration.

% RAILS_ENV=test NAME=redmine_supply bundle exec rake redmine:plugins:test

Expectation The test should pass always.

sanak commented 2 years ago

Well, easiest fix is just deleting original fixture's attachments at the setup of the test as follows, but probably it is not the best solution, because supply => s3 plugin dependency is not preferable.

--- a/test/unit/supply_item_test.rb
+++ b/test/unit/supply_item_test.rb
@@ -5,6 +5,7 @@ class SupplyItemTest < ActiveSupport::TestCase

   setup do
     @project = Project.find 'ecookbook'
+    Attachment.delete_all
   end

   test 'should find items' do

The complex thing is that Redmine fixtures doesn't include actual attachments files, so this may be rather s3 plugin side work...