Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-10 18:08:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-10 18:08:54 +0300
commit11e5d1b9ca3efa7be34ddebb708a6aedb4e91639 (patch)
tree999fdffb9d3db2e5200994e289e50fa3a3a1684a /spec/lib/gitlab
parent7351a484d79236b7e9d47c86f2fcc970b7ae10b0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/ci/config/entry/reports_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/import_export_equivalence_spec.rb60
2 files changed, 61 insertions, 1 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/reports_spec.rb b/spec/lib/gitlab/ci/config/entry/reports_spec.rb
index 1ec30976284..c64bb0a4cc3 100644
--- a/spec/lib/gitlab/ci/config/entry/reports_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/reports_spec.rb
@@ -43,7 +43,7 @@ describe Gitlab::Ci::Config::Entry::Reports do
:license_management | 'gl-license-management-report.json'
:license_scanning | 'gl-license-scanning-report.json'
:performance | 'performance.json'
- :lsif | 'lsif.sqlite3'
+ :lsif | 'lsif.json'
end
with_them do
diff --git a/spec/lib/gitlab/import_export/import_export_equivalence_spec.rb b/spec/lib/gitlab/import_export/import_export_equivalence_spec.rb
new file mode 100644
index 00000000000..50b26637cb1
--- /dev/null
+++ b/spec/lib/gitlab/import_export/import_export_equivalence_spec.rb
@@ -0,0 +1,60 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+# Verifies that given an exported project meta-data tree, when importing this
+# tree and then exporting it again, we should obtain the initial tree.
+#
+# This equivalence only works up to a certain extent, for instance we need
+# to ignore:
+#
+# - row IDs and foreign key IDs
+# - some timestamps
+# - randomly generated fields like tokens
+#
+# as these are expected to change between import/export cycles.
+describe Gitlab::ImportExport do
+ include ImportExport::CommonUtil
+ include ConfigurationHelper
+ include ImportExport::ProjectTreeExpectations
+
+ let(:json_fixture) { 'complex' }
+
+ it 'yields the initial tree when importing and exporting it again' do
+ project = create(:project, creator: create(:user, :admin))
+
+ # We first generate a test fixture dynamically from a seed-fixture, so as to
+ # account for any fields in the initial fixture that are missing and set to
+ # defaults during import (ideally we should have realistic test fixtures
+ # that "honestly" represent exports)
+ expect(
+ restore_then_save_project(
+ project,
+ import_path: seed_fixture_path,
+ export_path: test_fixture_path)
+ ).to be true
+ # Import, then export again from the generated fixture. Any residual changes
+ # in the JSON will count towards comparison i.e. test failures.
+ expect(
+ restore_then_save_project(
+ project,
+ import_path: test_fixture_path,
+ export_path: test_tmp_path)
+ ).to be true
+
+ imported_json = JSON.parse(File.read("#{test_fixture_path}/project.json"))
+ exported_json = JSON.parse(File.read("#{test_tmp_path}/project.json"))
+
+ assert_relations_match(imported_json, exported_json)
+ end
+
+ private
+
+ def seed_fixture_path
+ "#{fixtures_path}/#{json_fixture}"
+ end
+
+ def test_fixture_path
+ "#{test_tmp_path}/#{json_fixture}"
+ end
+end