download and fullScreen are imcompatible options
authorJoseph Nuthalapati <njoseph@riseup.net>
Fri, 27 Mar 2020 08:04:09 +0000 (13:34 +0530)
committerJoseph Nuthalapati <njoseph@riseup.net>
Fri, 27 Mar 2020 08:09:18 +0000 (13:39 +0530)
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
src/nimcoon.nim
tests/tests.nim

index a0bb93deb2ed9ac8a17dad9c5e440abf24255873..56e68674dcc2f40cf518b97597d8ffb4a28f7c3a 100644 (file)
@@ -32,7 +32,7 @@ proc parseArguments(): CommandLineOptions =
 
 proc isValidOptions*(options: Options): bool =
   # Check for invalid combinations of options
-  var invalidCombinations = [("musicOnly", "fullScreen")]
+  var invalidCombinations = [("musicOnly", "fullScreen"), ("download", "fullScreen")]
   for combination in invalidCombinations:
     if options[combination[0]] and options[combination[1]]:
      stderr.writeLine fmt"Incompatible options provided: {combination[0]} and {combination[1]}"
index dad726cdd28268341a70c394fb96d9447a54db46..8b9e6d21ac1a95de1221d7f66e4344853df077f8 100644 (file)
@@ -13,7 +13,15 @@ suite "Playing direct links":
     check(sanitizeURL("https://www.youtube.com/watch\\?v\\=QOEMv0S8AcA") == expected)
 
   test "validate options":
-      let invalidOptions = to_table({"musicOnly": true, "feelingLucky": false, "fullScreen": true, "download": false})
-      check(not isValidOptions(invalidOptions))
-      let validOptions = to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": true, "download": true})
-      check(isValidOptions(validOptions))
+      let invalidOptionsList = [
+        to_table({"musicOnly": true, "feelingLucky": false, "fullScreen": true, "download": false}),
+        to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": true, "download": true})
+      ]
+      for invalidOptions in invalidOptionsList:
+        check(not isValidOptions(invalidOptions))
+      let validOptionsList = [
+        to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": false, "download": true}),
+        to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": true, "download": false})
+      ]
+      for validOptions in validOptionsList:
+        check(isValidOptions(validOptions))