@@ -213,21 +213,6 @@ func TestClassifyResourceGroups(t *testing.T) {
213213 assert .Contains (t , res .Skipped [0 ].Reason , "Tier 3" )
214214 })
215215
216- t .Run ("Tier2 tag fetch 404 — already deleted skip" , func (t * testing.T ) {
217- t .Parallel ()
218- opts := ClassifyOptions {
219- EnvName : envName ,
220- GetResourceGroupTags : func (_ context.Context , _ string ) (map [string ]* string , error ) {
221- return nil , makeResponseError (http .StatusNotFound )
222- },
223- }
224- res , err := ClassifyResourceGroups (t .Context (), nil , []string {rgA }, opts )
225- require .NoError (t , err )
226- assert .Empty (t , res .Owned )
227- require .Len (t , res .Skipped , 1 )
228- assert .Contains (t , res .Skipped [0 ].Reason , "already deleted" )
229- })
230-
231216 t .Run ("Tier2 tag fetch 403 — falls to Tier3 non-interactive skip" , func (t * testing.T ) {
232217 t .Parallel ()
233218 opts := ClassifyOptions {
@@ -368,23 +353,23 @@ func TestClassifyResourceGroups(t *testing.T) {
368353
369354 t .Run ("Tier3 non-interactive — unknown skipped without prompt" , func (t * testing.T ) {
370355 t .Parallel ()
371- prompted := false
356+ var prompted atomic. Bool
372357 opts := ClassifyOptions {
373358 EnvName : envName ,
374359 Interactive : false ,
375360 GetResourceGroupTags : func (_ context.Context , _ string ) (map [string ]* string , error ) {
376361 return nil , nil
377362 },
378363 Prompter : func (_ , _ string ) (bool , error ) {
379- prompted = true
364+ prompted . Store ( true )
380365 return true , nil
381366 },
382367 }
383368 res , err := ClassifyResourceGroups (t .Context (), nil , []string {rgA }, opts )
384369 require .NoError (t , err )
385370 assert .Empty (t , res .Owned )
386371 require .Len (t , res .Skipped , 1 )
387- assert .False (t , prompted , "prompter should not be called in non-interactive mode" )
372+ assert .False (t , prompted . Load () , "prompter should not be called in non-interactive mode" )
388373 })
389374
390375 t .Run ("multiple RGs — mix of owned, external, unknown" , func (t * testing.T ) {
@@ -563,7 +548,7 @@ func TestClassifyResourceGroups(t *testing.T) {
563548 t .Run ("Tier4 foreign resources sequential prompt (not concurrent)" , func (t * testing.T ) {
564549 t .Parallel ()
565550 rgOp := "Microsoft.Resources/resourceGroups"
566- promptCount := 0
551+ var promptCount atomic. Int32
567552 opts := ClassifyOptions {
568553 EnvName : envName ,
569554 Interactive : true ,
@@ -573,7 +558,7 @@ func TestClassifyResourceGroups(t *testing.T) {
573558 }, nil
574559 },
575560 Prompter : func (_ , _ string ) (bool , error ) {
576- promptCount ++
561+ promptCount . Add ( 1 )
577562 return false , nil // deny all
578563 },
579564 }
@@ -584,7 +569,7 @@ func TestClassifyResourceGroups(t *testing.T) {
584569 res , err := ClassifyResourceGroups (t .Context (), ops , []string {rgA , rgB }, opts )
585570 require .NoError (t , err )
586571 assert .Empty (t , res .Owned )
587- assert .Equal (t , 2 , promptCount , "both RGs should be prompted sequentially" )
572+ assert .Equal (t , int32 ( 2 ) , promptCount . Load () , "both RGs should be prompted sequentially" )
588573 })
589574
590575 t .Run ("Tier4 500 error treated as veto (fail-safe)" , func (t * testing.T ) {
@@ -1001,6 +986,22 @@ func TestClassifyResourceGroups(t *testing.T) {
1001986 assert .Contains (t , res .Skipped [0 ].Reason , "error during safety check" )
1002987 })
1003988
989+ t .Run ("Tier4 non-azcore network error on resource listing treated as veto (fail-safe)" , func (t * testing.T ) {
990+ t .Parallel ()
991+ opts := ClassifyOptions {
992+ EnvName : envName ,
993+ ListResourceGroupResources : func (_ context.Context , _ string ) ([]* ResourceWithTags , error ) {
994+ return nil , fmt .Errorf ("dial tcp: connection refused" )
995+ },
996+ }
997+ ops := []* armresources.DeploymentOperation {makeOperation ("Create" , rgOp , rgA )}
998+ res , err := ClassifyResourceGroups (t .Context (), ops , []string {rgA }, opts )
999+ require .NoError (t , err )
1000+ assert .Empty (t , res .Owned , "non-azcore error on resource listing should veto" )
1001+ require .Len (t , res .Skipped , 1 )
1002+ assert .Contains (t , res .Skipped [0 ].Reason , "error during safety check" )
1003+ })
1004+
10041005 t .Run ("Tier4 extension resource types skipped in foreign check" , func (t * testing.T ) {
10051006 t .Parallel ()
10061007 opts := ClassifyOptions {
0 commit comments