diff --git a/model/transform/src/test/scala/aqua/model/transform/topology/OpModelTreeCursorSpec.scala b/model/transform/src/test/scala/aqua/model/transform/topology/OpModelTreeCursorSpec.scala index 6bb3430d..a1425652 100644 --- a/model/transform/src/test/scala/aqua/model/transform/topology/OpModelTreeCursorSpec.scala +++ b/model/transform/src/test/scala/aqua/model/transform/topology/OpModelTreeCursorSpec.scala @@ -7,6 +7,7 @@ import aqua.raw.value.{LiteralRaw, ValueRaw, VarRaw} import aqua.raw.ops.{Call, FuncOp, OnTag} import aqua.raw.value.{ValueRaw, VarRaw} import aqua.types.{ArrayType, ScalarType} + import cats.data.{Chain, NonEmptyList} import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers diff --git a/model/transform/src/test/scala/aqua/model/transform/topology/PathFinderSpec.scala b/model/transform/src/test/scala/aqua/model/transform/topology/PathFinderSpec.scala new file mode 100644 index 00000000..3b317620 --- /dev/null +++ b/model/transform/src/test/scala/aqua/model/transform/topology/PathFinderSpec.scala @@ -0,0 +1,34 @@ +package aqua.model.transform.topology + +import aqua.model.* +import aqua.model.transform.ModelBuilder +import aqua.types.ScalarType + +import cats.data.Chain +import cats.syntax.show.* +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class PathFinderSpec extends AnyFlatSpec with Matchers { + + val relay = ValueModel.fromRaw(ModelBuilder.relayV) + val initPeer = ValueModel.fromRaw(ModelBuilder.initPeer) + + val relayOn = OnModel(relay, Chain.empty) + val initPeerRelayOn = OnModel(initPeer, Chain.one(relay)) + + it should "find path from (op, or) -> r -> (i, r) to r -> (i, r)" in { + + val otherPeer = VarModel("other-peer", ScalarType.string) + val otherRelay = VarModel("other-relay", ScalarType.string) + val otherPeerRelayOn = OnModel(otherPeer, Chain.one(otherRelay)) + + val from = TopologyPath(otherPeerRelayOn :: relayOn :: initPeerRelayOn :: Nil) + val to = TopologyPath(relayOn :: initPeerRelayOn :: Nil) + + val path = PathFinder.findPath(from, to) + + path shouldBe Chain.one(otherRelay) + } + +}