X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Ftypes_test.go;fp=pkg%2Fcontrol%2Ftypes_test.go;h=eade2aadbe8a724addc9394ed6ddcd626e512927;hb=8b979ab74153ad8c120743e0f6d868baedcb3b32;hp=f29b3db85329d83f56cddb551a52a67a74935308;hpb=e406a34d5547107533e65ddfbb2074e96d77b4b3;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/types_test.go b/pkg/control/types_test.go index f29b3db..eade2aa 100644 --- a/pkg/control/types_test.go +++ b/pkg/control/types_test.go @@ -23,6 +23,35 @@ import ( "testing" ) +func TestRmrEndpoint(t *testing.T) { + + testEp := func(t *testing.T, val string, expect *RmrEndpoint) { + res := NewRmrEndpoint(val) + + if expect == nil && res == nil { + return + } + if res == nil { + testError(t, "Endpoint elems for value %s expected addr %s port %d got nil", val, expect.GetAddr(), expect.GetPort()) + return + } + if expect.GetAddr() != res.GetAddr() || expect.GetPort() != res.GetPort() { + testError(t, "Endpoint elems for value %s expected addr %s port %d got addr %s port %d", val, expect.GetAddr(), expect.GetPort(), res.GetAddr(), res.GetPort()) + } + if expect.String() != res.String() { + testError(t, "Endpoint string for value %s expected %s got %s", val, expect.String(), res.Get()) + } + + } + + testEp(t, "localhost:8080", &RmrEndpoint{"localhost", 8080}) + testEp(t, "127.0.0.1:8080", &RmrEndpoint{"127.0.0.1", 8080}) + testEp(t, "localhost:70000", nil) + testEp(t, "localhost?8080", nil) + testEp(t, "abcdefghijklmnopqrstuvwxyz", nil) + testEp(t, "", nil) +} + func TestAction(t *testing.T) { testActionString := func(t *testing.T, val int, str string) {