Skip to content

test(coderd): close metricscache and avoid background context #7996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Misc fixes
  • Loading branch information
mafredri committed Jun 13, 2023
commit a72d04ce0a943b21e2a2492a84a869deb10c75e8
12 changes: 11 additions & 1 deletion enterprise/replicasync/replicasync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ func TestReplica(t *testing.T) {
db, pubsub := dbtestutil.NewDB(t)
closeChan := make(chan struct{}, 1)
cancel, err := pubsub.Subscribe(replicasync.PubsubEvent, func(ctx context.Context, message []byte) {
closeChan <- struct{}{}
select {
case closeChan <- struct{}{}:
default:
}
})
require.NoError(t, err)
defer cancel()
Expand Down Expand Up @@ -70,6 +73,8 @@ func TestReplica(t *testing.T) {
RelayAddress: "http://169.254.169.254",
})
require.NoError(t, err)
defer server.Close()

require.Len(t, server.Regional(), 1)
require.Equal(t, peer.ID, server.Regional()[0].ID)
require.Empty(t, server.Self().Error)
Expand Down Expand Up @@ -113,6 +118,8 @@ func TestReplica(t *testing.T) {
TLSConfig: tlsConfig,
})
require.NoError(t, err)
defer server.Close()

require.Len(t, server.Regional(), 1)
require.Equal(t, peer.ID, server.Regional()[0].ID)
require.Empty(t, server.Self().Error)
Expand All @@ -138,6 +145,8 @@ func TestReplica(t *testing.T) {
RelayAddress: "http://127.0.0.1:1",
})
require.NoError(t, err)
defer server.Close()

require.Len(t, server.Regional(), 1)
require.Equal(t, peer.ID, server.Regional()[0].ID)
require.NotEmpty(t, server.Self().Error)
Expand All @@ -152,6 +161,7 @@ func TestReplica(t *testing.T) {
defer cancelCtx()
server, err := replicasync.New(ctx, slogtest.Make(t, nil), db, pubsub, nil)
require.NoError(t, err)
defer server.Close()
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}))
Expand Down