Skip to content

Commit a9b5f33

Browse files
committed
Merge branch 'join-value-uplink' of https://github.com/swimos/swim-rust into example_app_join_value
2 parents ae82efa + 4246145 commit a9b5f33

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

api/swimos_api/src/lane/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#[cfg(test)]
16+
mod tests;
17+
1518
use std::fmt::{Display, Formatter};
1619

1720
use swimos_form::structural::Tag;
@@ -61,7 +64,10 @@ impl WarpLaneKind {
6164

6265
pub fn uplink_kind(&self) -> UplinkKind {
6366
match self {
64-
WarpLaneKind::Map | WarpLaneKind::DemandMap | WarpLaneKind::JoinMap => UplinkKind::Map,
67+
WarpLaneKind::Map
68+
| WarpLaneKind::DemandMap
69+
| WarpLaneKind::JoinMap
70+
| WarpLaneKind::JoinValue => UplinkKind::Map,
6571
WarpLaneKind::Supply => UplinkKind::Supply,
6672
WarpLaneKind::Spatial => todo!("Spatial uplinks not supported."),
6773
_ => UplinkKind::Value,

api/swimos_api/src/lane/tests.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use crate::agent::UplinkKind;
2+
use crate::lane::WarpLaneKind;
3+
4+
// spatial lanes are omitted as they are unimplemented
5+
const LANE_KINDS: [WarpLaneKind; 8] = [
6+
WarpLaneKind::Command,
7+
WarpLaneKind::Demand,
8+
WarpLaneKind::DemandMap,
9+
WarpLaneKind::Map,
10+
WarpLaneKind::JoinMap,
11+
WarpLaneKind::JoinValue,
12+
WarpLaneKind::Supply,
13+
WarpLaneKind::Value,
14+
];
15+
16+
#[test]
17+
fn uplink_kinds() {
18+
for kind in LANE_KINDS {
19+
let uplink_kind = kind.uplink_kind();
20+
if kind.map_like() {
21+
assert_eq!(uplink_kind, UplinkKind::Map);
22+
} else if matches!(kind, WarpLaneKind::Supply) {
23+
assert_eq!(uplink_kind, UplinkKind::Supply);
24+
} else {
25+
assert_eq!(uplink_kind, UplinkKind::Value)
26+
}
27+
}
28+
}
29+
30+
// this is here for when spatial lanes are implemented as the test will no longer panic
31+
#[test]
32+
#[should_panic]
33+
fn spatial_uplink_kind() {
34+
WarpLaneKind::Spatial.uplink_kind();
35+
}

0 commit comments

Comments
 (0)