MCPcopy
hub / github.com/nats-io/nats.go / TestUrlArgument

Function TestUrlArgument

nats_test.go:427–453  ·  view source on GitHub ↗

This will test that comma separated url strings work properly for the Connect() command.

(t *testing.T)

Source from the content-addressed store, hash-verified

425// This will test that comma separated url strings work properly for
426// the Connect() command.
427func TestUrlArgument(t *testing.T) {
428 check := func(url string, expected []string) {
429 if !reflect.DeepEqual(processUrlString(url), expected) {
430 t.Fatalf("Got wrong response processing URL: %q, RES: %#v\n", url, processUrlString(url))
431 }
432 }
433 // This is normal case
434 oneExpected := []string{"nats://localhost:1222"}
435
436 check("nats://localhost:1222", oneExpected)
437 check("nats://localhost:1222 ", oneExpected)
438 check(" nats://localhost:1222", oneExpected)
439 check(" nats://localhost:1222 ", oneExpected)
440 check("nats://localhost:1222/", oneExpected)
441
442 var multiExpected = []string{
443 "nats://localhost:1222",
444 "nats://localhost:1223",
445 "nats://localhost:1224",
446 }
447
448 check("nats://localhost:1222,nats://localhost:1223,nats://localhost:1224", multiExpected)
449 check("nats://localhost:1222, nats://localhost:1223, nats://localhost:1224", multiExpected)
450 check(" nats://localhost:1222, nats://localhost:1223, nats://localhost:1224 ", multiExpected)
451 check("nats://localhost:1222, nats://localhost:1223 ,nats://localhost:1224", multiExpected)
452 check("nats://localhost:1222/,nats://localhost:1223/,nats://localhost:1224/", multiExpected)
453}
454
455func TestParserPing(t *testing.T) {
456 c := &Conn{}

Callers

nothing calls this directly

Calls 2

processUrlStringFunction · 0.85
FatalfMethod · 0.80

Tested by

no test coverage detected