@@ -6,7 +6,7 @@ use fake::{
66 } ,
77 Fake ,
88} ;
9- use paystack:: CreateCustomerRequestBuilder ;
9+ use paystack:: { CreateCustomerRequestBuilder , UpdateCustomerRequestBuilder } ;
1010
1111use crate :: helpers:: get_paystack_client;
1212
@@ -141,3 +141,54 @@ async fn can_fetch_customer_from_the_integration_with_customer_code() {
141141 assert_eq ! ( & res_data. email, & customer_data. email) ;
142142 assert_eq ! ( & res_data. customer_code, & customer_data. customer_code) ;
143143}
144+
145+ // TODO: find a way to clean up customers in the integration after the test
146+ #[ tokio:: test]
147+ async fn can_modify_customer_information ( ) {
148+ // Arrange
149+ let client = get_paystack_client ( ) ;
150+
151+ // Act
152+ let body = CreateCustomerRequestBuilder :: default ( )
153+ . email ( "test@email.com" . to_string ( ) )
154+ . first_name ( "Old First Name" . to_string ( ) )
155+ . last_name ( "Old Last Name" . to_string ( ) )
156+ . build ( )
157+ . unwrap ( ) ;
158+ let customer = client
159+ . customers
160+ . create_customer ( body)
161+ . await
162+ . expect ( "unable to create customer" ) ;
163+
164+ let customer_data = customer. data . unwrap ( ) ;
165+
166+ // Check that these fields don't exist
167+ assert ! ( customer. status) ;
168+ assert ! ( customer. message. contains( "Customer created" ) ) ;
169+
170+ // update customer
171+ let update_request = UpdateCustomerRequestBuilder :: default ( )
172+ . first_name ( "New First Name" . to_string ( ) )
173+ . last_name ( "New Last Name" . to_string ( ) )
174+ . build ( )
175+ . unwrap ( ) ;
176+ let updated_customer = client
177+ . customers
178+ . update_customer ( customer_data. customer_code , update_request)
179+ . await
180+ . expect ( "unable to update customer" ) ;
181+
182+ // Assert
183+ let updated_customer_data = updated_customer. data . unwrap ( ) ;
184+ assert ! ( updated_customer. status) ;
185+ assert ! ( updated_customer. message. contains( "Customer updated" ) ) ;
186+ assert_eq ! (
187+ updated_customer_data. first_name,
188+ Some ( "New First Name" . to_string( ) )
189+ ) ;
190+ assert_eq ! (
191+ updated_customer_data. last_name,
192+ Some ( "New Last Name" . to_string( ) )
193+ )
194+ }
0 commit comments