@@ -665,7 +665,8 @@ pub async fn assets_routing_works(controller: &dyn Controller) {
665
665
tc. run ( controller) . await . unwrap ( )
666
666
}
667
667
668
- pub async fn simple_spin_rust_works ( controller : & dyn Controller ) {
668
+ /// Test an http app using the current branch's version of the Rust SDK
669
+ pub async fn head_rust_sdk_http ( controller : & dyn Controller ) {
669
670
async fn checks (
670
671
metadata : AppMetadata ,
671
672
_: Option < Pin < Box < dyn AsyncBufRead > > > ,
@@ -719,8 +720,42 @@ pub async fn simple_spin_rust_works(controller: &dyn Controller) {
719
720
}
720
721
721
722
let tc = TestCaseBuilder :: default ( )
722
- . name ( "simple-spin-rust-test" . to_string ( ) )
723
- . appname ( Some ( "simple-spin-rust-test" . to_string ( ) ) )
723
+ . name ( "head-rust-sdk-http" . to_string ( ) )
724
+ . appname ( Some ( "head-rust-sdk-http" . to_string ( ) ) )
725
+ . assertions (
726
+ |metadata : AppMetadata ,
727
+ stdout_stream : Option < Pin < Box < dyn AsyncBufRead > > > ,
728
+ stderr_stream : Option < Pin < Box < dyn AsyncBufRead > > > | {
729
+ Box :: pin ( checks ( metadata, stdout_stream, stderr_stream) )
730
+ } ,
731
+ )
732
+ . build ( )
733
+ . unwrap ( ) ;
734
+
735
+ tc. run ( controller) . await . unwrap ( )
736
+ }
737
+
738
+ /// Test a redis app using the current branch's version of the Rust SDK
739
+ pub async fn head_rust_sdk_redis ( controller : & dyn Controller ) {
740
+ async fn checks (
741
+ _: AppMetadata ,
742
+ _: Option < Pin < Box < dyn AsyncBufRead > > > ,
743
+ stderr_stream : Option < Pin < Box < dyn AsyncBufRead > > > ,
744
+ ) -> Result < ( ) > {
745
+ wait_for_spin ( ) . await ;
746
+ let stderr = get_output_stream ( stderr_stream) . await ?;
747
+ anyhow:: ensure!(
748
+ stderr. is_empty( ) ,
749
+ "expected stderr to be empty, but it was not: {}" ,
750
+ stderr. join( "\n " )
751
+ ) ;
752
+ Ok ( ( ) )
753
+ }
754
+
755
+ let tc = TestCaseBuilder :: default ( )
756
+ . name ( "head-rust-sdk-redis" . to_string ( ) )
757
+ . appname ( Some ( "head-rust-sdk-redis" . to_string ( ) ) )
758
+ . trigger_type ( "redis" . to_string ( ) )
724
759
. assertions (
725
760
|metadata : AppMetadata ,
726
761
stdout_stream : Option < Pin < Box < dyn AsyncBufRead > > > ,
@@ -877,8 +912,7 @@ pub async fn redis_go_works(controller: &dyn Controller) {
877
912
_: Option < Pin < Box < dyn AsyncBufRead > > > ,
878
913
stderr_stream : Option < Pin < Box < dyn AsyncBufRead > > > ,
879
914
) -> Result < ( ) > {
880
- //TODO: wait for spin up to be ready dynamically
881
- sleep ( Duration :: from_secs ( 10 ) ) . await ;
915
+ wait_for_spin ( ) . await ;
882
916
883
917
let output = utils:: run (
884
918
& [
@@ -894,7 +928,7 @@ pub async fn redis_go_works(controller: &dyn Controller) {
894
928
) ?;
895
929
utils:: assert_success ( & output) ;
896
930
897
- let stderr = utils :: get_output_stream ( stderr_stream, Duration :: from_secs ( 5 ) ) . await ?;
931
+ let stderr = get_output_stream ( stderr_stream) . await ?;
898
932
let expected_logs = vec ! [ "Payload::::" , "msg-from-go-channel" ] ;
899
933
900
934
assert ! ( expected_logs
@@ -934,8 +968,7 @@ pub async fn redis_rust_works(controller: &dyn Controller) {
934
968
_: Option < Pin < Box < dyn AsyncBufRead > > > ,
935
969
stderr_stream : Option < Pin < Box < dyn AsyncBufRead > > > ,
936
970
) -> Result < ( ) > {
937
- //TODO: wait for spin up to be ready dynamically
938
- sleep ( Duration :: from_secs ( 20 ) ) . await ;
971
+ wait_for_spin ( ) . await ;
939
972
940
973
utils:: run (
941
974
& [
@@ -950,7 +983,7 @@ pub async fn redis_rust_works(controller: &dyn Controller) {
950
983
None ,
951
984
) ?;
952
985
953
- let stderr = utils :: get_output_stream ( stderr_stream, Duration :: from_secs ( 5 ) ) . await ?;
986
+ let stderr = get_output_stream ( stderr_stream) . await ?;
954
987
955
988
let expected_logs = vec ! [ "msg-from-rust-channel" ] ;
956
989
@@ -1207,3 +1240,14 @@ pub async fn error_messages(controller: &dyn Controller) {
1207
1240
1208
1241
tc. try_run ( controller) . await . unwrap ( ) ;
1209
1242
}
1243
+
1244
+ async fn get_output_stream (
1245
+ stream : Option < Pin < Box < dyn AsyncBufRead > > > ,
1246
+ ) -> anyhow:: Result < Vec < String > > {
1247
+ utils:: get_output_stream ( stream, Duration :: from_secs ( 5 ) ) . await
1248
+ }
1249
+
1250
+ async fn wait_for_spin ( ) {
1251
+ //TODO: wait for spin up to be ready dynamically
1252
+ sleep ( Duration :: from_secs ( 10 ) ) . await ;
1253
+ }
0 commit comments