From 3ccc80a462ed250006bb40780427dc320e7902cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daian=20YUE=20=F0=9F=90=8F?= Date: Thu, 21 Sep 2023 18:07:27 +0800 Subject: [PATCH] fix: test errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daian YUE 🐏 --- Cargo.toml | 1 - src/api/api.rs | 10 +++------- src/provider/feature_provider.rs | 4 ---- src/provider/no_op_provider.rs | 4 ++-- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 12702ab..53fec9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,5 +14,4 @@ tokio = { version = "1.32.0", features = [ "full" ] } typed-builder = "0.16.1" [dev-dependencies] -mockall = "0.11.4" spec = { path = "spec" } diff --git a/src/api/api.rs b/src/api/api.rs index c2bf5ce..ca5a5c7 100644 --- a/src/api/api.rs +++ b/src/api/api.rs @@ -102,11 +102,7 @@ mod tests { use std::sync::Arc; use super::*; - use crate::{ - provider::{self, *}, - EvaluationContextFieldValue, EvaluationReason, - }; - use mockall::mock; + use crate::{provider::NoOpProvider, EvaluationContextFieldValue, EvaluationReason}; use spec::spec; #[spec( @@ -172,14 +168,14 @@ mod tests { )] #[tokio::test] async fn set_provider_invoke_initialize() { - let mut provider = NoOpProvider::default(); + let provider = NoOpProvider::default(); assert_eq!(provider.metadata().name, "No Operation - Default"); let mut api = OpenFeature::default(); api.set_provider(provider).await; - assert_eq!(provider.metadata().name, "No Operation"); + assert_eq!(api.provider_metadata().await.name, "No Operation"); } #[spec( diff --git a/src/provider/feature_provider.rs b/src/provider/feature_provider.rs index 75dc66a..1ffd224 100644 --- a/src/provider/feature_provider.rs +++ b/src/provider/feature_provider.rs @@ -5,9 +5,6 @@ use crate::{EvaluationContext, EvaluationResult, StructValue}; use super::ResolutionDetails; -#[cfg(test)] -use mockall::{automock, predicate::*}; - // ============================================================ // FeatureProvider // ============================================================ @@ -25,7 +22,6 @@ use mockall::{automock, predicate::*}; /// vendor SDK, embed an REST client, or read flags from a local file. /// /// See the [spec](https://openfeature.dev/specification/sections/providers). -#[cfg_attr(test, automock)] #[async_trait] pub trait FeatureProvider: Send + Sync + 'static { /// The provider MAY define an initialize function which accepts the global evaluation diff --git a/src/provider/no_op_provider.rs b/src/provider/no_op_provider.rs index 23113f8..ea76ad3 100644 --- a/src/provider/no_op_provider.rs +++ b/src/provider/no_op_provider.rs @@ -78,7 +78,7 @@ impl FeatureProvider for NoOpProvider { &self.metadata } - async fn initialize(&mut self, evaluation_context: &EvaluationContext) { + async fn initialize(&mut self, _evaluation_context: &EvaluationContext) { self.metadata = ProviderMetadata::new("No Operation"); } @@ -244,7 +244,7 @@ mod tests { fn metadata_name() { let provider = NoOpProvider::default(); - assert_eq!(provider.metadata().name, "No Operation"); + assert_eq!(provider.metadata().name, "No Operation - Default"); } #[spec(