From 41d00edd2b2a266bca76e19d2861fc72dd0d0053 Mon Sep 17 00:00:00 2001
From: Giorgenes Gelatti <ggelatti@gitlab.com>
Date: Tue, 23 Jun 2020 20:39:06 +1000
Subject: [PATCH] Improve package factories

Fix a few package factories which don't
work on their own.
---
 ee/spec/factories/packages.rb | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/ee/spec/factories/packages.rb b/ee/spec/factories/packages.rb
index 69fab94d2b3..037c726c442 100644
--- a/ee/spec/factories/packages.rb
+++ b/ee/spec/factories/packages.rb
@@ -118,14 +118,25 @@ FactoryBot.define do
   end
 
   factory :composer_metadatum, class: 'Packages::Composer::Metadatum' do
+    package { create(:composer_package) }
+
+    target_sha { '123' }
+    composer_json { { name: 'foo' } }
   end
 
   factory :package_build_info, class: 'Packages::BuildInfo' do
+    package
   end
 
   factory :package_file, class: 'Packages::PackageFile' do
     package
 
+    file { fixture_file_upload('spec/fixtures/packages/conan/recipe_files/conanfile.py') }
+    file_name { 'conanfile.py' }
+    file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' }
+    file_md5 { '12345abcde' }
+    size { 400.kilobytes }
+
     factory :conan_package_file do
       package { create(:conan_package, without_package_files: true) }
 
@@ -297,6 +308,7 @@ FactoryBot.define do
   factory :conan_file_metadatum, class: 'Packages::Conan::FileMetadatum' do
     package_file { create(:conan_package_file, :conan_recipe_file, without_loaded_metadatum: true) }
     recipe_revision { '0' }
+    conan_file_type { 'recipe_file' }
 
     trait(:recipe_file) do
       conan_file_type { 'recipe_file' }
@@ -316,7 +328,7 @@ FactoryBot.define do
   end
 
   factory :packages_dependency_link, class: 'Packages::DependencyLink' do
-    package
+    package { create(:nuget_package) }
     dependency { create(:packages_dependency) }
     dependency_type { :dependencies }
 
@@ -328,6 +340,7 @@ FactoryBot.define do
   end
 
   factory :nuget_dependency_link_metadatum, class: 'Packages::Nuget::DependencyLinkMetadatum' do
+    dependency_link { create(:packages_dependency_link) }
     target_framework { '.NETStandard2.0' }
   end
 
-- 
2.30.9