@@ -341,6 +341,56 @@ func TestSyncInspectionAuthErrorPersistsLastErrorMetadata(t *testing.T) {
341341 }
342342}
343343
344+ func TestClearInspectionAuthErrorClearsMetadataOnlyError (t * testing.T ) {
345+ manager := coreauth .NewManager (nil , nil , nil )
346+ registered , err := manager .Register (context .Background (), & coreauth.Auth {
347+ Provider : "antigravity" ,
348+ ID : "antigravity-user" ,
349+ FileName : "antigravity-user.json" ,
350+ Status : coreauth .StatusActive ,
351+ StatusMessage : "" ,
352+ Unavailable : false ,
353+ Metadata : map [string ]any {
354+ "email" : "user@example.com" ,
355+ "last_error" : map [string ]any {
356+ "code" : "inspection_probe_error" ,
357+ "http_status" : 0 ,
358+ "message" : "antigravity quota unavailable" ,
359+ "retryable" : false ,
360+ },
361+ },
362+ })
363+ if err != nil {
364+ t .Fatalf ("Register auth error = %v" , err )
365+ }
366+
367+ scheduler := & accountInspectionScheduler {h : & Handler {authManager : manager }}
368+ scheduler .clearInspectionAuthError (context .Background (), accountFromAuth (registered ))
369+
370+ var got * coreauth.Auth
371+ for _ , auth := range manager .List () {
372+ if auth .ID == registered .ID {
373+ got = auth
374+ break
375+ }
376+ }
377+ if got == nil {
378+ t .Fatal ("updated auth not found" )
379+ }
380+ if got .LastError != nil {
381+ t .Fatalf ("LastError = %#v, want nil" , got .LastError )
382+ }
383+ if _ , ok := got .Metadata ["last_error" ]; ok {
384+ t .Fatalf ("metadata last_error = %#v, want removed" , got .Metadata ["last_error" ])
385+ }
386+ if got .Status != coreauth .StatusActive || got .StatusMessage != "" || got .Unavailable {
387+ t .Fatalf ("status = %q message=%q unavailable=%v, want active/empty/false" , got .Status , got .StatusMessage , got .Unavailable )
388+ }
389+ if got .Metadata ["email" ] != "user@example.com" {
390+ t .Fatalf ("metadata email = %#v, want preserved" , got .Metadata ["email" ])
391+ }
392+ }
393+
344394func TestAutoActionConfirmationDelaysExecution (t * testing.T ) {
345395 scheduler := & accountInspectionScheduler {}
346396 result := testInspectionResult ("quota" , accountInspectionActionDisable , false , nil , true , "" )
0 commit comments