Files
gocryptotrader/connchecker/connchecker_test.go
Ryan O'Hara-Reid 8279a036c2 Connection checker update (#294)
* Adds logic to ensure nothing proceeds a connectivity check and adds tests

* Adds waitgroup to verify monitor routine startup before shutdown is called thus eliminating race condition

* fix func desc and test func naming convention

* Add invalid address check

* Fix race condition for okgroup on wait group when instant shutdown called

* Fix fmt issue with gofmt
2019-05-13 12:02:39 +10:00

38 lines
727 B
Go

package connchecker
import (
"testing"
)
func TestConnection(t *testing.T) {
faultyDomain := []string{"faultyIP"}
faultyHost := []string{"faultyHost"}
_, err := New(faultyDomain, nil, 100000)
if err == nil {
t.Fatal("Test Failed - New error cannot be nil")
}
_, err = New(DefaultDNSList, nil, 100000)
if err != nil {
t.Fatal("Test Failed - New error", err)
}
_, err = New(nil, faultyHost, 100000)
if err != nil {
t.Fatal("Test Failed - New error cannot be nil", err)
}
c, err := New(nil, nil, 0)
if err != nil {
t.Fatal("Test Failed - New error", err)
}
if !c.IsConnected() {
t.Log("Test - No internet connection found")
} else {
t.Log("Test - Internet connection found")
}
c.Shutdown()
}