mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-10-30 20:08:41 +08:00
The test context is cancelled when the test ends, so anything still holding it stops instead of leaking into the next test. Uses inside `t.Cleanup`, `defer` and `go func` blocks are left alone, as the context is already cancelled there. Stacked on https://gitea.com/gitea/runner/pulls/1305. Assisted-by: Codet Co-authored-by: bircni <bircni@icloud.com> Reviewed-on: https://gitea.com/gitea/runner/pulls/1306 Reviewed-by: bircni <bircni@icloud.com>
21 lines
472 B
Go
21 lines
472 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package envcheck
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCheckIfDockerRunningReturnsPingError(t *testing.T) {
|
|
ctx, cancel := context.WithCancel(t.Context())
|
|
cancel()
|
|
|
|
err := CheckIfDockerRunning(ctx, "unix:///definitely/missing/docker.sock")
|
|
require.Error(t, err)
|
|
require.Contains(t, err.Error(), "cannot ping the docker daemon")
|
|
}
|