INNER CODE UNIT · Go
PreCheckRoot
terraform-lxd/terraform-provider-lxd · internal/acctest/checks.go:183
func PreCheckRoot(t *testing.T) {
err := exec.Command("sudo", "-n", "true").Run()
if err != nil {
t.Skipf("Test %q skipped. Cannot escalate privilege without a password.", t.Name())
}
}
// PreCheckLocalServerHTTPS skips the test if the LXD server is not reachable over HTTPS.
// Additionally, it returns the server's HTTPS address. If the test remote is a unix
// socket, the local HTTPS address is used instead.
func PreCheckLocalServerHTTPS(t *testing.T) string {
address := testRemotes()[testProviderRemoteName].Address
if strings.HasPrefix(address, "unix://") {
address = "https://127.0.0.1:8443"
}
conn, err := net.DialTimeout("tcp", strings.TrimPrefix(address, "https://"), 1*time.Second)
if err != nil {