MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / host_with

Function host_with

libatomic/tests/sandbox_service_test.rs:99–127  ·  view source on GitHub ↗

A repository with two recorded files on `dev`, and a state serving it.

(state: DaemonState)

Source from the content-addressed store, hash-verified

97
98/// A repository with two recorded files on `dev`, and a state serving it.
99fn host_with(state: DaemonState) -> Host {
100 let dir = TempDir::new().unwrap();
101 let root = dir.path().join("repo");
102 {
103 let repo = Repository::init(&root).unwrap();
104 let working_copy = repo.require_working_copy_id().unwrap();
105 write(&root, "README.md", "hello\n");
106 write(&root, "src/lib.rs", "pub fn f() {}\n");
107 repo.add(working_copy, "README.md", TrackingOptions::default())
108 .unwrap();
109 repo.add(working_copy, "src/lib.rs", TrackingOptions::default())
110 .unwrap();
111 record(&repo, "first").unwrap();
112 }
113 let state = Arc::new(state);
114 let repository = state.register(root.clone()).repository_ref();
115 let root = root.canonicalize().unwrap();
116 Host {
117 _dir: dir,
118 root,
119 state,
120 repository,
121 rt: tokio::runtime::Builder::new_multi_thread()
122 .worker_threads(4)
123 .enable_all()
124 .build()
125 .unwrap(),
126 }
127}
128
129impl Host {
130 /// The repository, opened for the closure only: the handlers open it per

Calls 12

repository_refMethod · 0.80
canonicalizeMethod · 0.80
writeFunction · 0.70
recordFunction · 0.70
initFunction · 0.50
unwrapMethod · 0.45
pathMethod · 0.45
addMethod · 0.45
registerMethod · 0.45
cloneMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected