66 "os"
77 "testing"
88
9+ openai "github.com/sashabaranov/go-openai"
910 "github.com/stretchr/testify/assert"
1011 "github.com/stretchr/testify/require"
11- openai "github.com/sashabaranov/go-openai"
1212)
1313
1414// TestBatchTranslationMock tests batch translation using a mock server
@@ -20,17 +20,17 @@ func TestBatchTranslationMock(t *testing.T) {
2020 if ! contains (content , `["Hello","World"]` ) {
2121 return nil , fmt .Errorf ("unexpected prompt: %s" , content )
2222 }
23-
23+
2424 // Return valid JSON array
2525 return createMockResponse (`["你好", "世界"]` ), nil
2626 }
27-
27+
2828 server1 := NewMockLLMServer (successHandler )
2929 defer server1 .Close ()
3030
3131 trans1 := NewLLMTranslator ("key" , server1 .URL , "model" )
3232 results , err := trans1 .TranslateBatch (context .Background (), []string {"Hello" , "World" }, "en" , "zh-CN" )
33-
33+
3434 require .NoError (t , err )
3535 assert .Equal (t , []string {"你好" , "世界" }, results )
3636
@@ -72,7 +72,7 @@ func TestDeepSeekIntegration(t *testing.T) {
7272 if testing .Short () {
7373 t .Skip ("Skipping integration test in short mode" )
7474 }
75-
75+
7676 apiKey := os .Getenv ("OPENAI_API_KEY" )
7777 if apiKey == "" {
7878 t .Skip ("Skipping integration test: OPENAI_API_KEY not set" )
@@ -119,7 +119,7 @@ func TestEdgeCases(t *testing.T) {
119119 return createMockResponse (`[]` ), nil
120120 })
121121 defer server .Close ()
122-
122+
123123 trans := NewLLMTranslator ("key" , server .URL , "model" )
124124 res , err := trans .TranslateBatch (context .Background (), []string {}, "en" , "zh" )
125125 assert .NoError (t , err )
@@ -132,7 +132,7 @@ func TestEdgeCases(t *testing.T) {
132132 return createMockResponse (`["Quote \"", "Newline \\n"]` ), nil
133133 })
134134 defer server2 .Close ()
135-
135+
136136 trans2 := NewLLMTranslator ("key" , server2 .URL , "model" )
137137 res2 , err := trans2 .TranslateBatch (context .Background (), specials , "en" , "zh" )
138138 assert .NoError (t , err )
0 commit comments