mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-26 18:20:59 +00:00
chore: use t.Context for tests, activate usetesting for lint + add t.TempDir and t.Chdir (#844)
<!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/844): <!--number 844 --><!--line 0 --><!--description Y2hvcmU6IHVzZSB0LkNvbnRleHQgZm9yIHRlc3RzLCBhY3RpdmF0ZSB1c2V0ZXN0aW5nIGZvciBsaW50ICsgYWRkIHQuVGVtcERpciBhbmQgdC5DaGRpciBbc2tpcCBjYXNjYWRlXQ==-->chore: use t.Context for tests, activate usetesting for lint + add t.TempDir and t.Chdir [skip cascade]<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/844 Reviewed-by: Gusted <gusted@noreply.code.forgejo.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
parent
66bb63ea18
commit
0520ff4e05
22 changed files with 126 additions and 153 deletions
|
@ -26,7 +26,7 @@ func TestDocker(t *testing.T) {
|
|||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
client, err := GetDockerClient(ctx)
|
||||
assert.NoError(t, err)
|
||||
defer client.Close()
|
||||
|
@ -152,7 +152,7 @@ func TestDockerExecAbort(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDockerExecFailure(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
conn := &mockConn{}
|
||||
|
||||
|
@ -183,7 +183,7 @@ func TestDockerExecFailure(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDockerCopyTarStream(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
conn := &mockConn{}
|
||||
|
||||
|
@ -205,7 +205,7 @@ func TestDockerCopyTarStream(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDockerCopyTarStreamErrorInCopyFiles(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
conn := &mockConn{}
|
||||
|
||||
|
@ -230,7 +230,7 @@ func TestDockerCopyTarStreamErrorInCopyFiles(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDockerCopyTarStreamErrorInMkdir(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
conn := &mockConn{}
|
||||
|
||||
|
@ -318,7 +318,7 @@ func TestCheckVolumes(t *testing.T) {
|
|||
for _, tc := range testCases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
logger, _ := test.NewNullLogger()
|
||||
ctx := common.WithLogger(context.Background(), logger)
|
||||
ctx := common.WithLogger(t.Context(), logger)
|
||||
cr := &containerReference{
|
||||
input: &NewContainerInput{
|
||||
ValidVolumes: tc.validVolumes,
|
||||
|
@ -379,7 +379,7 @@ func TestMergeJobOptions(t *testing.T) {
|
|||
JobOptions: testCase.options,
|
||||
},
|
||||
}
|
||||
config, hostConfig, err := cr.mergeJobOptions(context.Background(), &container.Config{}, &container.HostConfig{})
|
||||
config, hostConfig, err := cr.mergeJobOptions(t.Context(), &container.Config{}, &container.HostConfig{})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, testCase.config, config)
|
||||
assert.EqualValues(t, testCase.hostConfig, hostConfig)
|
||||
|
@ -394,7 +394,7 @@ func TestDockerRun_isHealthy(t *testing.T) {
|
|||
NetworkAliases: []string{"servicename"},
|
||||
},
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
makeInspectResponse := func(interval time.Duration, status container.HealthStatus, test []string) container.InspectResponse {
|
||||
return container.InspectResponse{
|
||||
Config: &container.Config{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue