Skip to content

Commit

Permalink
Add ZnLogEventTest with some sanity elementary unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvc committed Oct 2, 2023
1 parent 2d27fa3 commit b8532e0
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
clientId
^ 'client-1'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
request
^ ZnRequest get: 'http://foo.com/test'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
response
^ ZnResponse ok: (ZnEntity text: 'OK')
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
serverId
^ 'server-1'
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
testing
testClientTransactionEvent
| event |
(event := ZnClientTransactionEvent new)
clientId: self clientId;
request: self request;
response: self response;
requestDuration: self timing requestDuration;
responseDuration: self timing responseDuration.
self assert: event id isInteger.
self assert: event processId isInteger.
self assert: event timestamp <= DateAndTime now.
self assert: event clientId equals: self clientId.
self assert: event request uri equals: self request uri.
self assert: event request method equals: self request method.
self assert: event response code equals: self response code.
self assert: event duration equals: self timing requestDuration + self timing responseDuration.
self assert: event printString isString.
^ event
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
testing
testServerTransactionEvent
| event |
(event := ZnServerTransactionEvent new)
serverId: self serverId;
request: self request;
response: self response;
timing: self timing.
self assert: event id isInteger.
self assert: event processId isInteger.
self assert: event timestamp <= DateAndTime now.
self assert: event serverId equals: self serverId.
self assert: event request uri equals: self request uri.
self assert: event request method equals: self request method.
self assert: event response code equals: self response code.
self assert: event duration equals: self timing totalDuration.
self assert: event printString isString.
^ event
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
testing
testSimplifiedClientTransactionEvent
| event |
(event := ZnSimplifiedClientTransactionEvent new)
clientId: self clientId;
request: self request;
response: self response;
requestDuration: self timing requestDuration;
responseDuration: self timing responseDuration.
self assert: event id isInteger.
self assert: event processId isInteger.
self assert: event timestamp <= DateAndTime now.
self assert: event clientId equals: self clientId.
self assert: event url equals: self request uri.
self assert: event method equals: self request method.
self assert: event responseCode equals: self response code.
self assert: event size equals: self response contentLength.
self assert: event duration equals: self timing requestDuration + self timing responseDuration.
self assert: event printString isString.
^ event
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
testing
testSimplifiedServerTransactionEvent
| event |
(event := ZnSimplifiedServerTransactionEvent new)
serverId: self serverId;
request: self request;
response: self response;
timing: self timing.
self assert: event id isInteger.
self assert: event processId isInteger.
self assert: event timestamp <= DateAndTime now.
self assert: event serverId equals: self serverId.
self assert: event url equals: self request uri.
self assert: event method equals: self request method.
self assert: event responseCode equals: self response code.
self assert: event size equals: self response contentLength.
self assert: event duration equals: self timing totalDuration.
self assert: event printString isString.
^ event
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
accessing
timing
^ ZnServerTransactionTiming new
requestDuration: 1;
responseDuration: 2;
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "ZnUnixSocketClientTest",
"name" : "ZnLogEventTest",
"type" : "normal"
}

0 comments on commit b8532e0

Please sign in to comment.