첫 커밋: 로컬 프로젝트 업로드
This commit is contained in:
34
baron-sso/backend/internal/testsupport/env.go
Normal file
34
baron-sso/backend/internal/testsupport/env.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package testsupport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"github.com/testcontainers/testcontainers-go"
|
||||
)
|
||||
|
||||
// PortBindingAvailable reports whether this environment can bind a local TCP listener.
|
||||
func PortBindingAvailable() bool {
|
||||
ln, err := net.Listen("tcp4", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
_ = ln.Close()
|
||||
return true
|
||||
}
|
||||
|
||||
// DockerAvailable reports whether Testcontainers can talk to a Docker provider.
|
||||
func DockerAvailable() bool {
|
||||
defer func() {
|
||||
_ = recover()
|
||||
}()
|
||||
|
||||
provider, err := testcontainers.ProviderDocker.GetProvider()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if err := provider.Health(context.Background()); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user