in src/parse.rs [227:340]
fn test_parse() {
let cases = [
("file:/path", (ObjectStoreScheme::Local, "path")),
("file:///path", (ObjectStoreScheme::Local, "path")),
("memory:/path", (ObjectStoreScheme::Memory, "path")),
("memory:///", (ObjectStoreScheme::Memory, "")),
("s3://bucket/path", (ObjectStoreScheme::AmazonS3, "path")),
("s3a://bucket/path", (ObjectStoreScheme::AmazonS3, "path")),
(
"https://s3.region.amazonaws.com/bucket",
(ObjectStoreScheme::AmazonS3, ""),
),
(
"https://s3.region.amazonaws.com/bucket/path",
(ObjectStoreScheme::AmazonS3, "path"),
),
(
"https://bucket.s3.region.amazonaws.com",
(ObjectStoreScheme::AmazonS3, ""),
),
(
"https://ACCOUNT_ID.r2.cloudflarestorage.com/bucket",
(ObjectStoreScheme::AmazonS3, ""),
),
(
"https://ACCOUNT_ID.r2.cloudflarestorage.com/bucket/path",
(ObjectStoreScheme::AmazonS3, "path"),
),
(
"abfs://container/path",
(ObjectStoreScheme::MicrosoftAzure, "path"),
),
(
"abfs://file_system@account_name.dfs.core.windows.net/path",
(ObjectStoreScheme::MicrosoftAzure, "path"),
),
(
"abfss://file_system@account_name.dfs.core.windows.net/path",
(ObjectStoreScheme::MicrosoftAzure, "path"),
),
(
"https://account.dfs.core.windows.net",
(ObjectStoreScheme::MicrosoftAzure, ""),
),
(
"https://account.blob.core.windows.net",
(ObjectStoreScheme::MicrosoftAzure, ""),
),
(
"gs://bucket/path",
(ObjectStoreScheme::GoogleCloudStorage, "path"),
),
(
"gs://test.example.com/path",
(ObjectStoreScheme::GoogleCloudStorage, "path"),
),
("http://mydomain/path", (ObjectStoreScheme::Http, "path")),
("https://mydomain/path", (ObjectStoreScheme::Http, "path")),
(
"s3://bucket/foo%20bar",
(ObjectStoreScheme::AmazonS3, "foo bar"),
),
(
"https://foo/bar%20baz",
(ObjectStoreScheme::Http, "bar baz"),
),
(
"file:///bar%252Efoo",
(ObjectStoreScheme::Local, "bar%2Efoo"),
),
(
"abfss://file_system@account.dfs.fabric.microsoft.com/",
(ObjectStoreScheme::MicrosoftAzure, ""),
),
(
"abfss://file_system@account.dfs.fabric.microsoft.com/",
(ObjectStoreScheme::MicrosoftAzure, ""),
),
(
"https://account.dfs.fabric.microsoft.com/",
(ObjectStoreScheme::MicrosoftAzure, ""),
),
(
"https://account.dfs.fabric.microsoft.com/container",
(ObjectStoreScheme::MicrosoftAzure, "container"),
),
(
"https://account.blob.fabric.microsoft.com/",
(ObjectStoreScheme::MicrosoftAzure, ""),
),
(
"https://account.blob.fabric.microsoft.com/container",
(ObjectStoreScheme::MicrosoftAzure, "container"),
),
];
for (s, (expected_scheme, expected_path)) in cases {
let url = Url::parse(s).unwrap();
let (scheme, path) = ObjectStoreScheme::parse(&url).unwrap();
assert_eq!(scheme, expected_scheme, "{s}");
assert_eq!(path, Path::parse(expected_path).unwrap(), "{s}");
}
let neg_cases = [
"unix:/run/foo.socket",
"file://remote/path",
"memory://remote/",
];
for s in neg_cases {
let url = Url::parse(s).unwrap();
assert!(ObjectStoreScheme::parse(&url).is_err());
}
}