1- //! End-to-end tests for node-related commands
1+ #! [ End -to-end tests for node-related commands
22
33use crate :: tests:: e2e:: common:: { run_osvm_command, run_osvm_command_string, output_contains, create_temp_dir, create_mock_config, MockServer } ;
44use predicates:: prelude:: * ;
@@ -8,15 +8,15 @@ use serial_test::serial;
88#[ serial]
99fn test_nodes_list ( ) {
1010 let output = run_osvm_command_string ( & [ "nodes" , "list" ] ) ;
11-
11+
1212 // Verify the output contains expected headers
1313 assert ! ( output_contains( & output, "OSVM - Node Management" ) ) ;
1414 assert ! ( output_contains( & output, "Managed SVM Nodes:" ) ) ;
15-
15+
1616 // The output might show "No nodes are currently managed" if no nodes are configured
1717 // or it might show a list of nodes if some are configured
1818 assert ! (
19- output_contains( & output, "No nodes are currently managed" ) ||
19+ output_contains( & output, "No nodes are currently managed" ) ||
2020 output_contains( & output, "ID" ) && output_contains( & output, "SVM" ) && output_contains( & output, "TYPE" )
2121 ) ;
2222}
@@ -27,15 +27,15 @@ fn test_nodes_list_with_filters() {
2727 // Test with network filter
2828 let output = run_osvm_command_string ( & [ "nodes" , "list" , "--network" , "mainnet" ] ) ;
2929 assert ! ( output_contains( & output, "OSVM - Node Management" ) ) ;
30-
30+
3131 // Test with type filter
3232 let output = run_osvm_command_string ( & [ "nodes" , "list" , "--type" , "validator" ] ) ;
3333 assert ! ( output_contains( & output, "OSVM - Node Management" ) ) ;
34-
34+
3535 // Test with status filter
3636 let output = run_osvm_command_string ( & [ "nodes" , "list" , "--status" , "running" ] ) ;
3737 assert ! ( output_contains( & output, "OSVM - Node Management" ) ) ;
38-
38+
3939 // Test with JSON output
4040 let output = run_osvm_command_string ( & [ "nodes" , "list" , "--json" ] ) ;
4141 // JSON output should start with a curly brace or square bracket
@@ -50,7 +50,7 @@ fn test_nodes_dashboard() {
5050 let assert = run_osvm_command ( )
5151 . args ( & [ "nodes" , "dashboard" ] )
5252 . assert ( ) ;
53-
53+
5454 // The dashboard might not work in a test environment, so we're just checking
5555 // that the command is recognized
5656 assert. stderr ( predicate:: str:: contains ( "Unknown command" ) . not ( ) ) ;
@@ -62,7 +62,7 @@ fn test_nodes_get_invalid() {
6262 let assert = run_osvm_command ( )
6363 . args ( & [ "nodes" , "get" , "invalid_node_id" ] )
6464 . assert ( ) ;
65-
65+
6666 // Verify the command fails with a non-zero exit code
6767 assert. failure ( )
6868 . stderr ( predicate:: str:: contains ( "Node not found" ) . or ( predicate:: str:: contains ( "Error:" ) ) ) ;
@@ -73,16 +73,16 @@ fn test_nodes_get_invalid() {
7373fn test_examples_command ( ) {
7474 // Test the examples command
7575 let output = run_osvm_command_string ( & [ "examples" ] ) ;
76-
76+
7777 // Verify the output contains examples
78- assert ! ( output_contains( & output, "OSVM CLI Examples" ) ||
78+ assert ! ( output_contains( & output, "OSVM CLI Examples" ) ||
7979 output_contains( & output, "Available SVMs in the chain:" ) ||
8080 output_contains( & output, "Basic Commands" ) ) ;
81-
81+
8282 // Test examples with category filter
8383 let output = run_osvm_command_string ( & [ "examples" , "--category" , "basic" ] ) ;
8484 assert ! ( output_contains( & output, "Basic Commands" ) ) ;
85-
85+
8686 // Test listing categories
8787 let output = run_osvm_command_string ( & [ "examples" , "--list-categories" ] ) ;
8888 assert ! ( output_contains( & output, "Available example categories:" ) ) ;
@@ -93,16 +93,16 @@ fn test_examples_command() {
9393fn test_verbose_output ( ) {
9494 // Test with verbose flag
9595 let output = run_osvm_command_string ( & [ "--verbose" , "svm" , "list" ] ) ;
96-
96+
9797 // Verbose output should include JSON RPC URL or other verbose information
98- assert ! ( output_contains( & output, "JSON RPC URL:" ) ||
98+ assert ! ( output_contains( & output, "JSON RPC URL:" ) ||
9999 output_contains( & output, "Available SVMs in the chain:" ) ) ;
100-
100+
101101 // Test with very verbose flag
102102 let output = run_osvm_command_string ( & [ "-vv" , "svm" , "list" ] ) ;
103-
103+
104104 // Very verbose output should include keypair info or other very verbose information
105- assert ! ( output_contains( & output, "Using keypair:" ) ||
105+ assert ! ( output_contains( & output, "Using keypair:" ) ||
106106 output_contains( & output, "Available SVMs in the chain:" ) ) ;
107107}
108108
@@ -111,7 +111,7 @@ fn test_verbose_output() {
111111fn test_no_color_flag ( ) {
112112 // Test with no-color flag
113113 let output = run_osvm_command_string ( & [ "--no-color" , "svm" , "list" ] ) ;
114-
114+
115115 // Output should still contain the expected text, but without color codes
116116 assert ! ( output_contains( & output, "Available SVMs in the chain:" ) ) ;
117117}
@@ -122,10 +122,10 @@ fn test_with_custom_config() {
122122 // Create a temporary directory and config file
123123 let temp_dir = create_temp_dir ( ) ;
124124 let config_path = create_mock_config ( & temp_dir) ;
125-
125+
126126 // Run the command with the config file
127127 let output = run_osvm_command_string ( & [ "-C" , config_path. to_str ( ) . unwrap ( ) , "nodes" , "list" ] ) ;
128-
128+
129129 // Verify the output contains expected headers
130130 assert ! ( output_contains( & output, "OSVM - Node Management" ) ) ;
131131}
@@ -137,10 +137,10 @@ fn test_help_command() {
137137 let assert = run_osvm_command ( )
138138 . arg ( "--help" )
139139 . assert ( ) ;
140-
140+
141141 // Verify the output contains help information
142142 assert. success ( )
143143 . stdout ( predicate:: str:: contains ( "USAGE:" ) )
144144 . stdout ( predicate:: str:: contains ( "FLAGS:" ) )
145145 . stdout ( predicate:: str:: contains ( "SUBCOMMANDS:" ) ) ;
146- }
146+ }
0 commit comments