Skip to content

Commit

Permalink
Added block messages blockOpened and blockClosed from TeamCity 9.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jozefizso committed Jan 7, 2016
1 parent bf8fc74 commit d557d93
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
24 changes: 24 additions & 0 deletions teamcity.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ if ($env:TEAMCITY_VERSION) {
$host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(8192,50)
}

function TeamCity-Message([string]$text, [string]$status = 'NORMAL', [string]$errorDetails) {
$messageAttributes = @{ text=$text; status=$status }

if ($errorDetails) {
$messageAttributes.errorDetails = $errorDetails
}

TeamCity-WriteServiceMessage 'message' $messageAttributes
}

function TeamCity-BlockOpened([string]$name, [string]$description) {
$messageAttributes = @{ name=$name }

if ($description) {
$messageAttributes.description = $description
}

TeamCity-WriteServiceMessage 'blockOpened' $messageAttributes
}

function TeamCity-BlockClosed([string]$name) {
TeamCity-WriteServiceMessage 'blockClosed' @{ name=$name }
}

function TeamCity-TestSuiteStarted([string]$name) {
TeamCity-WriteServiceMessage 'testSuiteStarted' @{ name=$name }
}
Expand Down
36 changes: 36 additions & 0 deletions tests/teamcity.tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
Import-Module ".\teamcity.psm1" -DisableNameChecking -Force

Describe "TeamCity-Message" {
It "Writes ##teamcity[message text='Build log message.' status='NORMAL']" {
TeamCity-Message "Build log message." | `
Should BeExactly "##teamcity[message text='Build log message.' status='NORMAL']"
}

It "Writes ##teamcity[message text='Exception text' status='ERROR']" {
TeamCity-Message "Exception text" "ERROR" | `
Should BeExactly "##teamcity[message text='Exception text' status='ERROR']"
}

It "Writes ##teamcity[message text='Exception text' errorDetails='stack trace' status='ERROR']" {
TeamCity-Message "Exception text" "ERROR" "stack trace" | `
Should BeExactly "##teamcity[message errorDetails='stack trace' status='ERROR' text='Exception text']"
}
}

Describe "TeamCity-BlockOpened" {
It "Writes ##teamcity[blockOpened name='MyServiceBlock']" {
TeamCity-BlockOpened "MyServiceBlock" | `
Should BeExactly "##teamcity[blockOpened name='MyServiceBlock']"
}

It "Writes ##teamcity[blockOpened name='MyServiceBlock' description='Service block description.']" {
TeamCity-BlockOpened "MyServiceBlock" "Service block description." | `
Should BeExactly "##teamcity[blockOpened name='MyServiceBlock' description='Service block description.']"
}
}

Describe "TeamCity-BlockClosed" {
It "Writes ##teamcity[blockClosed name='MyServiceBlock']" {
TeamCity-BlockClosed "MyServiceBlock" | `
Should BeExactly "##teamcity[blockClosed name='MyServiceBlock']"
}
}

Describe "TeamCity-WriteServiceMessage" {
It "Writes ##teamcity[message 'Single parameter message.']" {
TeamCity-WriteServiceMessage "message" "Single parameter message." | `
Expand Down

0 comments on commit d557d93

Please sign in to comment.