sync: migrate ai-operator to Gitea (2026-08-10)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package fake
|
||||
|
||||
import (
|
||||
"ai-operator/internal/ai"
|
||||
"ai-operator/internal/media"
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestFakeProvider(t *testing.T) {
|
||||
p := New()
|
||||
ctx := context.Background()
|
||||
if err := p.StartSession(ctx, ai.VoiceSessionConfig{CallID: "c1"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := p.SendAudio(ctx, media.AudioChunk{CallID: "c1", Data: []byte{0, 0}, Timestamp: time.Now()}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if st := p.Stats(); st.InputAudioFrames != 1 || st.InputAudioBytes != 2 {
|
||||
t.Fatalf("stats=%+v", st)
|
||||
}
|
||||
_ = p.Close(ctx)
|
||||
}
|
||||
|
||||
func TestFakeProviderCanStartAfterClose(t *testing.T) {
|
||||
p := New()
|
||||
ctx := context.Background()
|
||||
for _, callID := range []string{"c1", "c2"} {
|
||||
if err := p.StartSession(ctx, ai.VoiceSessionConfig{CallID: callID}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := p.Close(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for range p.Events() {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user