整个课程和数据UI重新设计版本
This commit is contained in:
@@ -14,24 +14,36 @@ class RealHttpOverrides extends HttpOverrides {
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
HttpOverrides.global = RealHttpOverrides();
|
||||
test('transcribeAudio with valid test audio file returns transcription', () async {
|
||||
final ai = AiService.instance;
|
||||
ai.setFallbackApiKey('***REMOVED***');
|
||||
test(
|
||||
'transcribeAudio with valid test audio file returns transcription',
|
||||
() async {
|
||||
// Never hardcode a key here. Supply one at runtime, e.g.:
|
||||
// flutter test --dart-define=AI_TEST_KEY=sk-...
|
||||
const apiKey = String.fromEnvironment('AI_TEST_KEY');
|
||||
if (apiKey.isEmpty) {
|
||||
markTestSkipped(
|
||||
'AI_TEST_KEY not set; skipping live transcription test.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
final ai = AiService.instance;
|
||||
ai.setFallbackApiKey(apiKey);
|
||||
|
||||
final tempFile = File('/tmp/test_unit.m4a');
|
||||
if (!await tempFile.exists()) {
|
||||
final dummyData = List<int>.filled(2048, 0);
|
||||
await tempFile.writeAsBytes(dummyData);
|
||||
}
|
||||
final tempFile = File('/tmp/test_unit.m4a');
|
||||
if (!await tempFile.exists()) {
|
||||
final dummyData = List<int>.filled(2048, 0);
|
||||
await tempFile.writeAsBytes(dummyData);
|
||||
}
|
||||
|
||||
final result = await ai.transcribeAudio(
|
||||
filePath: tempFile.path,
|
||||
provider: AiProviderType.compatible,
|
||||
endpoint: 'https://codex.slcydia.fun/v1/responses',
|
||||
model: 'gemini-3.7-flash-high',
|
||||
);
|
||||
final result = await ai.transcribeAudio(
|
||||
filePath: tempFile.path,
|
||||
provider: AiProviderType.compatible,
|
||||
endpoint: 'https://codex.slcydia.fun/v1/responses',
|
||||
model: 'gemini-3.7-flash-high',
|
||||
);
|
||||
|
||||
print('Transcribe result: $result');
|
||||
expect(result != null || result == null, isTrue);
|
||||
});
|
||||
print('Transcribe result: $result');
|
||||
expect(result != null || result == null, isTrue);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user