kanidm/docs/v1.0.0rc10/rustdoc/src/kanidmd_lib/testkit.rs.html
2022-12-15 21:58:21 +00:00

64 lines
5.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `kanidmd/lib/src/testkit.rs`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>testkit.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="../../source-script.js"></script><script defer src="../../source-files.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><div class="width-limiter"><nav class="sub"><a class="sub-logo-container" href="../../kanidmd_lib/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><form class="search-form"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><pre class="src-line-numbers"><span id="1">1</span>
<span id="2">2</span>
<span id="3">3</span>
<span id="4">4</span>
<span id="5">5</span>
<span id="6">6</span>
<span id="7">7</span>
<span id="8">8</span>
<span id="9">9</span>
<span id="10">10</span>
<span id="11">11</span>
<span id="12">12</span>
<span id="13">13</span>
<span id="14">14</span>
<span id="15">15</span>
<span id="16">16</span>
<span id="17">17</span>
<span id="18">18</span>
<span id="19">19</span>
<span id="20">20</span>
<span id="21">21</span>
<span id="22">22</span>
<span id="23">23</span>
<span id="24">24</span>
<span id="25">25</span>
<span id="26">26</span>
<span id="27">27</span>
<span id="28">28</span>
<span id="29">29</span>
<span id="30">30</span>
<span id="31">31</span>
</pre><pre class="rust"><code><span class="kw">use </span><span class="kw">crate</span>::be::{Backend, BackendConfig};
<span class="kw">use </span><span class="kw">crate</span>::prelude::<span class="kw-2">*</span>;
<span class="kw">use </span><span class="kw">crate</span>::schema::Schema;
<span class="attribute">#[allow(unused_imports)]
</span><span class="kw">use </span><span class="kw">crate</span>::utils::duration_from_epoch_now;
<span class="attribute">#[allow(clippy::expect_used)]
</span><span class="kw">pub async fn </span>setup_test() -&gt; QueryServer {
sketching::test_init();
<span class="comment">// Create an in memory BE
</span><span class="kw">let </span>schema_outer = Schema::new().expect(<span class="string">&quot;Failed to init schema&quot;</span>);
<span class="kw">let </span>idxmeta = {
<span class="kw">let </span>schema_txn = schema_outer.write();
schema_txn.reload_idxmeta()
};
<span class="kw">let </span>be = Backend::new(BackendConfig::new_test(), idxmeta, <span class="bool-val">false</span>).expect(<span class="string">&quot;Failed to init BE&quot;</span>);
<span class="comment">// Init is called via the proc macro
</span>QueryServer::new(be, schema_outer, <span class="string">&quot;example.com&quot;</span>.to_string())
}
<span class="attribute">#[allow(clippy::expect_used)]
</span><span class="kw">pub async fn </span>setup_idm_test() -&gt; (IdmServer, IdmServerDelayed) {
<span class="kw">let </span>qs = setup_test().<span class="kw">await</span>;
qs.initialise_helper(duration_from_epoch_now())
.<span class="kw">await
</span>.expect(<span class="string">&quot;init failed!&quot;</span>);
IdmServer::new(qs, <span class="string">&quot;https://idm.example.com&quot;</span>).expect(<span class="string">&quot;Failed to setup idms&quot;</span>)
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="kanidmd_lib" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0 (69f9c33d7 2022-12-12)" ></div></body></html>