MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / test_ifttt_integration

Function test_ifttt_integration

chirpstack/src/api/application.rs:3172–3299  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3170
3171 #[tokio::test]
3172 async fn test_ifttt_integration() {
3173 let _guard = test::prepare().await;
3174 let app = get_application().await;
3175 let u = get_user().await;
3176 let service = Application::new(RequestValidator::new());
3177
3178 // create
3179 let create_req = get_request(
3180 &u.id,
3181 api::CreateIftttIntegrationRequest {
3182 integration: Some(api::IftttIntegration {
3183 application_id: app.id.to_string(),
3184 key: "verysecret".into(),
3185 uplink_values: vec!["value_1".into(), "value_2".into()],
3186 arbitrary_json: false,
3187 event_prefix: "foo".to_string(),
3188 }),
3189 },
3190 );
3191 let _ = service.create_ifttt_integration(create_req).await.unwrap();
3192
3193 // get
3194 let get_req = get_request(
3195 &u.id,
3196 api::GetIftttIntegrationRequest {
3197 application_id: app.id.to_string(),
3198 },
3199 );
3200 let get_resp = service.get_ifttt_integration(get_req).await.unwrap();
3201 let get_resp = get_resp.get_ref();
3202 assert_eq!(
3203 Some(api::IftttIntegration {
3204 application_id: app.id.to_string(),
3205 key: "verysecret".into(),
3206 uplink_values: vec!["value_1".into(), "value_2".into()],
3207 arbitrary_json: false,
3208 event_prefix: "foo".to_string(),
3209 }),
3210 get_resp.integration
3211 );
3212
3213 // update
3214 let update_req = get_request(
3215 &u.id,
3216 api::UpdateIftttIntegrationRequest {
3217 integration: Some(api::IftttIntegration {
3218 application_id: app.id.to_string(),
3219 key: "verysecrettoo".into(),
3220 uplink_values: vec!["value_4".into(), "value_5".into()],
3221 arbitrary_json: true,
3222 event_prefix: "bar".to_string(),
3223 }),
3224 },
3225 );
3226 let _ = service.update_ifttt_integration(update_req).await.unwrap();
3227
3228 // get
3229 let get_req = get_request(

Callers

nothing calls this directly

Calls 12

prepareFunction · 0.85
get_applicationFunction · 0.85
to_stringMethod · 0.80
unwrapMethod · 0.80
get_ifttt_integrationMethod · 0.80
list_integrationsMethod · 0.80
get_userFunction · 0.70
get_requestFunction · 0.70
intoMethod · 0.45

Tested by

no test coverage detected