Project import/export: Ensure project.json tests everything in import_export.yml
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
We saw in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31690#note_202718225, that project import/export would fail because attributes added in import_export.yml were not added to spec/fixtures/import_export/project.json.
Something like this might be a start:
diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
index baec24590b4..88ff6a729f4 100644
--- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
@@ -2,6 +2,25 @@ require 'spec_helper'
include ImportExport::CommonUtil
describe Gitlab::ImportExport::ProjectTreeRestorer do
+ describe 'import_export.yml consistency' do
+ let(:project_json) { JSON.load(File.open(File.join("spec", "lib", "gitlab", "import_export", "project.json"))) }
+ let(:import_export_yml) { YAML.load_file(File.join("lib", "gitlab", "import_export", "import_export.yml")) }
+
+ it 'project.json includes all attributes in import_export.yml' do
+ project_tree = import_export_yml['project_tree']
+
+ keys = project_tree.map do |element|
+ if element.is_a?(Hash)
+ element.keys.first
+ else
+ element.to_s
+ end
+ end
+
+ expect(project_json.keys).to match_array(keys)
+ end
+ end
+
We'd also need to do the same for all subkeys.
Edited by 🤖 GitLab Bot 🤖