-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
57 lines (42 loc) · 1.36 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCoalesceConfiguration_Key_CLIOverride(t *testing.T) {
// Set up to restore the value later
currentEnvVar := os.Getenv("OPENAI_API_KEY")
defer os.Setenv("OPENAI_API_KEY", currentEnvVar)
// Set up an override
err := os.Setenv("OPENAI_API_KEY", "dummy_key")
require.NoError(t, err)
args := &argT{ApiKey: "overridden_key"}
result, _ := coalesceConfiguration(args)
assert.Equal(t, "overridden_key", result.ApiKey)
}
func TestCoalesceConfiguration_Model_CLIOverride(t *testing.T) {
// Set up to restore the value later
currentEnvVar := os.Getenv("CADRE_COMPLETION_MODEL")
defer os.Setenv("CADRE_COMPLETION_MODEL", currentEnvVar)
// Set up an override
err := os.Setenv("CADRE_COMPLETION_MODEL", "gpt-4")
require.NoError(t, err)
args := &argT{CompletionModel: "overridden_model"}
result, _ := coalesceConfiguration(args)
assert.Equal(t, "overridden_model", result.CompletionModel)
}
func TestProcessPullRequest(t *testing.T) {
// Create a mock GitHub client
mockClient := &MockGithubClient{}
// Create mock argT with URL
args := &argT{
URL: "https://github.com/user/repo/pull/123",
}
diffs, err := processPullRequest(args.URL, mockClient)
// Check if there's no error returned
assert.NoError(t, err)
fmt.Printf("%v", diffs)
}