Skip to content

Commit

Permalink
✅ Add tests for the log module
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiome committed Mar 21, 2024
1 parent 661a166 commit 829234a
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 0 deletions.
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 829234a

Please sign in to comment.