@@ -110,3 +110,106 @@ def __prepare_content(self, prefix: str = None):
110110 targets = [('' , TEST_BUCKET , prefix , DEFAULT_REGISTRY )],
111111 dir_ = self .tempdir , do_index = False
112112 )
113+
114+ def test_overlap_prefix_del (self ):
115+ self .__prepare_content_backstage ()
116+
117+ test_bucket = self .mock_s3 .Bucket (TEST_BUCKET )
118+ objs = list (test_bucket .objects .all ())
119+ actual_files = [obj .key for obj in objs ]
120+ self .assertEqual (18 , len (actual_files ))
121+
122+ meta_obj = test_bucket .Object ("@janus-idp/backstage-plugin-orchestrator/package.json" )
123+ meta_content_client = str (meta_obj .get ()["Body" ].read (), "utf-8" )
124+ self .assertIn ("\" name\" : \" @janus-idp/backstage-plugin-orchestrator\" " , meta_content_client )
125+ self .assertIn ("\" version\" : \" 1.21.102\" " , meta_content_client )
126+ self .assertIn ("\" version\" : \" 1.21.103\" " , meta_content_client )
127+ self .assertIn ("\" 1.21.103\" : {\" name\" :" , meta_content_client )
128+
129+ meta_obj = test_bucket .Object (
130+ "@janus-idp/backstage-plugin-orchestrator-backend-dynamic/package.json" )
131+ meta_content_client = str (meta_obj .get ()["Body" ].read (), "utf-8" )
132+ self .assertIn (
133+ "\" name\" : \" @janus-idp/backstage-plugin-orchestrator-backend-dynamic\" " ,
134+ meta_content_client )
135+ self .assertIn ("\" version\" : \" 0.0.1\" " , meta_content_client )
136+ self .assertIn ("\" version\" : \" 2.3.0\" " , meta_content_client )
137+ self .assertIn ("\" 2.3.0\" : {\" name\" :" , meta_content_client )
138+
139+ test_prod = "backstage-plugin-orchestrator-1.21.103"
140+ test_tgz = os .path .join (INPUTS , test_prod + ".tgz" )
141+ handle_npm_del (
142+ test_tgz , test_prod ,
143+ targets = [('' , TEST_BUCKET , None , '' )],
144+ dir_ = self .tempdir , do_index = False
145+ )
146+
147+ test_bucket = self .mock_s3 .Bucket (TEST_BUCKET )
148+ objs = list (test_bucket .objects .all ())
149+ actual_files = [obj .key for obj in objs ]
150+ self .assertEqual (14 , len (actual_files ))
151+
152+ meta_obj = test_bucket .Object ("@janus-idp/backstage-plugin-orchestrator/package.json" )
153+ meta_content_client = str (meta_obj .get ()["Body" ].read (), "utf-8" )
154+ self .assertIn ("\" name\" : \" @janus-idp/backstage-plugin-orchestrator\" " , meta_content_client )
155+ self .assertIn ("\" version\" : \" 1.21.102\" " , meta_content_client )
156+ self .assertNotIn ("\" version\" : \" 1.21.103\" " , meta_content_client )
157+ self .assertNotIn ("\" 1.21.103\" : {\" name\" :" , meta_content_client )
158+
159+ meta_obj = test_bucket .Object (
160+ "@janus-idp/backstage-plugin-orchestrator-backend-dynamic/package.json" )
161+ meta_content_client = str (meta_obj .get ()["Body" ].read (), "utf-8" )
162+ self .assertIn (
163+ "\" name\" : \" @janus-idp/backstage-plugin-orchestrator-backend-dynamic\" " ,
164+ meta_content_client )
165+ self .assertIn ("\" version\" : \" 0.0.1\" " , meta_content_client )
166+ self .assertIn ("\" version\" : \" 2.3.0\" " , meta_content_client )
167+ self .assertIn ("\" 2.3.0\" : {\" name\" :" , meta_content_client )
168+
169+ test_prod = "backstage-plugin-orchestrator-backend-dynamic-2.3.0"
170+ test_tgz = os .path .join (INPUTS , test_prod + ".tgz" )
171+ handle_npm_del (
172+ test_tgz , test_prod ,
173+ targets = [('' , TEST_BUCKET , None , '' )],
174+ dir_ = self .tempdir , do_index = False
175+ )
176+
177+ test_bucket = self .mock_s3 .Bucket (TEST_BUCKET )
178+ objs = list (test_bucket .objects .all ())
179+ actual_files = [obj .key for obj in objs ]
180+ self .assertEqual (10 , len (actual_files ))
181+
182+ meta_obj = test_bucket .Object (
183+ "@janus-idp/backstage-plugin-orchestrator/package.json" )
184+ meta_content_client = str (meta_obj .get ()["Body" ].read (), "utf-8" )
185+ self .assertIn (
186+ "\" name\" : \" @janus-idp/backstage-plugin-orchestrator\" " ,
187+ meta_content_client )
188+ self .assertIn ("\" version\" : \" 1.21.102\" " , meta_content_client )
189+ self .assertNotIn ("\" version\" : \" 1.21.103\" " , meta_content_client )
190+ self .assertNotIn ("\" 1.21.103\" : {\" name\" :" , meta_content_client )
191+
192+ meta_obj = test_bucket .Object (
193+ "@janus-idp/backstage-plugin-orchestrator-backend-dynamic/package.json" )
194+ meta_content_client = str (meta_obj .get ()["Body" ].read (), "utf-8" )
195+ self .assertIn (
196+ "\" name\" : \" @janus-idp/backstage-plugin-orchestrator-backend-dynamic\" " ,
197+ meta_content_client )
198+ self .assertIn ("\" version\" : \" 0.0.1\" " , meta_content_client )
199+ self .assertNotIn ("\" version\" : \" 2.3.0\" " , meta_content_client )
200+ self .assertNotIn ("\" 2.3.0\" : {\" name\" :" , meta_content_client )
201+
202+ def __prepare_content_backstage (self , prefix : str = None ):
203+ test_prods = [
204+ "backstage-plugin-orchestrator-1.21.102" ,
205+ "backstage-plugin-orchestrator-1.21.103" ,
206+ "backstage-plugin-orchestrator-backend-dynamic-0.0.1" ,
207+ "backstage-plugin-orchestrator-backend-dynamic-2.3.0"
208+ ]
209+ for p in test_prods :
210+ test_tgz = os .path .join (INPUTS , p + ".tgz" )
211+ handle_npm_uploading (
212+ test_tgz , p ,
213+ targets = [('' , TEST_BUCKET , prefix , DEFAULT_REGISTRY )],
214+ dir_ = self .tempdir , do_index = False
215+ )
0 commit comments