Radish alpha
r
rad:z2UcCU1LgMshWvXj6hXSDDrwB8q8M
Radicle Job Collaborative Object
Radicle
Git
docs: add a doc test to library, for documetation
Lars Wirzenius committed 11 months ago
commit 7cd8b06c07612e2f29c9969add95be7c0a762d6c
parent b41229c
1 file changed +42 -1
modified src/lib.rs
@@ -1,3 +1,44 @@
+
//! Radicle "job COB".
+
//!
+
//! # Example
+
//!
+
//! ```
+
//! # use radicle::crypto::Signer;
+
//! # use radicle::git::{raw::Repository, Oid};
+
//! # use radicle::test;
+
//! # use url::Url;
+
//! # use uuid::Uuid;
+
//! #
+
//! # use radicle_job::{Jobs, Run, Runs, Reason};
+
//! #
+
//! # fn commit(repo: &Repository) -> Oid {
+
//! #     let tree = {
+
//! #         let tree = repo.treebuilder(None).unwrap();
+
//! #         let oid = tree.write().unwrap();
+
//! #         repo.find_tree(oid).unwrap()
+
//! #     };
+
//! #
+
//! #     let author = repo.signature().unwrap();
+
//! #     repo.commit(None, &author, &author, "Test Commit", &tree, &[])
+
//! #         .unwrap()
+
//! #         .into()
+
//! # }
+
//! #
+
//! # let test::setup::NodeWithRepo {
+
//! #     node: alice, repo, ..
+
//! # } = test::setup::NodeWithRepo::default();
+
//! # let oid = commit(&repo.backend);
+
//! # let repo = (&*repo).clone();
+
//! let mut jobs = Jobs::open(repo).unwrap();
+
//! #
+
//! # let test::setup::NodeWithRepo { node: bob, .. } = test::setup::NodeWithRepo::default();
+
//! let mut job = jobs.create(oid, &alice.signer).unwrap();
+
//! #
+
//! let uuid = Uuid::new_v4();
+
//! let log = Url::parse(&format!("https://example.com/ci/logs?run={}", uuid)).unwrap();
+
//! job.run(uuid, log, &alice.signer).unwrap();
+
//! ```
+

use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
use std::str::FromStr;
@@ -381,7 +422,7 @@ pub struct Run {
}

impl Run {
-
    fn new(log: Url) -> Self {
+
    pub fn new(log: Url) -> Self {
        Self {
            status: Status::Started,
            log,