MCPcopy
hub / github.com/wavetermdev/waveterm / TestParseURI_S3BucketOnly

Function TestParseURI_S3BucketOnly

pkg/remote/connparse/connparse_test.go:448–484  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

446}
447
448func TestParseURI_S3BucketOnly(t *testing.T) {
449 t.Parallel()
450
451 testUri := func(cstr string, pathExpected string, pathWithHostExpected string) {
452 c, err := connparse.ParseURI(cstr)
453 if err != nil {
454 t.Fatalf("failed to parse URI: %v", err)
455 }
456 if c.Path != pathExpected {
457 t.Fatalf("expected path to be \"%q\", got \"%q\"", pathExpected, c.Path)
458 }
459 expected := "bucket"
460 if c.Host != expected {
461 t.Fatalf("expected host to be \"%q\", got \"%q\"", expected, c.Host)
462 }
463 pathWithHost := c.GetPathWithHost()
464 if pathWithHost != pathWithHostExpected {
465 t.Fatalf("expected path with host to be \"%q\", got \"%q\"", expected, pathWithHost)
466 }
467 expected = "s3"
468 if c.GetType() != expected {
469 t.Fatalf("expected conn type to be \"%q\", got \"%q\"", expected, c.GetType())
470 }
471 if len(c.GetSchemeParts()) != 2 {
472 t.Fatalf("expected scheme parts to be 2, got %d", len(c.GetSchemeParts()))
473 }
474 fullUri := c.GetFullURI()
475 if fullUri != cstr {
476 t.Fatalf("expected full URI to be \"%q\", got \"%q\"", cstr, fullUri)
477 }
478 }
479
480 t.Log("Testing with no trailing slash")
481 testUri("profile:s3://bucket", "", "bucket")
482 t.Log("Testing with trailing slash")
483 testUri("profile:s3://bucket/", "/", "bucket/")
484}

Callers

nothing calls this directly

Calls 6

ParseURIFunction · 0.92
GetPathWithHostMethod · 0.80
GetTypeMethod · 0.80
GetSchemePartsMethod · 0.80
GetFullURIMethod · 0.80
LogMethod · 0.80

Tested by

no test coverage detected