From 9e028b99163f4e46b3ea976b1126c46bb3a698e9 Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Wed, 12 Feb 2025 15:55:49 -0800 Subject: [PATCH] chore: improves tests --- internal/container/container_store_test.go | 4 +--- internal/web/logs_test.go | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/container/container_store_test.go b/internal/container/container_store_test.go index 6d50a5bc..ce39d7ee 100644 --- a/internal/container/container_store_test.go +++ b/internal/container/container_store_test.go @@ -63,10 +63,8 @@ func TestContainerStore_List(t *testing.T) { Stats: utils.NewRingBuffer[ContainerStat](300), }, nil) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) collector := &fakeStatsCollector{} - store := NewContainerStore(ctx, client, collector, ContainerLabels{}) + store := NewContainerStore(t.Context(), client, collector, ContainerLabels{}) containers, _ := store.ListContainers(ContainerLabels{}) assert.Equal(t, containers[0].ID, "1234") diff --git a/internal/web/logs_test.go b/internal/web/logs_test.go index d40c4752..fe07b93f 100644 --- a/internal/web/logs_test.go +++ b/internal/web/logs_test.go @@ -21,7 +21,7 @@ import ( ) func Test_handler_streamLogs_happy(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) id := "123456" req, err := http.NewRequestWithContext(ctx, "GET", "/api/hosts/localhost/containers/"+id+"/logs/stream", nil)