Get all existing specs passing

* Use disable_ddl_transaction so we can rescue from failed updates
* Specify category for each test feedback
上级 6f9f1ecd
......@@ -9,23 +9,7 @@ class UpdateFingerprintsOnNonDefaultBranchFeedback < ActiveRecord::Migration[5.2
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
# DOWNTIME_REASON = ''
# When using the methods "add_concurrent_index", "remove_concurrent_index" or
# "add_column_with_default" you must disable the use of transactions
# as these methods can not run in an existing transaction.
# When using "add_concurrent_index" or "remove_concurrent_index" methods make sure
# that either of them is the _only_ method called in the migration,
# any other changes should go in a separate migration.
# This ensures that upon failure _only_ the index creation or removing fails
# and can be retried or reverted easily.
#
# To disable transactions uncomment the following line and remove these
# comments:
# disable_ddl_transaction!
disable_ddl_transaction!
def up
Feedback.all.each do |feedback|
......
......@@ -38,7 +38,7 @@ describe UpdateFingerprintsOnNonDefaultBranchFeedback, :migration do
vulnerability = JSON.parse(artifact.file.read)['vulnerabilities'].first
old_fingerprint = Digest::SHA1.hexdigest(vulnerability['message'])
new_fingerprint = Digest::SHA1.hexdigest(vulnerability['cve'])
feedback = create_feedback(fingerprint: old_fingerprint)
feedback = create_feedback(fingerprint: old_fingerprint, category: 1)
migrate!
......@@ -56,7 +56,7 @@ describe UpdateFingerprintsOnNonDefaultBranchFeedback, :migration do
":#{vulnerability['featurename']}:#{vulnerability['featureversion']}"
)
new_fingerprint = Digest::SHA1.hexdigest(vulnerability['vulnerability'])
feedback = create_feedback(fingerprint: old_fingerprint)
feedback = create_feedback(fingerprint: old_fingerprint, category: 2)
migrate!
......@@ -72,8 +72,8 @@ describe UpdateFingerprintsOnNonDefaultBranchFeedback, :migration do
vulnerability = JSON.parse(artifact.file.read)['vulnerabilities'].first
old_fingerprint = Digest::SHA1.hexdigest(vulnerability['message'])
new_fingerprint = Digest::SHA1.hexdigest(vulnerability['cve'])
old_feedback = create_feedback(fingerprint: old_fingerprint)
_new_feedback = create_feedback(fingerprint: new_fingerprint)
old_feedback = create_feedback(fingerprint: old_fingerprint, category: 1)
_new_feedback = create_feedback(fingerprint: new_fingerprint, category: 1)
migrate!
......@@ -95,10 +95,10 @@ describe UpdateFingerprintsOnNonDefaultBranchFeedback, :migration do
)
end
def create_feedback(fingerprint:)
def create_feedback(category:, fingerprint:)
vulnerability_feedback.create(
author_id: user.id,
category: 1,
category: category,
feedback_type: 0,
pipeline_id: pipeline.id,
project_fingerprint: fingerprint,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册