-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCarrierServicesSpec.scala
52 lines (40 loc) · 1.53 KB
/
CarrierServicesSpec.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package io.flow.reference
import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers
class CarrierServicesSpec extends AnyFunSpec with Matchers {
it("be unique") {
data.CarrierServices.all.groupBy(_.id).filter { _._2.size > 1 }.keys should be(Set())
}
it("be sorted") {
data.CarrierServices.all.map(_.id) should be(data.CarrierServices.all.map(_.id).sortBy { _.toLowerCase })
}
it("have no blanks") {
data.CarrierServices.all.find(_.id.trim.isEmpty) should be(None)
}
it("find") {
data.CarrierServices.all.foreach { carrierService =>
// find by name
CarrierServices.find(carrierService.name).getOrElse {
sys.error(s"${carrierService.name} missing")
}
// find by id
CarrierServices.find(carrierService.id).getOrElse {
sys.error(s"${carrierService.id} missing")
}
}
CarrierServices.find("other") should be(None)
}
it("mustFind") {
data.CarrierServices.all.foreach { carrierService =>
// must find by name
CarrierServices.mustFind(carrierService.name).name.toLowerCase should be(carrierService.name.trim.toLowerCase)
// must find by id
CarrierServices.mustFind(carrierService.id).id.toLowerCase should be(carrierService.id.trim.toLowerCase)
}
intercept[Throwable] {
CarrierServices.mustFind("other")
}.getMessage should be(
"The following carrier service is invalid: [other]. See https://api.flow.io/reference/carrier-services for a list of all valid carrier-services.",
)
}
}