@@ -62,17 +62,16 @@ def source(self):
6262
6363 assert 2 == len (os .listdir (os .path .join (tmp_folder , "s" )))
6464 content = json .loads (load (os .path .join (tmp_folder , "s" , sha256 + ".json" )))
65- assert "http://localhost.mirror:5000/myfile.txt" in content ["references" ]["unknown" ]
66- assert "http://localhost:5000/myfile.txt" in content ["references" ]["unknown" ]
67- assert len (content ["references" ]["unknown" ]) == 2
65+ assert "http://localhost.mirror:5000/myfile.txt" in content ["references" ]["pkg/1.0" ]
66+ assert len (content ["references" ]["pkg/1.0" ]) == 1
6867
6968 # Ensure the cache is working and we didn't break anything by modifying the summary
7069 client .run ("source ." )
7170 assert "Downloading file" not in client .out
7271
73- client .run ("create ." )
72+ client .run ("create . --user=barbarian " )
7473 content = json .loads (load (os .path .join (tmp_folder , "s" , sha256 + ".json" )))
75- assert content ["references" ]["pkg/1.0" ] == \
74+ assert content ["references" ]["pkg/1.0@barbarian " ] == \
7675 ["http://localhost.mirror:5000/myfile.txt" ]
7776
7877 client .run ("create . --user=barbarian --channel=stable" )
@@ -214,9 +213,9 @@ def test_unknown_handling(self):
214213 from conan.tools.files import download
215214 class Pkg2(ConanFile):
216215 name = "pkg"
217- version = "1.0"
218216 def source(self):
219- download(self, "{ self .file_server .fake_url } /internet/myfile.txt", "myfile.txt",
217+ download(self, "{ self .file_server .fake_url } /internet/myfile.txt",
218+ "myfile.txt",
220219 sha256="{ sha256 } ")
221220 """ )
222221
@@ -234,7 +233,7 @@ def source(self):
234233 s_folder = os .path .join (self .download_cache_folder , "s" )
235234 assert len (os .listdir (s_folder )) == 2
236235
237- self .client .run ("export ." )
236+ self .client .run ("export . --version=1.0 " )
238237 self .client .run ("upload * -c -r=default" )
239238 assert "No backup sources files to upload" in self .client .out
240239
@@ -746,7 +745,8 @@ def source(self):
746745 # Ensure we are testing for an already uploaded recipe
747746 assert f"Recipe 'pkg/1.0#{ exported_rev } ' already in server, skipping upload" in self .client .out
748747
749- def test_source_then_upload_workflow (self ):
748+ @pytest .mark .parametrize ("unknown" , [True , False ])
749+ def test_source_then_upload_workflow (self , unknown ):
750750 mkdir (os .path .join (self .download_cache_folder , "s" ))
751751
752752 http_server_base_folder_internet = os .path .join (self .file_server .store , "internet" )
@@ -770,7 +770,12 @@ def source(self):
770770 f"core.sources:upload_url={ self .file_server .fake_url } /backup/" })
771771
772772 self .client .save ({"conanfile.py" : conanfile })
773- self .client .run ("source ." )
773+ ref_args = "" if unknown else "--name foo --version 1.0"
774+ reference_key = "unknown" if unknown else "foo/1.0"
775+ self .client .run (f"source . { ref_args } " )
776+ content = json .loads (load (os .path .join (self .download_cache_folder , "s" , sha256 + ".json" )))
777+ assert len (content ["references" ][reference_key ]) == 1
778+
774779 self .client .run ("cache backup-upload" )
775780 # This used to crash because we were trying to list a missing dir if only exports were made
776781 assert "[Errno 2] No such file or directory" not in self .client .out
0 commit comments