diff --git a/storage/2020-08-04/blob/blobs/resource_id_test.go b/storage/2020-08-04/blob/blobs/resource_id_test.go index eb453b8..c156b55 100644 --- a/storage/2020-08-04/blob/blobs/resource_id_test.go +++ b/storage/2020-08-04/blob/blobs/resource_id_test.go @@ -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{ diff --git a/storage/2023-11-03/blob/blobs/resource_id_test.go b/storage/2023-11-03/blob/blobs/resource_id_test.go index fe60fd9..d8fc21e 100644 --- a/storage/2023-11-03/blob/blobs/resource_id_test.go +++ b/storage/2023-11-03/blob/blobs/resource_id_test.go @@ -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{