@@ -105,49 +105,3 @@ pub enum FailedInState {
105105 /// The `post_scale` hook returned an error.
106106 PostScaling ,
107107}
108-
109- #[ cfg( test) ]
110- mod tests {
111- use rstest:: rstest;
112-
113- use super :: * ;
114- use crate :: {
115- test_utils:: serialize_to_yaml_with_singleton_map, utils:: yaml_from_str_singleton_map,
116- } ;
117-
118- #[ rstest]
119- #[ case:: idle( "idle: {}" , ScalerState :: Idle { } ) ]
120- #[ case:: pre_scaling( "preScaling: {}" , ScalerState :: PreScaling { } ) ]
121- #[ case:: scaling( "scaling:
122- previousReplicas: 42" , ScalerState :: Scaling { previous_replicas: 42 } ) ]
123- #[ case:: post_scaling( "postScaling:
124- previousReplicas: 42" , ScalerState :: PostScaling { previous_replicas: 42 } ) ]
125- #[ case:: failed( "failed:
126- failedIn: PreScaling
127- reason: bruh moment" , ScalerState :: Failed {
128- failed_in: FailedInState :: PreScaling ,
129- reason: "bruh moment" . to_owned( )
130- } ) ]
131- fn parse_state ( #[ case] input : & str , #[ case] expected : ScalerState ) {
132- let parsed: ScalerState =
133- yaml_from_str_singleton_map ( input) . expect ( "invalid test YAML input" ) ;
134- assert_eq ! ( parsed, expected) ;
135- }
136-
137- #[ rstest]
138- #[ case:: idle( ScalerState :: Idle { } , "idle: {}\n " ) ]
139- #[ case:: pre_scaling( ScalerState :: PreScaling { } , "preScaling: {}\n " ) ]
140- #[ case:: scaling( ScalerState :: Scaling { previous_replicas: 42 } , "scaling:
141- previousReplicas: 42\n " ) ]
142- #[ case:: post_scaling( ScalerState :: PostScaling { previous_replicas: 42 } , "postScaling:
143- previousReplicas: 42\n " ) ]
144- #[ case:: failed( ScalerState :: Failed { failed_in: FailedInState :: PreScaling , reason: "bruh moment" . to_owned( ) } , "failed:
145- failedIn: PreScaling
146- reason: bruh moment\n " ) ]
147- fn serialize_state ( #[ case] input : ScalerState , #[ case] expected : & str ) {
148- let serialized =
149- serialize_to_yaml_with_singleton_map ( & input) . expect ( "serialization always passes" ) ;
150-
151- assert_eq ! ( serialized, expected) ;
152- }
153- }
0 commit comments