mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
23 lines
405 B
Go
23 lines
405 B
Go
|
package iputils
|
||
|
|
||
|
import (
|
||
|
"regexp"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestExternalIPv4(t *testing.T) {
|
||
|
// Regular expression format for IPv4
|
||
|
IPv4Format := `\.\d{1,3}\.\d{1,3}\b`
|
||
|
test, err := ExternalIPv4()
|
||
|
|
||
|
if err != nil {
|
||
|
t.Errorf("Test check external ipv4 failed with %v", err)
|
||
|
}
|
||
|
|
||
|
valid := regexp.MustCompile(IPv4Format)
|
||
|
|
||
|
if !valid.MatchString(test) {
|
||
|
t.Errorf("Wanted: %v, got: %v", IPv4Format, test)
|
||
|
}
|
||
|
}
|