From fc8ebff99ea13858b26700d74dc1abb571864862 Mon Sep 17 00:00:00 2001
From: David <david.dorchies@inrae.fr>
Date: Tue, 22 Nov 2022 17:43:05 +0100
Subject: [PATCH] test: add beginning of crash test on the use of RunModel_lag

Refs #107
---
 tests/testthat/test-RunModel.R | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tests/testthat/test-RunModel.R b/tests/testthat/test-RunModel.R
index 27868ca..0bbdc0c 100644
--- a/tests/testthat/test-RunModel.R
+++ b/tests/testthat/test-RunModel.R
@@ -127,3 +127,18 @@ test_that("Huge minimum remaining flow results in Qdiv = 0", {
   expect_equal(OM[["54029"]]$Qsim, OM[["54029"]]$Qnat)
   expect_equal(OM[["54029"]]$Qdiv_m3, rep(0, length(IndPeriod_Run)))
 })
+
+test_that("RunModel_Lag should work", {
+  # This example is a network of 2 nodes which can be describe like this:
+  db <- data.frame(id = c("54095", "DownLag"),
+                   length = c(1, NA),
+                   down = c("DownLag", NA),
+                   area = as.double(c(3722.68, NA)),
+                   model = c("RunModel_GR4J", "RunModel_Lag"),
+                   stringsAsFactors = FALSE)
+  g <- CreateGRiwrm(db)
+  IM <- CreateInputsModel(g,
+                          DatesR = DatesR,
+                          Precip = Precip[, "54095", drop = FALSE],
+                          PotEvap = PotEvap[, "54095", drop = FALSE])
+})
-- 
GitLab