40 lines
896 B
Go
40 lines
896 B
Go
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() {
|
|
}
|
|
}
|
|
}
|