2 Commits
1.5.0 ... 1.5.2

Author SHA1 Message Date
d647600568 Update Get-GiteaFileContent tests to use 'Result' for status reporting instead of 'Success'
All checks were successful
Publish Powershell Module to Gitea Repository / test (push) Successful in 10s
Publish Powershell Module to Gitea Repository / deploy (push) Successful in 32s
2025-05-27 13:27:38 -04:00
ed8f3ab02e Update pester tests
Some checks failed
Publish Powershell Module to Gitea Repository / test (push) Failing after 10s
Publish Powershell Module to Gitea Repository / deploy (push) Has been skipped
2025-05-27 13:23:37 -04:00
3 changed files with 18 additions and 18 deletions

View File

@@ -434,8 +434,8 @@ Function Invoke-GiteaFileDownload {
return [PSCustomObject]@{
SourceURL = $downloadURL
Type = $type
Result = 'Success'
Error = "Skipped - item is a directory"
Result = 'Skipped'
Error = $null
Timestamp = Get-Date
FileSize = $null
}
@@ -521,7 +521,7 @@ Function Invoke-GiteaFileDownload {
Path = $fileOutputPath
SourceURL = $downloadURL
Type = "file"
Result = 'Failure'
Result = $null
Error = $null
Timestamp = Get-Date
FileSize = $null
@@ -545,6 +545,7 @@ Function Invoke-GiteaFileDownload {
}
}
else {
$result.Result = 'Skipped'
$errorMsg = "The file '$fileOutputPath' already exists. Use the -Force switch to overwrite the file."
Write-Error $errorMsg
$result.Error = $errorMsg
@@ -578,6 +579,7 @@ Function Invoke-GiteaFileDownload {
return $result
}
catch {
$result.Result = 'Failure'
$errorMsg = "Failed to download file from Gitea: $_"
Write-Error $errorMsg
$result.Error = $errorMsg

View File

@@ -21,7 +21,7 @@ Describe 'Get-GiteaFileContent' {
$result = Get-GiteaFileContent -repoOwner 'user' -repoName 'repo' -filePath 'README.md' -token 'abc123'
$result | Should -Not -BeNullOrEmpty
$result.Success | Should -Be $true
$result.Result | Should -Be 'Success'
$result.Content | Should -Be ([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes('Hello World')))
}
@@ -29,7 +29,7 @@ Describe 'Get-GiteaFileContent' {
$result = Get-GiteaFileContent -repoOwner 'user' -repoName 'repo' -filePath 'README.md' -token 'abc123' -decode
$result | Should -Not -BeNullOrEmpty
$result.Success | Should -Be $true
$result.Result | Should -Be 'Success'
$result.Content | Should -Be 'Hello World'
}
}
@@ -73,7 +73,7 @@ Describe 'Get-GiteaFileContent' {
It 'Should capture error and mark result as unsuccessful' {
$result = Get-GiteaFileContent -repoOwner 'user' -repoName 'repo' -filePath 'badfile.ps1' -token 'abc123'
$result.Success | Should -Be $false
$result.Result | Should -Be 'Failure'
$result.Error | Should -Match 'API call failed'
}
}
@@ -103,7 +103,7 @@ Describe 'Get-GiteaFileContent' {
$result = Get-GiteaFileContent -repoOwner 'user' -repoName 'repo' -filePath 'testfile.txt' -token 'abc123'
$result | Should -Not -BeNullOrEmpty
$result.Success | Should -Be $true
$result.Result | Should -Be 'Success'
$result.Content | Should -Be ([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes('Hello from API!')))
}
@@ -111,7 +111,7 @@ Describe 'Get-GiteaFileContent' {
$result = Get-GiteaFileContent -repoOwner 'user' -repoName 'repo' -filePath 'testfile.txt' -token 'abc123' -decode
$result | Should -Not -BeNullOrEmpty
$result.Success | Should -Be $true
$result.Result | Should -Be 'Success'
$result.Content | Should -Be 'Hello from API!'
}
}

View File

@@ -49,7 +49,7 @@ Describe 'Invoke-GiteaFileDownload' {
$result = Invoke-GiteaFileDownload -downloadURL 'https://gitea.example.com/raw/path/to/file.txt' -token 'abc123'
$result | Should -Not -BeNullOrEmpty
$result.Success | Should -Be $true
$result.Result | Should -Be 'Success'
$result.Path | Should -Match 'file\.txt$'
}
}
@@ -60,7 +60,7 @@ Describe 'Invoke-GiteaFileDownload' {
-outputPath 'docs/manual/' -token 'abc123'
$result.Path | Should -Match 'docs[\\/]+manual[\\/]+file\.txt$'
$result.Success | Should -Be $true
$result.Result | Should -Be 'Success'
}
}
@@ -70,7 +70,7 @@ Describe 'Invoke-GiteaFileDownload' {
-outputName 'newfile.txt' -token 'abc123'
$result.Path | Should -Match 'newfile\.txt$'
$result.Success | Should -Be $true
$result.Result | Should -Be 'Success'
}
}
@@ -80,7 +80,7 @@ Describe 'Invoke-GiteaFileDownload' {
-outputPath 'docs/manual/' -outputName 'newfile.txt' -token 'abc123'
$result.Path | Should -Match 'docs[\\/]+manual[\\/]+newfile\.txt$'
$result.Success | Should -Be $true
$result.Result | Should -Be 'Success'
}
}
@@ -90,7 +90,7 @@ Describe 'Invoke-GiteaFileDownload' {
-PreserveRelativePath -token 'abc123'
$result.Path | Should -Match 'path[\\/]+to[\\/]+file\.txt$'
$result.Success | Should -Be $true
$result.Result | Should -Be 'Success'
}
}
@@ -98,8 +98,7 @@ Describe 'Invoke-GiteaFileDownload' {
It 'Should skip items with type = dir' {
$result = Invoke-GiteaFileDownload -outputPath 'docs/' -type 'dir' -token 'abc123'
$result.Success | Should -Be $true
$result.Error | Should -Match 'Skipped'
$result.Result | Should -Be 'Skipped'
}
}
@@ -116,8 +115,7 @@ Describe 'Invoke-GiteaFileDownload' {
It 'Should not overwrite existing file without Force' {
$result = Invoke-GiteaFileDownload -downloadURL 'https://gitea.example.com/raw/path/to/existingfile.txt' -token 'abc123'
$result.Success | Should -Be $false
$result.Error | Should -Match 'already exists'
$result.Result | Should -Be 'Skipped'
}
}
@@ -145,7 +143,7 @@ Describe 'Invoke-GiteaFileDownload' {
It 'Should capture error and mark download as failed' {
$result = Invoke-GiteaFileDownload -downloadURL 'https://gitea.example.com/raw/path/to/badfile.txt' -token 'abc123'
$result.Success | Should -Be $false
$result.Result | Should -Be 'Failure'
$result.Error | Should -Match 'Failed to download'
}
}