@@ -255,6 +255,112 @@ func TestObserve(t *testing.T) {
255255 err : nil ,
256256 },
257257 },
258+ "SuccessfulWithAppProject" : {
259+ args : args {
260+ client : withMockClient (t , func (mcs * mockclient.MockRepositoryServiceClient ) {
261+ mcs .EXPECT ().Get (
262+ context .Background (),
263+ & argocdRepository.RepoQuery {
264+ Repo : testRepositoryExternalName ,
265+ AppProject : "test-project" ,
266+ },
267+ ).Return (
268+ & argocdv1alpha1.Repository {
269+ Repo : testRepo ,
270+ Name : testRepositoryExternalName ,
271+ Project : "test-project" ,
272+ }, nil )
273+ }),
274+ cr : Repository (
275+ withExternalName (testRepositoryExternalName ),
276+ withSpec (v1alpha1.RepositoryParameters {
277+ Name : ptr .To (testRepositoryExternalName ),
278+ Repo : testRepo ,
279+ Project : ptr .To ("test-project" ),
280+ Insecure : & testInsecure ,
281+ EnableLFS : & testEnableLFS ,
282+ InheritedCreds : & testInheritedCreds ,
283+ EnableOCI : & testEnableOCI ,
284+ }),
285+ ),
286+ },
287+ want : want {
288+ cr : Repository (
289+ withExternalName (testRepositoryExternalName ),
290+ withSpec (v1alpha1.RepositoryParameters {
291+ Name : ptr .To (testRepositoryExternalName ),
292+ Repo : testRepo ,
293+ Project : ptr .To ("test-project" ),
294+ Insecure : & testInsecure ,
295+ EnableLFS : & testEnableLFS ,
296+ InheritedCreds : & testInheritedCreds ,
297+ EnableOCI : & testEnableOCI ,
298+ }),
299+ withConditions (xpv1 .Available ()),
300+ withObservation (v1alpha1.RepositoryObservation {
301+ ConnectionState : v1alpha1.ConnectionState {},
302+ }),
303+ ),
304+ result : managed.ExternalObservation {
305+ ResourceExists : true ,
306+ ResourceUpToDate : true ,
307+ ResourceLateInitialized : false ,
308+ },
309+ err : nil ,
310+ },
311+ },
312+ "SuccessfulWithoutAppProject" : {
313+ args : args {
314+ client : withMockClient (t , func (mcs * mockclient.MockRepositoryServiceClient ) {
315+ mcs .EXPECT ().Get (
316+ context .Background (),
317+ & argocdRepository.RepoQuery {
318+ Repo : testRepositoryExternalName ,
319+ },
320+ ).Return (
321+ & argocdv1alpha1.Repository {
322+ Repo : testRepo ,
323+ Name : testRepositoryExternalName ,
324+ }, nil )
325+ }),
326+ cr : Repository (
327+ withExternalName (testRepositoryExternalName ),
328+ withSpec (v1alpha1.RepositoryParameters {
329+ Name : ptr .To (testRepositoryExternalName ),
330+ Repo : testRepo ,
331+ Project : nil , // Explicitly nil
332+ Insecure : & testInsecure ,
333+ EnableLFS : & testEnableLFS ,
334+ InheritedCreds : & testInheritedCreds ,
335+ EnableOCI : & testEnableOCI ,
336+ }),
337+ ),
338+ },
339+ want : want {
340+ cr : Repository (
341+ withExternalName (testRepositoryExternalName ),
342+ withSpec (v1alpha1.RepositoryParameters {
343+ Name : ptr .To (testRepositoryExternalName ),
344+ Repo : testRepo ,
345+ Project : nil ,
346+ Insecure : & testInsecure ,
347+ EnableLFS : & testEnableLFS ,
348+ InheritedCreds : & testInheritedCreds ,
349+ EnableOCI : & testEnableOCI ,
350+ }),
351+ withConditions (xpv1 .Available ()),
352+ withObservation (v1alpha1.RepositoryObservation {
353+ ConnectionState : v1alpha1.ConnectionState {},
354+ }),
355+ ),
356+ result : managed.ExternalObservation {
357+ ResourceExists : true ,
358+ ResourceUpToDate : true ,
359+ ResourceLateInitialized : false ,
360+ },
361+ err : nil ,
362+ },
363+ },
258364 }
259365
260366 for name , tc := range cases {
@@ -551,6 +657,67 @@ func TestDelete(t *testing.T) {
551657 err : errors .Wrap (errBoom , errDeleteFailed ),
552658 },
553659 },
660+ "SuccessfulWithAppProject" : {
661+ args : args {
662+ client : withMockClient (t , func (mcs * mockclient.MockRepositoryServiceClient ) {
663+ mcs .EXPECT ().DeleteRepository (
664+ context .Background (),
665+ & argocdRepository.RepoQuery {
666+ Repo : testRepositoryExternalName ,
667+ AppProject : "test-project" ,
668+ },
669+ ).Return (
670+ & argocdRepository.RepoResponse {}, nil )
671+ }),
672+ cr : Repository (
673+ withExternalName (testRepositoryExternalName ),
674+ withSpec (v1alpha1.RepositoryParameters {
675+ Repo : testRepositoryExternalName ,
676+ Project : ptr .To ("test-project" ),
677+ }),
678+ ),
679+ },
680+ want : want {
681+ cr : Repository (
682+ withExternalName (testRepositoryExternalName ),
683+ withSpec (v1alpha1.RepositoryParameters {
684+ Repo : testRepositoryExternalName ,
685+ Project : ptr .To ("test-project" ),
686+ }),
687+ ),
688+ err : nil ,
689+ },
690+ },
691+ "SuccessfulWithoutAppProject" : {
692+ args : args {
693+ client : withMockClient (t , func (mcs * mockclient.MockRepositoryServiceClient ) {
694+ mcs .EXPECT ().DeleteRepository (
695+ context .Background (),
696+ & argocdRepository.RepoQuery {
697+ Repo : testRepositoryExternalName ,
698+ },
699+ ).Return (
700+ & argocdRepository.RepoResponse {}, nil )
701+ }),
702+ cr : Repository (
703+ withExternalName (testRepositoryExternalName ),
704+ withSpec (v1alpha1.RepositoryParameters {
705+ Repo : testRepositoryExternalName ,
706+ Project : nil , // Explicitly nil
707+ }),
708+ ),
709+ },
710+ want : want {
711+ cr : Repository (
712+ withExternalName (testRepositoryExternalName ),
713+ withSpec (v1alpha1.RepositoryParameters {
714+ Repo : testRepositoryExternalName ,
715+ Project : nil ,
716+ }),
717+ ),
718+ err : nil ,
719+ },
720+ },
554721 }
555722
556723 for name , tc := range cases {
0 commit comments