Skip to content

Commit

Permalink
Add ZnServerTest>>#testLogging with ZnLogEvent rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvc committed Oct 1, 2023
1 parent 0b99553 commit a5677a0
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
tests
testLogging
| client logEventCollection count renderedLogEvents |
logEventCollection := OrderedCollection new.
ZnLogEvent announcer
when: ZnLogEvent do: [ :event | logEventCollection add: event ].
self withServerDo: [ :server |
server serverId: #S1; logLevel: 3.
client := ZnClient new.
client clientId: #C1; logLevel: 3.
client get: (server localUrl addPathSegment: #small).
self assert: client isSuccess.
client get: (server localUrl addPathSegment: #error).
self deny: client isSuccess.
server delegate map: #redirect to: [ :request | ZnResponse redirect: #welcome ].
client get: (server localUrl addPathSegment: #redirect).
self assert: client isSuccess.
client close ].
count := ZnLogEvent announcer numberOfSubscriptions.
ZnLogEvent announcer
unsubscribe: self.
self assert: ZnLogEvent announcer numberOfSubscriptions equals: count -1.
self deny: logEventCollection isEmpty.
renderedLogEvents := String streamContents: [ :out |
logEventCollection do: [ :event | out print: event; cr ] ].
self deny: renderedLogEvents isEmpty

0 comments on commit a5677a0

Please sign in to comment.