|
|
@@ -275,4 +275,65 @@ struct ProfileGeneratorTests {
|
|
|
|
|
|
#expect(profile.model == "554")
|
|
|
}
|
|
|
+
|
|
|
+ @Test("Profile should use temptargetSet key in output json") func testTempTargetSetKey() async throws {
|
|
|
+ var inputs = createBaseInputs()
|
|
|
+ inputs.7 = "\"554\"\n"
|
|
|
+ let now = Date()
|
|
|
+ let tempTargets = [
|
|
|
+ TempTarget(
|
|
|
+ name: nil,
|
|
|
+ createdAt: now - 1.hoursToSeconds,
|
|
|
+ targetTop: 100,
|
|
|
+ targetBottom: 80,
|
|
|
+ duration: 120,
|
|
|
+ enteredBy: nil,
|
|
|
+ reason: nil,
|
|
|
+ isPreset: nil,
|
|
|
+ enabled: nil,
|
|
|
+ halfBasalTarget: nil
|
|
|
+ )
|
|
|
+ ]
|
|
|
+
|
|
|
+ let openAps = OpenAPS(storage: BaseFileStorage(), tddStorage: MockTDDStorage())
|
|
|
+ let jsResult = await openAps.makeProfileJavascript(
|
|
|
+ preferences: inputs.4,
|
|
|
+ pumpSettings: inputs.0,
|
|
|
+ bgTargets: inputs.1,
|
|
|
+ basalProfile: inputs.2,
|
|
|
+ isf: inputs.3,
|
|
|
+ carbRatio: inputs.5,
|
|
|
+ tempTargets: tempTargets,
|
|
|
+ model: inputs.7,
|
|
|
+ autotune: RawJSON.null,
|
|
|
+ trioSettings: inputs.8
|
|
|
+ )
|
|
|
+
|
|
|
+ let swiftResult = OpenAPSSwift.makeProfile(
|
|
|
+ preferences: inputs.4,
|
|
|
+ pumpSettings: inputs.0,
|
|
|
+ bgTargets: inputs.1,
|
|
|
+ basalProfile: inputs.2,
|
|
|
+ isf: inputs.3,
|
|
|
+ carbRatio: inputs.5,
|
|
|
+ tempTargets: tempTargets,
|
|
|
+ model: inputs.7,
|
|
|
+ trioSettings: inputs.8
|
|
|
+ )
|
|
|
+
|
|
|
+ let comparison = JSONCompare.createComparison(
|
|
|
+ function: .makeProfile,
|
|
|
+ swift: swiftResult,
|
|
|
+ swiftDuration: 1.0,
|
|
|
+ javascript: jsResult,
|
|
|
+ javascriptDuration: 1.0,
|
|
|
+ iobInputs: nil
|
|
|
+ )
|
|
|
+
|
|
|
+ if comparison.resultType == .valueDifference {
|
|
|
+ print(comparison.differences!.prettyPrintedJSON!)
|
|
|
+ }
|
|
|
+
|
|
|
+ #expect(comparison.resultType == .matching)
|
|
|
+ }
|
|
|
}
|