Skip to content

Commit 392cfcf

Browse files
committed
Fix unit tests following mapper bridge changes
Signed-off-by: James Rhodes <jarhodes314@gmail.com>
1 parent 556a661 commit 392cfcf

File tree

8 files changed

+16
-2
lines changed

8 files changed

+16
-2
lines changed

crates/common/tedge_config/src/tedge_config_cli/tedge_config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,14 +454,15 @@ define_tedge_config! {
454454
},
455455

456456
#[tedge_config(default(value = false))]
457-
#[doku(skip)]
457+
#[doku(skip)] // Hide the configuration in `tedge config list --doc`
458458
in_mapper: bool,
459459

460460
// TODO validation
461461
/// The topic prefix that will be used for the mapper bridge MQTT topic. For instance,
462462
/// if this is set to "c8y", then messages published to `c8y/s/us` will be
463463
/// forwarded by to Cumulocity on the `s/us` topic
464464
#[tedge_config(example = "c8y", default(value = "c8y"))]
465+
#[doku(skip)] // Hide the configuration in `tedge config list --doc`
465466
topic_prefix: TopicPrefix,
466467
},
467468

@@ -817,9 +818,11 @@ define_tedge_config! {
817818
}
818819

819820
impl ReadableKey {
821+
// This is designed to be simple way of
820822
pub fn is_printable_value(self, value: &str) -> bool {
821823
match self {
822824
Self::C8yBridgeInMapper => value != "false",
825+
Self::C8yBridgeTopicPrefix => value != "c8y",
823826
_ => true,
824827
}
825828
}

crates/core/c8y_api/src/utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ mod tests {
5050
use mqtt_channel::Topic;
5151
use test_case::test_case;
5252

53+
use crate::utils::bridge::is_c8y_bridge_established;
5354
use crate::utils::bridge::is_c8y_bridge_up;
5455

5556
const C8Y_BRIDGE_HEALTH_TOPIC: &str =
@@ -76,7 +77,7 @@ mod tests {
7677
let topic = Topic::new(topic).unwrap();
7778
let message = Message::new(&topic, payload);
7879

79-
let actual = is_c8y_bridge_up(&message, "tedge-mapper-bridge-c8y");
80+
let actual = is_c8y_bridge_established(&message, "tedge-mapper-bridge-c8y");
8081
assert_eq!(actual, expected);
8182
}
8283
}

crates/core/tedge/src/bridge/aws.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ fn test_bridge_config_from_aws_params() -> anyhow::Result<()> {
126126
notifications_local_only: true,
127127
notification_topic: MOSQUITTO_BRIDGE_TOPIC.into(),
128128
bridge_attempt_unsubscribe: false,
129+
bridge_location: BridgeLocation::Mosquitto,
129130
};
130131

131132
assert_eq!(bridge, expected);

crates/core/tedge/src/bridge/azure.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ fn test_bridge_config_from_azure_params() -> anyhow::Result<()> {
126126
notifications_local_only: true,
127127
notification_topic: MOSQUITTO_BRIDGE_TOPIC.into(),
128128
bridge_attempt_unsubscribe: false,
129+
bridge_location: BridgeLocation::Mosquitto,
129130
};
130131

131132
assert_eq!(bridge, expected);

crates/core/tedge/src/bridge/c8y.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ mod tests {
167167
bridge_keyfile: "./test-private-key.pem".into(),
168168
smartrest_templates: TemplatesSet::try_from(vec!["abc", "def"])?,
169169
include_local_clean_session: AutoFlag::False,
170+
bridge_location: BridgeLocation::Mosquitto,
170171
};
171172

172173
let bridge = BridgeConfig::from(params);
@@ -229,6 +230,7 @@ mod tests {
229230
notifications_local_only: true,
230231
notification_topic: C8Y_BRIDGE_HEALTH_TOPIC.into(),
231232
bridge_attempt_unsubscribe: false,
233+
bridge_location: BridgeLocation::Mosquitto,
232234
};
233235

234236
assert_eq!(bridge, expected);

crates/core/tedge/src/bridge/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ mod test {
173173
notifications_local_only: false,
174174
notification_topic: "test_topic".into(),
175175
bridge_attempt_unsubscribe: false,
176+
bridge_location: BridgeLocation::Mosquitto,
176177
};
177178

178179
let mut serialized_config = Vec::<u8>::new();
@@ -238,6 +239,7 @@ bridge_attempt_unsubscribe false
238239
notifications_local_only: false,
239240
notification_topic: "test_topic".into(),
240241
bridge_attempt_unsubscribe: false,
242+
bridge_location: BridgeLocation::Mosquitto,
241243
};
242244
let mut serialized_config = Vec::<u8>::new();
243245
bridge.serialize(&mut serialized_config)?;
@@ -305,6 +307,7 @@ bridge_attempt_unsubscribe false
305307
notifications_local_only: false,
306308
notification_topic: "test_topic".into(),
307309
bridge_attempt_unsubscribe: false,
310+
bridge_location: BridgeLocation::Mosquitto,
308311
};
309312

310313
let mut buffer = Vec::new();
@@ -442,6 +445,7 @@ bridge_attempt_unsubscribe false
442445
notification_topic: "test_topic".into(),
443446
bridge_attempt_unsubscribe: false,
444447
topics: vec![],
448+
bridge_location: BridgeLocation::Mosquitto,
445449
}
446450
}
447451
}

crates/extensions/c8y_mapper_ext/src/converter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3193,6 +3193,7 @@ pub(crate) mod tests {
31933193
true,
31943194
true,
31953195
"c8y".into(),
3196+
false,
31963197
)
31973198
}
31983199

crates/extensions/c8y_mapper_ext/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,6 +2420,7 @@ pub(crate) async fn spawn_c8y_mapper_actor(
24202420
true,
24212421
true,
24222422
"c8y".into(),
2423+
false,
24232424
);
24242425

24252426
let mut mqtt_builder: SimpleMessageBoxBuilder<MqttMessage, MqttMessage> =

0 commit comments

Comments
 (0)