@@ -141,159 +141,3 @@ impl Store for MockStore {
141141 todo ! ( )
142142 }
143143}
144-
145- // async fn run_test_with_config_and_stores_for_label(
146- // runtime_config: Option<toml::Table>,
147- // store_types: Vec<impl MakeKeyValueStore>,
148- // labels: Vec<&str>,
149- // ) -> anyhow::Result<TestFactorsInstanceState> {
150- // let mut test_resolver = RuntimeConfigResolver::new();
151- // for store_type in store_types {
152- // test_resolver.register_store_type(store_type)?;
153- // }
154- // let test_resolver = Arc::new(test_resolver);
155- // let factors = TestFactors {
156- // key_value: KeyValueFactor::new(),
157- // };
158- // let labels_clone = labels.clone();
159- // let env = TestEnvironment::new(factors)
160- // .extend_manifest(toml! {
161- // [component.test-component]
162- // source = "does-not-exist.wasm"
163- // key_value_stores = labels_clone
164- // })
165- // .runtime_config(TomlConfig::new(test_resolver, runtime_config))?;
166- // let state = env.build_instance_state().await?;
167- // assert_eq!(
168- // labels,
169- // state.key_value.allowed_stores().iter().collect::<Vec<_>>()
170- // );
171-
172- // Ok(state)
173- // }
174-
175- // #[tokio::test]
176- // async fn overridden_default_key_value_works() -> anyhow::Result<()> {
177- // let runtime_config = toml::toml! {
178- // [key_value_store.default]
179- // type = "redis"
180- // url = "redis://localhost:6379"
181- // };
182- // run_test_with_config_and_stores_for_label(
183- // Some(runtime_config),
184- // vec![RedisKeyValueStore::new()],
185- // vec!["default"],
186- // )
187- // .await?;
188- // Ok(())
189- // }
190-
191- // #[tokio::test]
192- // async fn custom_spin_key_value_works() -> anyhow::Result<()> {
193- // let runtime_config = toml::toml! {
194- // [key_value_store.custom]
195- // type = "spin"
196- // };
197- // run_test_with_config_and_stores_for_label(
198- // Some(runtime_config),
199- // vec![SpinKeyValueStore::new(None)],
200- // vec!["custom"],
201- // )
202- // .await?;
203- // Ok(())
204- // }
205-
206- // #[tokio::test(flavor = "multi_thread", worker_threads = 1)]
207- // async fn custom_spin_key_value_works_with_absolute_path() -> anyhow::Result<()> {
208- // let tmp_dir = tempfile::TempDir::with_prefix("example")?;
209- // let db_path = tmp_dir.path().join("foo/custom.db");
210- // // Check that the db does not exist yet - it will exist by the end of the test
211- // assert!(!db_path.exists());
212-
213- // let path_str = db_path.to_str().unwrap();
214- // let runtime_config = toml::toml! {
215- // [key_value_store.custom]
216- // type = "spin"
217- // path = path_str
218- // };
219- // let mut state = run_test_with_config_and_stores_for_label(
220- // Some(runtime_config),
221- // vec![SpinKeyValueStore::new(Some(
222- // std::env::current_dir().context("failed to get current directory")?,
223- // ))],
224- // vec!["custom"],
225- // )
226- // .await?;
227-
228- // // Actually et a key since store creation is lazy
229- // let store = state.key_value.open("custom".to_owned()).await??;
230- // let _ = state.key_value.get(store, "foo".to_owned()).await??;
231-
232- // // Check that the parent has been created
233- // assert!(db_path.exists());
234- // Ok(())
235- // }
236-
237- // #[tokio::test(flavor = "multi_thread", worker_threads = 1)]
238- // async fn custom_spin_key_value_works_with_relative_path() -> anyhow::Result<()> {
239- // let tmp_dir = tempfile::TempDir::with_prefix("example")?;
240- // let db_path = tmp_dir.path().join("custom.db");
241- // // Check that the db does not exist yet - it will exist by the end of the test
242- // assert!(!db_path.exists());
243-
244- // let runtime_config = toml::toml! {
245- // [key_value_store.custom]
246- // type = "spin"
247- // path = "custom.db"
248- // };
249- // let mut state = run_test_with_config_and_stores_for_label(
250- // Some(runtime_config),
251- // vec![SpinKeyValueStore::new(Some(tmp_dir.path().to_owned()))],
252- // vec!["custom"],
253- // )
254- // .await?;
255-
256- // // Actually et a key since store creation is lazy
257- // let store = state.key_value.open("custom".to_owned()).await??;
258- // let _ = state.key_value.get(store, "foo".to_owned()).await??;
259-
260- // // Check that the correct store in the config was chosen by verifying the existence of the DB
261- // assert!(db_path.exists());
262- // Ok(())
263- // }
264-
265- // #[tokio::test]
266- // async fn custom_redis_key_value_works() -> anyhow::Result<()> {
267- // let runtime_config = toml::toml! {
268- // [key_value_store.custom]
269- // type = "redis"
270- // url = "redis://localhost:6379"
271- // };
272- // run_test_with_config_and_stores_for_label(
273- // Some(runtime_config),
274- // vec![RedisKeyValueStore::new()],
275- // vec!["custom"],
276- // )
277- // .await?;
278- // Ok(())
279- // }
280-
281- // #[tokio::test]
282- // async fn misconfigured_spin_key_value_fails() -> anyhow::Result<()> {
283- // let tmp_dir = tempfile::TempDir::with_prefix("example")?;
284- // let runtime_config = toml::toml! {
285- // [key_value_store.custom]
286- // type = "spin"
287- // path = "/$$&/bad/path/foo.db"
288- // };
289- // let result = run_test_with_config_and_stores_for_label(
290- // Some(runtime_config),
291- // vec![SpinKeyValueStore::new(Some(tmp_dir.path().to_owned()))],
292- // vec!["custom"],
293- // )
294- // .await;
295- // // TODO(rylev): This only fails on my machine due to a read-only file system error.
296- // // We should consider adding a check for the error message.
297- // assert!(result.is_err());
298- // Ok(())
299- // }
0 commit comments