From 00daaca6f40a75fa2db6d134aa64758da78f6d72 Mon Sep 17 00:00:00 2001 From: Sandro-Alessio Gierens Date: Sat, 16 Mar 2024 22:51:15 +0100 Subject: [PATCH] test(block_storage): add integration test_volume_create_get_delete_simple Signed-off-by: Sandro-Alessio Gierens --- tests/integration-block-storage.rs | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/integration-block-storage.rs diff --git a/tests/integration-block-storage.rs b/tests/integration-block-storage.rs new file mode 100644 index 0000000000..1b99f8b670 --- /dev/null +++ b/tests/integration-block-storage.rs @@ -0,0 +1,52 @@ +// Copyright 2024 Sandro-Alessio Gierens +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use std::sync::Once; + +static INIT: Once = Once::new(); + +async fn set_up() -> openstack::Cloud { + INIT.call_once(|| { + env_logger::init(); + }); + + openstack::Cloud::from_env() + .await + .expect("Failed to create an identity provider from the environment") +} + +#[tokio::test] +async fn test_volume_create_get_delete_simple() { + let os = set_up().await; + + let volume = os + .new_volume(1 as u64) + .create() + .await + .expect("Could not create volume"); + let id = volume.id().clone(); + assert_eq!(volume.name(), ""); + assert_eq!(*volume.size(), 1 as u64); + + let volume2 = os + .get_volume(&id) + .await + .expect("Could not get volume"); + assert_eq!(volume2.id(), volume.id()); + + volume.delete().await.expect("Could not delete volume"); + + let volume3 = os.get_volume(id).await; + assert!(volume3.is_err()); +}