@@ -67,7 +67,7 @@ if show_feature {
6767}
6868```
6969
70- ## Testing
70+ ## Testing for sdk
7171
7272We have unified integration tests for all our SDKs. Integration test cases are added as submodules for each SDK repo. So
7373be sure to pull submodules first to get the latest integration tests before running tests.
@@ -77,7 +77,25 @@ git pull --recurse-submodules
7777cargo test
7878```
7979
80+ ## Testing for caller
81+
82+ You could do unit testing for each variation:
83+
84+ ``` rust
85+ let fp = FeatureProbe :: new_for_test (" toggle_1" , Value :: Bool (false ));
86+ let u = FPUser :: new (" key" );
87+ assert_eq! (fp . bool_value (" toggle_1" , & u , true ), false );
88+
89+ let mut toggles : HashMap <String , Value > = HashMap :: new ();
90+ toggles . insert (" toggle_2" . to_owned (), json! (12.5 ));
91+ toggles . insert (" toggle_3" . to_owned (), json! (" value" ));
92+ let fp = FeatureProbe :: new_for_tests (toggles );
93+ assert_eq! (fp . number_value (" toggle_2" , & u , 20.0 ), 12.5 );
94+ assert_eq! (fp . string_value (" toggle_3" , & u , " val" . to_owned ()), " value" );
95+ ```
96+
8097## Contributing
98+
8199We are working on continue evolving FeatureProbe core, making it flexible and easier to use.
82100Development of FeatureProbe happens in the open on GitHub, and we are grateful to the
83101community for contributing bugfixes and improvements.
0 commit comments