Skip to content

Commit b05902e

Browse files
committed
fix tests
Signed-off-by: Jan Zachmann <[email protected]>
1 parent 9eb529f commit b05902e

File tree

2 files changed

+20
-53
lines changed

2 files changed

+20
-53
lines changed

src/twin/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use firmware_update::update_validation::UpdateValidation;
3131
use futures::stream;
3232
use futures_util::StreamExt;
3333
use log::{error, info, warn};
34-
use serde_json::{json, Value};
34+
use serde_json::json;
3535
use signal_hook::consts::TERM_SIGNALS;
3636
use signal_hook_tokio::Signals;
3737
use std::{
@@ -139,10 +139,10 @@ impl Twin {
139139
Ok(twin)
140140
}
141141

142-
fn feature_info(&self) -> serde_json::Map<K, V> {
142+
fn feature_info(&self) -> serde_json::Value {
143143
let mut features = serde_json::Map::new();
144144

145-
// report feature availability and version
145+
// report feature availability and version
146146
for f in self.features.values() {
147147
let value = if f.is_enabled() {
148148
json!({ "version": f.version() })
@@ -153,7 +153,7 @@ impl Twin {
153153
features.insert(f.name(), value);
154154
}
155155

156-
features
156+
serde_json::Value::Object(features)
157157
}
158158

159159
async fn connect_twin(&mut self) -> Result<()> {

src/twin/mod_test.rs

Lines changed: 16 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,21 @@ pub mod mod_test {
457457

458458
let expect = |mock: &mut MockMyIotHub| {
459459
mock.expect_twin_report()
460-
.with(eq(json!({"system_info":{"version":1,}})))
460+
.with(eq(json!({
461+
"device_update_consent": {"version": 1},
462+
"factory_reset": null,
463+
"firmware_update": {"version": 1},
464+
"modem_info": null,
465+
"network_status": {"version": 3},
466+
"provisioning_config": {"version": 1},
467+
"reboot": {"version": 2},
468+
"ssh_tunnel": {"version": 2},
469+
"system_info": {"version": 1},
470+
"wifi_commissioning": null,
471+
})))
461472
.times(1)
462473
.returning(|_| Ok(()));
474+
463475
let s = IotHubClient::sdk_version_string();
464476
mock.expect_twin_report()
465477
.with(eq(json!({"system_info":{
@@ -474,21 +486,6 @@ pub mod mod_test {
474486
.times(1)
475487
.returning(|_| Ok(()));
476488

477-
mock.expect_twin_report()
478-
.with(eq(json!({ "factory_reset": null })))
479-
.times(1)
480-
.returning(|_| Ok(()));
481-
482-
mock.expect_twin_report()
483-
.with(eq(json!({"ssh_tunnel":{"version":2}})))
484-
.times(1)
485-
.returning(|_| Ok(()));
486-
487-
mock.expect_twin_report()
488-
.with(eq(json!({"firmware_update":{"version":1}})))
489-
.times(1)
490-
.returning(|_| Ok(()));
491-
492489
mock.expect_twin_report()
493490
.with(eq(json!({
494491
"ssh_tunnel":{
@@ -498,21 +495,6 @@ pub mod mod_test {
498495
.times(1)
499496
.returning(|_| Ok(()));
500497

501-
mock.expect_twin_report()
502-
.with(eq(json!({"device_update_consent":{"version":1}})))
503-
.times(1)
504-
.returning(|_| Ok(()));
505-
506-
mock.expect_twin_report()
507-
.with(eq(json!({"modem_info":null})))
508-
.times(1)
509-
.returning(|_| Ok(()));
510-
511-
mock.expect_twin_report()
512-
.with(eq(json!({"network_status":{"version": 3}})))
513-
.times(1)
514-
.returning(|_| Ok(()));
515-
516498
mock.expect_twin_report()
517499
.with(eq(json!({
518500
"network_status":{
@@ -545,16 +527,6 @@ pub mod mod_test {
545527
.times(1)
546528
.returning(|_| Ok(()));
547529

548-
mock.expect_twin_report()
549-
.with(eq(json!({"reboot":{"version":2}})))
550-
.times(1)
551-
.returning(|_| Ok(()));
552-
553-
mock.expect_twin_report()
554-
.with(eq(json!({ "wifi_commissioning": null })))
555-
.times(1)
556-
.returning(|_| Ok(()));
557-
558530
mock.expect_twin_report()
559531
.with(eq(
560532
json!({"wait_online_timeout_secs":{"nanos":0, "secs": 300}}),
@@ -579,11 +551,6 @@ pub mod mod_test {
579551
.times(1)
580552
.returning(|_| Ok(()));
581553

582-
mock.expect_twin_report()
583-
.with(eq(json!({"provisioning_config":{"version": 1}})))
584-
.times(1)
585-
.returning(|_| Ok(()));
586-
587554
mock.expect_twin_report()
588555
.with(eq(json!({
589556
"provisioning_config":{
@@ -632,7 +599,7 @@ pub mod mod_test {
632599
];
633600

634601
let expect = |mock: &mut MockMyIotHub| {
635-
mock.expect_twin_report().times(12).returning(|_| Ok(()));
602+
mock.expect_twin_report().times(3).returning(|_| Ok(()));
636603
};
637604

638605
let test = |test_attr: &mut TestConfig| {
@@ -656,7 +623,7 @@ pub mod mod_test {
656623
];
657624

658625
let expect = |mock: &mut MockMyIotHub| {
659-
mock.expect_twin_report().times(20).returning(|_| Ok(()));
626+
mock.expect_twin_report().times(11).returning(|_| Ok(()));
660627

661628
mock.expect_twin_report()
662629
.with(eq(json!({
@@ -732,7 +699,7 @@ pub mod mod_test {
732699
let test_dirs = vec!["testfiles/positive/test_component"];
733700

734701
let expect = |mock: &mut MockMyIotHub| {
735-
mock.expect_twin_report().times(20).returning(|_| Ok(()));
702+
mock.expect_twin_report().times(11).returning(|_| Ok(()));
736703
};
737704

738705
let test = |test_attr: &mut TestConfig| {

0 commit comments

Comments
 (0)