Skip to content

Commit

Permalink
Refactored the channel for test
Browse files Browse the repository at this point in the history
  • Loading branch information
4gust committed Feb 26, 2025
1 parent 8e6d3ef commit 7a8eefe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions apps/confidential/confidential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ func TestRefreshInMultipleRequests(t *testing.T) {
return fixedTime
}
var wg sync.WaitGroup
done := make(chan struct{})
// done := make(chan struct{})
ch := make(chan error, 1)

firstTenantChecker := false
Expand Down Expand Up @@ -916,22 +916,16 @@ func TestRefreshInMultipleRequests(t *testing.T) {
}
}()
}
// Wait for all goroutines in a separate goroutine
go func() {
wg.Wait()
close(done)
close(ch)
}()
wg.Wait()
select {
case err := <-ch:
t.Fatal(err)
default:
}
// Wait for all goroutines to complete
<-done
if !secondTenantChecker && !firstTenantChecker {
t.Error("Error should be called at least once")
}
close(ch)
}

func TestRefreshIn(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion apps/managedidentity/managedidentity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ func TestRefreshInMultipleRequests(t *testing.T) {
if !requestChecker {
t.Error("Error should be called at least once")
}

close(ch)
}

func TestShouldRefresh(t *testing.T) {
Expand Down

0 comments on commit 7a8eefe

Please sign in to comment.