Skip to content

Commit

Permalink
test(block_storage): add integration test_volume_create_get_delete_si…
Browse files Browse the repository at this point in the history
…mple

Signed-off-by: Sandro-Alessio Gierens <[email protected]>
  • Loading branch information
gierens committed Mar 16, 2024
1 parent fcf7eee commit 00daaca
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/integration-block-storage.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2024 Sandro-Alessio Gierens <[email protected]>
//
// 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());
}

0 comments on commit 00daaca

Please sign in to comment.