Skip to content

Commit

Permalink
somet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed Jun 29, 2024
1 parent 4b293ce commit bde406c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
2 changes: 2 additions & 0 deletions finetuna.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function Import-ModuleFile {
else { $ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText($Path))), $null, $null) }
}

# import internal functions from PSOpenAI bc I have changes
foreach ($file in (Get-ChildItem -Path $privatedir -Filter *.ps1)) {
. Import-ModuleFile -Path $file.FullName
}
Expand All @@ -39,6 +40,7 @@ foreach ($function in (Get-ChildItem "$ModuleRoot\public" -Filter "*.ps1" -Recur
. Import-ModuleFile -Path $function.FullName
}

# i need these psopenai public things to use my internal functions
foreach ($file in (Get-ChildItem -Path $publicdir -Filter *.ps1)) {
. Import-ModuleFile -Path $file.FullName
}
Expand Down
30 changes: 9 additions & 21 deletions tests/finetuna.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

BeforeAll {
BeforeEach {
if (-not $env:OPENAI_API_KEY) {
throw "OPENAI_API_KEY environment variable is not set."
}
Expand All @@ -14,6 +14,14 @@ BeforeAll {
}

Describe "finetuna Module Tests" {
Context "Clear-TuneProvider" {
It "Should clear the provider configuration" {
Clear-TuneProvider
$provider = Get-TuneProvider
$provider.ApiKey | Should -BeNullOrEmpty
$provider.ApiType | Should -BeNullOrEmpty
}
}
Context "Set-TuneProvider" {
It "Should set the API key and configuration" {
$splat = @{
Expand All @@ -25,17 +33,6 @@ Describe "finetuna Module Tests" {
$provider.ApiType | Should -Be 'openai'
(Get-OpenAIContext).ApiKey | Should -Not -BeNullOrEmpty
}

$context = Get-OpenAIContext
$global:PSDefaultParameterValues['Get-OpenAIAPIParameter:Parameters'] = @{
ApiKey = $context.ApiKey
AuthType = $context.AuthType
Organization = $context.Organization
ApiBase = $context.ApiBase
ApiVersion = $context.ApiVersion
TimeoutSec = $context.TimeoutSec
MaxRetryCount = $context.MaxRetryCount
}
}

Context "Get-TuneProvider" {
Expand Down Expand Up @@ -116,15 +113,6 @@ Describe "finetuna Module Tests" {
}
}

Context "Clear-TuneProvider" {
It "Should clear the provider configuration" {
Clear-TuneProvider
$provider = Get-TuneProvider
$provider.ApiKey | Should -BeNullOrEmpty
$provider.ApiType | Should -BeNullOrEmpty
}
}

Context "Get-Embedding" {
It "Should generate an embedding for the given text" {
$result = Get-Embedding -Text "Hello, world!"
Expand Down

0 comments on commit bde406c

Please sign in to comment.