Skip to content

Commit

Permalink
Merge pull request #167 from aksiome/dev-tests
Browse files Browse the repository at this point in the history
✅ Dev modules tests
  • Loading branch information
aksiome authored Mar 25, 2024
2 parents 0364357 + 4a63976 commit 68fea33
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 0 deletions.
13 changes: 13 additions & 0 deletions datapacks/Bookshelf Dev/data/bs.dump/tests/var.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Dumping var works as expected
# @batch bs.dump
# @dummy

data modify storage bs:data packtest set value {foo:"bar"}
function #bs.dump:var { var: { storage: "storage bs:data packtest", entity:"entity @s {} 0", score: ["3 bs.const", "-_- bs.const"] }}

assert chat '.*?\\{[\\s\\S]*storage: \\{[\\s\\S]*foo: \\"bar\\"[\\s\\S]*\\}[\\s\\S]*\\}'
assert chat '.*?\\{[\\s\\S]*entity: \\{ [0-9]+ entries .*? \\}[\\s\\S]*\\}'
assert chat '.*?\\{[\\s\\S]*score: \\[3, undefined\\][\\s\\S]*\\}'

data remove storage bs:data packtest

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Debug logs are not shown when missing tag
# @batch bs.log
# @dummy

function #bs.log:debug { path: "bs.foo:bar", feature: "foo.bar", message: '"Hidden debug log message"' }
assert not chat "Hidden debug log message"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Debug logs are shown when having tag
# @batch bs.log
# @dummy

tag @s add bs.log.foo.bar.debug
function #bs.log:debug { path: "bs.foo:bar", feature: "foo.bar", message: '"Debug tag debug log message"' }
assert chat "Debug tag debug log message"
tag @s remove bs.log.foo.bar.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Debug logs are shown when having tag
# @batch bs.log
# @dummy

tag @s add bs.log.foo.bar._
function #bs.log:debug { path: "bs.foo:bar", feature: "foo.bar", message: '"Level wildcard debug log message"' }
assert chat "Level wildcard debug log message"
tag @s remove bs.log.foo.bar._

tag @s add bs.log._.debug
function #bs.log:debug { path: "bs.foo:bar", feature: "foo.bar", message: '"Feature wildcard debug log message"' }
assert chat "Feature wildcard debug log message"
tag @s remove bs.log._.debug

tag @s add bs.log._._
function #bs.log:debug { path: "bs.foo:bar", feature: "foo.bar", message: '"All wildcards debug log message"' }
assert chat "All wildcards debug log message"
tag @s remove bs.log._._
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Error logs are not shown when missing tag
# @batch bs.log
# @dummy

function #bs.log:error { path: "bs.foo:bar", feature: "foo.bar", message: '"Hidden error log message"' }
assert not chat "Hidden error log message"
23 changes: 23 additions & 0 deletions datapacks/Bookshelf Dev/data/bs.log/tests/error/visible.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Error logs are shown when having tag
# @batch bs.log
# @dummy

tag @s add bs.log.foo.bar.debug
function #bs.log:error { path: "bs.foo:bar", feature: "foo.bar", message: '"Debug tag error log message"' }
assert chat "Debug tag error log message"
tag @s remove bs.log.foo.bar.debug

tag @s add bs.log.foo.bar.info
function #bs.log:error { path: "bs.foo:bar", feature: "foo.bar", message: '"Info tag error log message"' }
assert chat "Info tag error log message"
tag @s remove bs.log.foo.bar.info

tag @s add bs.log.foo.bar.warn
function #bs.log:error { path: "bs.foo:bar", feature: "foo.bar", message: '"Warn tag error log message"' }
assert chat "Warn tag error log message"
tag @s remove bs.log.foo.bar.warn

tag @s add bs.log.foo.bar.error
function #bs.log:error { path: "bs.foo:bar", feature: "foo.bar", message: '"Error tag error log message"' }
assert chat "Error tag error log message"
tag @s remove bs.log.foo.bar.error
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Error logs are shown when having tag
# @batch bs.log
# @dummy

tag @s add bs.log.foo.bar._
function #bs.log:error { path: "bs.foo:bar", feature: "foo.bar", message: '"Level wildcard error log message"' }
assert chat "Level wildcard error log message"
tag @s remove bs.log.foo.bar._

tag @s add bs.log._.error
function #bs.log:error { path: "bs.foo:bar", feature: "foo.bar", message: '"Feature wildcard error log message"' }
assert chat "Feature wildcard error log message"
tag @s remove bs.log._.error

tag @s add bs.log._._
function #bs.log:error { path: "bs.foo:bar", feature: "foo.bar", message: '"All wildcards error log message"' }
assert chat "All wildcards error log message"
tag @s remove bs.log._._
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Info logs are not shown when missing tag
# @batch bs.log
# @dummy

function #bs.log:info { path: "bs.foo:bar", feature: "foo.bar", message: '"Hidden info log message"' }
assert not chat "Hidden info log message"
13 changes: 13 additions & 0 deletions datapacks/Bookshelf Dev/data/bs.log/tests/info/visible.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Info logs are shown when having tag
# @batch bs.log
# @dummy

tag @s add bs.log.foo.bar.debug
function #bs.log:info { path: "bs.foo:bar", feature: "foo.bar", message: '"Debug tag info log message"' }
assert chat "Debug tag info log message"
tag @s remove bs.log.foo.bar.debug

tag @s add bs.log.foo.bar.info
function #bs.log:info { path: "bs.foo:bar", feature: "foo.bar", message: '"Info tag info log message"' }
assert chat "Info tag info log message"
tag @s remove bs.log.foo.bar.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Info logs are shown when having tag
# @batch bs.log
# @dummy

tag @s add bs.log.foo.bar._
function #bs.log:info { path: "bs.foo:bar", feature: "foo.bar", message: '"Level wildcard info log message"' }
assert chat "Level wildcard info log message"
tag @s remove bs.log.foo.bar._

tag @s add bs.log._.info
function #bs.log:info { path: "bs.foo:bar", feature: "foo.bar", message: '"Feature wildcard info log message"' }
assert chat "Feature wildcard info log message"
tag @s remove bs.log._.info

tag @s add bs.log._._
function #bs.log:info { path: "bs.foo:bar", feature: "foo.bar", message: '"All wildcards info log message"' }
assert chat "All wildcards info log message"
tag @s remove bs.log._._
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Warn logs are not shown when missing tag
# @batch bs.log
# @dummy

function #bs.log:warn { path: "bs.foo:bar", feature: "foo.bar", message: '"Hidden warn log message"' }
assert not chat "Hidden warn log message"
18 changes: 18 additions & 0 deletions datapacks/Bookshelf Dev/data/bs.log/tests/warn/visible.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Warn logs are shown when having tag
# @batch bs.log
# @dummy

tag @s add bs.log.foo.bar.debug
function #bs.log:warn { path: "bs.foo:bar", feature: "foo.bar", message: '"Debug tag warn log message"' }
assert chat "Debug tag warn log message"
tag @s remove bs.log.foo.bar.debug

tag @s add bs.log.foo.bar.info
function #bs.log:warn { path: "bs.foo:bar", feature: "foo.bar", message: '"Info tag warn log message"' }
assert chat "Info tag warn log message"
tag @s remove bs.log.foo.bar.info

tag @s add bs.log.foo.bar.warn
function #bs.log:warn { path: "bs.foo:bar", feature: "foo.bar", message: '"Warn tag warn log message"' }
assert chat "Warn tag warn log message"
tag @s remove bs.log.foo.bar.warn
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Warn logs are shown when having tag
# @batch bs.log
# @dummy

tag @s add bs.log.foo.bar._
function #bs.log:warn { path: "bs.foo:bar", feature: "foo.bar", message: '"Level wildcard warn log message"' }
assert chat "Level wildcard warn log message"
tag @s remove bs.log.foo.bar._

tag @s add bs.log._.warn
function #bs.log:warn { path: "bs.foo:bar", feature: "foo.bar", message: '"Feature wildcard warn log message"' }
assert chat "Feature wildcard warn log message"
tag @s remove bs.log._.warn

tag @s add bs.log._._
function #bs.log:warn { path: "bs.foo:bar", feature: "foo.bar", message: '"All wildcards warn log message"' }
assert chat "All wildcards warn log message"
tag @s remove bs.log._._

0 comments on commit 68fea33

Please sign in to comment.