MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / policy_get_by_version

Function policy_get_by_version

crates/openshell-server/src/persistence/tests.rs:643–679  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

641
642#[tokio::test]
643async fn policy_get_by_version() {
644 let store = test_store().await;
645
646 let policy_v1 = SandboxPolicy::default().encode_to_vec();
647 let policy_v2 = SandboxPolicy {
648 version: 2,
649 ..SandboxPolicy::default()
650 }
651 .encode_to_vec();
652 store
653 .put_policy_revision("p1", "sandbox-1", 1, &policy_v1, "h1")
654 .await
655 .unwrap();
656 store
657 .put_policy_revision("p2", "sandbox-1", 2, &policy_v2, "h2")
658 .await
659 .unwrap();
660
661 let v1 = store
662 .get_policy_by_version("sandbox-1", 1)
663 .await
664 .unwrap()
665 .unwrap();
666 assert_eq!(v1.version, 1);
667 assert_eq!(v1.policy_hash, "h1");
668
669 let v2 = store
670 .get_policy_by_version("sandbox-1", 2)
671 .await
672 .unwrap()
673 .unwrap();
674 assert_eq!(v2.version, 2);
675 assert_eq!(v2.policy_hash, "h2");
676
677 let none = store.get_policy_by_version("sandbox-1", 99).await.unwrap();
678 assert!(none.is_none());
679}
680
681#[tokio::test]
682async fn policy_update_status_and_get_loaded() {

Callers

nothing calls this directly

Calls 3

test_storeFunction · 0.70
put_policy_revisionMethod · 0.45
get_policy_by_versionMethod · 0.45

Tested by

no test coverage detected