mirror of
https://github.com/docker/compose.git
synced 2026-08-31 06:49:15 +00:00
test: replace context.Background()/context.TODO() with t.Context()
Replace manual context creation with t.Context() which is automatically cancelled when the test completes. Go 1.24 modernization pattern. Assisted-By: cagent Signed-off-by: David Gageot <david.gageot@docker.com>
This commit is contained in:
parent
b92b87dd9c
commit
093205121c
19 changed files with 56 additions and 96 deletions
|
|
@ -18,7 +18,6 @@ package compose
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
|
@ -244,16 +243,11 @@ services:
|
|||
}
|
||||
|
||||
// Set up the context with necessary environment variables
|
||||
ctx := context.Background()
|
||||
_ = os.Setenv("TEST_VAR", "test-value")
|
||||
_ = os.Setenv("API_KEY", "123456")
|
||||
defer func() {
|
||||
_ = os.Unsetenv("TEST_VAR")
|
||||
_ = os.Unsetenv("API_KEY")
|
||||
}()
|
||||
t.Setenv("TEST_VAR", "test-value")
|
||||
t.Setenv("API_KEY", "123456")
|
||||
|
||||
// Extract variables from the model
|
||||
info, noVariables, err := extractInterpolationVariablesFromModel(ctx, cli, projectOptions, []string{})
|
||||
info, noVariables, err := extractInterpolationVariablesFromModel(t.Context(), cli, projectOptions, []string{})
|
||||
require.NoError(t, err)
|
||||
require.False(t, noVariables)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue