Skip to content

Commit

Permalink
additional tests for parsing invalid nested blob resource IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed Mar 18, 2024
1 parent 3d7f148 commit 25a1a6a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions storage/2020-08-04/blob/blobs/resource_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ func TestFormatNestedBlobIDStandard(t *testing.T) {
}
}

func TestParseInvalidBlobIDStandard(t *testing.T) {
input := "https://example1.blob.core.windows.net/blobby.vhd"
actual, err := ParseBlobID(input, "core.windows.net")
if err == nil {
if actual != nil {
t.Fatalf("expected an error but got: %#v", *actual)
} else {
t.Fatalf("expected an error but got no error and a nil result")
}
}
if err.Error() != "expected the path to contain at least 2 segments but got 1" {
t.Fatalf("unexpected error received: %+v", err)
}
}

func TestFormatBlobIDInDNSZone(t *testing.T) {
actual := BlobId{
AccountId: accounts.AccountId{
Expand Down
15 changes: 15 additions & 0 deletions storage/2023-11-03/blob/blobs/resource_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ func TestParseNestedBlobIDStandard(t *testing.T) {
}
}

func TestParseInvalidBlobIDStandard(t *testing.T) {
input := "https://example1.blob.core.windows.net/blobby.vhd"
actual, err := ParseBlobID(input, "core.windows.net")
if err == nil {
if actual != nil {
t.Fatalf("expected an error but got: %#v", *actual)
} else {
t.Fatalf("expected an error but got no error and a nil result")
}
}
if err.Error() != "expected the path to contain at least 2 segments but got 1" {
t.Fatalf("unexpected error received: %+v", err)
}
}

func TestParseBlobIDInADNSZone(t *testing.T) {
input := "https://example1.zone1.blob.storage.azure.net/container1/blob1.vhd"
expected := BlobId{
Expand Down

0 comments on commit 25a1a6a

Please sign in to comment.