@@ -8,14 +8,82 @@ use tokio::main;
8
8
#[ main]
9
9
async fn main ( ) {
10
10
/// List all Services.
11
- // let services = ServiceManager::list_all_services("20").await;
11
+ let services = ServiceManager :: list_all_services ( "20" ) . await ;
12
12
13
13
// List all Services by Name and Type.
14
- // let services = ServiceManager::find_service_by_name_and_type("whoami", "web_service").await;
14
+ let services = ServiceManager :: find_service_by_name_and_type ( "whoami" , "web_service" ) . await ;
15
15
16
16
// List all Services by Region.
17
- // let services = ServiceManager::find_service_by_region("oregon", "10").await;
17
+ let services = ServiceManager :: find_service_by_region ( "oregon" , "10" ) . await ;
18
18
19
19
// List all Services by Environment.
20
20
let services = ServiceManager :: find_service_by_environment ( "image" , "10" ) . await ;
21
21
}
22
+
23
+ /// Checks for regression of service management functions
24
+ ///
25
+ /// These checks are there to validate that it is functioning properly
26
+ /// and returning the right results, after which we shall describe each test case.
27
+ /// List all Services.
28
+ ///
29
+ /// This test confirms if the function list_all_services returns all services available.
30
+ ///
31
+ /// #[tokio::test]
32
+ /// async fn test_list_all_services() {
33
+ /// let result = ServiceManager::list_all_services("10").await;
34
+ /// // The result should be Ok().
35
+ /// assert!(result.is_ok());
36
+ ///
37
+ /// // Validate content.
38
+ /// let services = result.unwrap();
39
+ /// assert!(!services.is_empty());
40
+ /// }
41
+ ///
42
+ /// #[tokio::test]
43
+ /// async fn test_find_service_by_name_and_type() {
44
+ /// let result = ServiceManager::find_service_by_name_and_type("whoami", "web_service").await;
45
+ /// // The result should be Ok().
46
+ /// assert!(result.is_ok());
47
+ /// // Validate content.
48
+ /// let services = result.unwrap();
49
+ /// assert!(!services.is_empty());
50
+ /// }
51
+ /// More tests...
52
+
53
+ #[ cfg( test) ]
54
+ mod tests {
55
+ use super :: * ;
56
+
57
+ #[ tokio:: test]
58
+ async fn test_list_all_services ( ) {
59
+ let result = ServiceManager :: list_all_services ( "10" ) . await ;
60
+ // The result should be Ok().
61
+ assert ! ( result. is_ok( ) ) ;
62
+
63
+ // Validate content.
64
+ let services = result. unwrap ( ) ;
65
+ assert ! ( !services. is_empty( ) ) ;
66
+ }
67
+
68
+ #[ tokio:: test]
69
+ async fn test_find_service_by_name_and_type ( ) {
70
+ let result = ServiceManager :: find_service_by_name_and_type ( "whoami" , "web_service" ) . await ;
71
+ // The result should be Ok().
72
+ assert ! ( result. is_ok( ) ) ;
73
+
74
+ // Validate content.
75
+ let services = result. unwrap ( ) ;
76
+ assert ! ( !services. is_empty( ) ) ;
77
+ }
78
+
79
+ #[ tokio:: test]
80
+ async fn test_find_service_by_region ( ) {
81
+ let result = ServiceManager :: find_service_by_region ( "oregon" , "10" ) . await ;
82
+ // The result should be Ok().
83
+ assert ! ( result. is_ok( ) ) ;
84
+
85
+ // Validate content.
86
+ let services = result. unwrap ( ) ;
87
+ assert ! ( !services. is_empty( ) ) ;
88
+ }
89
+ }
0 commit comments