Skip to content

Commit 743cfdf

Browse files
committed
nexus: add type annotations for tests using IpNet
maghemite #533 adds impl PartialEq<rdb_types::Prefix> for oxnet::IpNet, which caused some preexisting type inferences to no longer be resolved unambiguously (now there are multiple PartialEq<T> for oxnet::IpNet). This updates these spots to be explicit about the types being compared. Signed-off-by: Trey Aspelund <[email protected]>
1 parent cb2551d commit 743cfdf

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

nexus/db-queries/src/db/datastore/vpc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3905,21 +3905,21 @@ mod tests {
39053905
assert!(resolved.iter().any(|x| {
39063906
let k = &x.dest;
39073907
let v = &x.target;
3908-
*k == subnet.ipv4_block.0.into()
3908+
*k == IpNet::from(subnet.ipv4_block.0)
39093909
&& match v {
39103910
RouterTarget::VpcSubnet(ip) => {
3911-
*ip == subnet.ipv4_block.0.into()
3911+
*ip == IpNet::from(subnet.ipv4_block.0)
39123912
}
39133913
_ => false,
39143914
}
39153915
}));
39163916
assert!(resolved.iter().any(|x| {
39173917
let k = &x.dest;
39183918
let v = &x.target;
3919-
*k == subnet.ipv6_block.0.into()
3919+
*k == IpNet::from(subnet.ipv6_block.0)
39203920
&& match v {
39213921
RouterTarget::VpcSubnet(ip) => {
3922-
*ip == subnet.ipv6_block.0.into()
3922+
*ip == IpNet::from(subnet.ipv6_block.0)
39233923
}
39243924
_ => false,
39253925
}

nexus/tests/integration_tests/switch_port.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use omicron_common::api::external::{
2323
LinkSpeed, NameOrId, SwitchPort, SwitchPortSettings,
2424
};
2525
use omicron_common::api::external::{ImportExportPolicy, Name};
26+
use oxnet::IpNet;
2627

2728
type ControlPlaneTestContext =
2829
nexus_test_utils::ControlPlaneTestContext<omicron_nexus::Server>;
@@ -229,11 +230,11 @@ async fn test_port_settings_basic_crud(ctx: &ControlPlaneTestContext) {
229230
assert_eq!(ifx0.kind, external::SwitchInterfaceKind::Primary);
230231

231232
let route0 = &created.routes[0];
232-
assert_eq!(route0.dst, "1.2.3.0/24".parse().unwrap());
233+
assert_eq!(route0.dst, IpNet::from_str("1.2.3.0/24").unwrap());
233234
assert_eq!(&route0.gw.to_string(), "1.2.3.4");
234235

235236
let addr0 = &created.addresses[0];
236-
assert_eq!(addr0.address, "203.0.113.10/24".parse().unwrap());
237+
assert_eq!(addr0.address, IpNet::from_str("203.0.113.10/24").unwrap());
237238

238239
// Get the port settings back
239240
let roundtrip: SwitchPortSettings = NexusRequest::object_get(
@@ -271,11 +272,11 @@ async fn test_port_settings_basic_crud(ctx: &ControlPlaneTestContext) {
271272
assert_eq!(ifx0.kind, external::SwitchInterfaceKind::Primary);
272273

273274
let route0 = &roundtrip.routes[0];
274-
assert_eq!(route0.dst, "1.2.3.0/24".parse().unwrap());
275+
assert_eq!(route0.dst, IpNet::from_str("1.2.3.0/24").unwrap());
275276
assert_eq!(&route0.gw.to_string(), "1.2.3.4");
276277

277278
let addr0 = &roundtrip.addresses[0];
278-
assert_eq!(addr0.address, "203.0.113.10/24".parse().unwrap());
279+
assert_eq!(addr0.address, IpNet::from_str("203.0.113.10/24").unwrap());
279280

280281
// Delete port settings
281282
NexusRequest::object_delete(

0 commit comments

Comments
 (0)