From 54956cadf270d597e5ba3bf492001b540dd0803c Mon Sep 17 00:00:00 2001 From: teridax Date: Tue, 2 Jul 2024 11:11:33 +0200 Subject: [PATCH] change: added tests for invalid configurations --- run-ci.sh | 19 ++++++++++++++++-- tests/invalid-config/test-case-1.typ | 29 +++++++++++++++++++++++++++ tests/invalid-config/test-case-2.typ | 30 ++++++++++++++++++++++++++++ tests/invalid-config/test-case-3.typ | 24 ++++++++++++++++++++++ 4 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 tests/invalid-config/test-case-1.typ create mode 100644 tests/invalid-config/test-case-2.typ create mode 100644 tests/invalid-config/test-case-3.typ diff --git a/run-ci.sh b/run-ci.sh index 4481709..47cb00e 100755 --- a/run-ci.sh +++ b/run-ci.sh @@ -1,7 +1,5 @@ #!/bin/bash -set -e - function abort() { echo "test case `$1` has failed" 1>&2 exit 1 @@ -15,4 +13,21 @@ echo "Running tests..." echo "Running test local-import..." typst compile tests/local-import/main.typ --root . || abort "local-import" +echo "Running test invalid-config..." + +echo "Expected to fail..." +typst compile tests/invalid-config/test-case-1.typ --root . +if [ $? -eq 0 ]; then + abort "invalid-config case 1" +fi + +typst compile tests/invalid-config/test-case-2.typ --root . || abort "invalid-config case 2" + +echo "Expected to fail..." +typst compile tests/invalid-config/test-case-3.typ --root . +if [ $? -eq 0 ]; then + abort "invalid-config case 3b" +fi + + echo "Tests completed successfully" diff --git a/tests/invalid-config/test-case-1.typ b/tests/invalid-config/test-case-1.typ new file mode 100644 index 0000000..92d7098 --- /dev/null +++ b/tests/invalid-config/test-case-1.typ @@ -0,0 +1,29 @@ + +#import "../../src/lib.typ": dhbw-template + +#show: dhbw-template.with( + config: ( + lang: none, + region: "en", + author: ( + name: "Sven Vogel", + semester: 4, + program: "Informationtechnology", + course: "TINF19IT1", + faculty: "Technik", + university: "DHBW Mannheim", + company: "ABB AG", + supervisor: "Benny Goodman", + matriculation-number: 123456789), + thesis: ( + title: "Unofficial ABB/DHBW Typst template", + subtitle: "for reports and thesises", + submission-date: "23rd march 2020", + timeframe: "1st january 2020 - 20th march 2020", + kind: "T2000", + summary: none, + abstract: none, + keywords: ( "IT", "other stuff" ), + bibliography: none, + glossary: none, + appendices: none))) diff --git a/tests/invalid-config/test-case-2.typ b/tests/invalid-config/test-case-2.typ new file mode 100644 index 0000000..10793ca --- /dev/null +++ b/tests/invalid-config/test-case-2.typ @@ -0,0 +1,30 @@ + +#import "../../src/lib.typ": dhbw-template + +#show: dhbw-template.with( + config: ( + lang: "en", + this-key-is-not-in-config: "Ha Ha", + region: "en", + author: ( + name: "Sven Vogel", + semester: 4, + program: "Informationtechnology", + course: "TINF19IT1", + faculty: "Technik", + university: "DHBW Mannheim", + company: "ABB AG", + supervisor: "Benny Goodman", + matriculation-number: 123456789), + thesis: ( + title: "Unofficial ABB/DHBW Typst template", + subtitle: "for reports and thesises", + submission-date: "23rd march 2020", + timeframe: "1st january 2020 - 20th march 2020", + kind: "T2000", + summary: none, + abstract: none, + keywords: ( "IT", "other stuff" ), + bibliography: none, + glossary: none, + appendices: none))) diff --git a/tests/invalid-config/test-case-3.typ b/tests/invalid-config/test-case-3.typ new file mode 100644 index 0000000..ef42dd8 --- /dev/null +++ b/tests/invalid-config/test-case-3.typ @@ -0,0 +1,24 @@ + +#import "../../src/lib.typ": dhbw-template + +#show: dhbw-template.with( + config: ( + lang: "en", + region: "en", + author: ( + university: "DHBW Mannheim", + company: "ABB AG", + supervisor: none, + matriculation-number: 123456789), + thesis: ( + title: "Unofficial ABB/DHBW Typst template", + subtitle: "for reports and thesises", + submission-date: "23rd march 2020", + timeframe: "1st january 2020 - 20th march 2020", + kind: "T2000", + summary: none, + abstract: none, + keywords: ( "IT", "other stuff" ), + bibliography: none, + glossary: none, + appendices: none)))