()
| 137 | |
| 138 | #[test] |
| 139 | fn deploy_user_station() { |
| 140 | let TestEnv { |
| 141 | env, canister_ids, .. |
| 142 | } = setup_new_env(); |
| 143 | |
| 144 | let user_id = user_test_id(0); |
| 145 | |
| 146 | // register user |
| 147 | let register_args = RegisterUserInput { station: None }; |
| 148 | let res: (ApiResult<RegisterUserResponse>,) = update_candid_as( |
| 149 | &env, |
| 150 | canister_ids.control_panel, |
| 151 | user_id, |
| 152 | "register_user", |
| 153 | (register_args,), |
| 154 | ) |
| 155 | .unwrap(); |
| 156 | let user_dto = res.0.unwrap().user; |
| 157 | assert_eq!(user_dto.identity, user_id); |
| 158 | |
| 159 | // deploy user station |
| 160 | let deploy_station_args = DeployStationInput { |
| 161 | name: "station".to_string(), |
| 162 | admins: vec![DeployStationAdminUserInput { |
| 163 | identity: user_id, |
| 164 | username: "admin".to_string(), |
| 165 | }], |
| 166 | associate_with_caller: Some(AssociateWithCallerInput { labels: vec![] }), |
| 167 | subnet_selection: None, |
| 168 | }; |
| 169 | let res: (ApiResult<DeployStationResponse>,) = update_candid_as( |
| 170 | &env, |
| 171 | canister_ids.control_panel, |
| 172 | user_id, |
| 173 | "deploy_station", |
| 174 | (deploy_station_args,), |
| 175 | ) |
| 176 | .unwrap(); |
| 177 | let newly_created_user_station = res.0.unwrap().canister_id; |
| 178 | |
| 179 | // get main station |
| 180 | let res: (ApiResult<ListUserStationsResponse>,) = update_candid_as( |
| 181 | &env, |
| 182 | canister_ids.control_panel, |
| 183 | user_id, |
| 184 | "list_user_stations", |
| 185 | (ListUserStationsInput { |
| 186 | filter_by_labels: None, |
| 187 | },), |
| 188 | ) |
| 189 | .unwrap(); |
| 190 | let main_station_dto = res.0.unwrap().stations[0].clone(); |
| 191 | assert_eq!(main_station_dto.canister_id, newly_created_user_station); |
| 192 | |
| 193 | // the newly created station should be uninitialized at first |
| 194 | let res: (HealthStatus,) = update_candid_as( |
| 195 | &env, |
| 196 | newly_created_user_station, |
nothing calls this directly
no test coverage detected