mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
26 lines
610 B
Go
26 lines
610 B
Go
package cli
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func Test_hasLocalDnsServerRunning(t *testing.T) {
|
|
start := time.Now()
|
|
hasDns := hasLocalDnsServerRunning()
|
|
t.Logf("Using Windows API takes: %d", time.Since(start).Milliseconds())
|
|
|
|
start = time.Now()
|
|
hasDnsPowershell := hasLocalDnsServerRunningPowershell()
|
|
t.Logf("Using Powershell takes: %d", time.Since(start).Milliseconds())
|
|
|
|
if hasDns != hasDnsPowershell {
|
|
t.Fatalf("result mismatch, want: %v, got: %v", hasDnsPowershell, hasDns)
|
|
}
|
|
}
|
|
|
|
func hasLocalDnsServerRunningPowershell() bool {
|
|
_, err := powershell("Get-Process -Name DNS")
|
|
return err == nil
|
|
}
|