-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_test.go
94 lines (77 loc) · 2.27 KB
/
setup_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package hal
import (
"fmt"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func init() {
PARAMS.LoadParams("params.json")
}
func TestGetOpenaiKey(t *testing.T) {
// use the key from params.json
input = strings.NewReader("")
PARAMS.OpenaiKey = getOpenaiKey()
assert.NotEmpty(t, PARAMS.OpenaiKey)
// use the key from input
temp := PARAMS.OpenaiKey
PARAMS.OpenaiKey = ""
input = strings.NewReader(temp)
PARAMS.OpenaiKey = getOpenaiKey()
assert.Equal(t, temp, PARAMS.OpenaiKey)
}
func TestChooseModel(t *testing.T) {
input = strings.NewReader("")
PARAMS.ChatgptModel = chooseModel()
assert.NotEmpty(t, PARAMS.ChatgptModel)
PARAMS.ChatgptModel = ""
input = strings.NewReader("3")
PARAMS.ChatgptModel = chooseModel()
assert.Equal(t, "gpt-4", PARAMS.ChatgptModel)
}
func TestGetSpeechKey(t *testing.T) {
input = strings.NewReader("")
PARAMS.SpeechKey = getSpeechKey()
assert.NotEmpty(t, PARAMS.SpeechKey)
temp := PARAMS.SpeechKey
PARAMS.SpeechKey = ""
input = strings.NewReader(temp)
PARAMS.SpeechKey = getSpeechKey()
assert.Equal(t, temp, PARAMS.SpeechKey)
}
func TestGetSpeechRegion(t *testing.T) {
input = strings.NewReader("")
PARAMS.SpeechRegion = getSpeechRegion()
assert.NotEmpty(t, PARAMS.SpeechRegion)
temp := PARAMS.SpeechRegion
PARAMS.SpeechRegion = ""
input = strings.NewReader(temp)
PARAMS.SpeechRegion = getSpeechRegion()
assert.Equal(t, temp, PARAMS.SpeechRegion)
}
func TestCheckSpeechKeyAndRegion(t *testing.T) {
fmt.Printf("key: %s, Region: %s\n", PARAMS.SpeechKey, PARAMS.SpeechRegion)
assert.True(t, checkSpeechKeyAndRegion(PARAMS.SpeechKey, PARAMS.SpeechRegion))
}
func TestChooseLanguage(t *testing.T) {
input = strings.NewReader("")
PARAMS.Language = chooseLanguage()
assert.NotEmpty(t, PARAMS.Language)
input = strings.NewReader("1")
PARAMS.Language = chooseLanguage()
assert.Empty(t, PARAMS.Language)
}
func TestSelectLanguage(t *testing.T) {
input = strings.NewReader("en-US")
PARAMS.Language = selectLanguage()
assert.NotEmpty(t, PARAMS.Language)
}
func TestSelectVoiceLanguage(t *testing.T) {
input = strings.NewReader("en-US")
assert.Equal(t, "en-US", selectVoiceLanguage())
}
func TestSelectVoice(t *testing.T) {
input = strings.NewReader("1")
PARAMS.Voice = selectVoice("en-US")
assert.NotEmpty(t, PARAMS.Voice)
}