1+ Import-Module - Name Pester - Force
2+ Import-Module .\Toggl.API\Toggl.API.psm1 - Force
3+
4+ $configPath = Join-Path - Path $PSScriptRoot - ChildPath " ..\config.json"
5+ $config = Get-Content - Path $configPath | ConvertFrom-Json
6+
7+ $apiToken = $config.apiToken
8+ $workspaceId = $config.workspaceId
9+
10+ Describe ' Toggl Tag Integration Tests' {
11+ $tagName = " TestTagToRemove"
12+
13+ Context " New-TogglTag" {
14+ It " should create a new tag in the workspace" {
15+ $newTag = New-TogglTag - ApiToken $apiToken - WorkspaceId $workspaceId - Name $tagName
16+ $newTag | Should -Not - BeNullOrEmpty
17+ $newTag.name | Should - BeExactly $tagName
18+ $Script :tagId = $newTag.id
19+ }
20+ }
21+
22+ Context " Get-TogglTags" {
23+ It " should retrieve the list of tags for the workspace" - Skip:($Script :tagId -eq $null ) {
24+ $tags = Get-TogglTags - ApiToken $apiToken - WorkspaceId $workspaceId
25+ $tags | Should -Not - BeNullOrEmpty
26+ $tags | Where-Object { $_.name -eq $tagName } | Should -Not - BeNullOrEmpty
27+ }
28+ }
29+
30+ Context " Remove-TogglTag" {
31+ It " should delete the tag from the workspace" - Skip:($Script :tagId -eq $null ) {
32+ Remove-TogglTag - ApiToken $apiToken - WorkspaceId $workspaceId - TagId $Script :tagId
33+
34+ # Verify the tag was deleted
35+ $tags = Get-TogglTags - ApiToken $apiToken - WorkspaceId $workspaceId
36+ $tags | Where-Object { $_.id -eq $Script :tagId } | Should BeNullOrEmpty
37+ }
38+ }
39+ }
0 commit comments