29 lines
869 B
Go
29 lines
869 B
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/QuantumNous/new-api/model"
|
|
relaycommon "github.com/QuantumNous/new-api/relay/common"
|
|
)
|
|
|
|
func TestAppendStreamStatusTreatsClientGoneAsDisplayNormal(t *testing.T) {
|
|
status := relaycommon.NewStreamStatus()
|
|
status.SetEndReason(relaycommon.StreamEndReasonClientGone, nil)
|
|
info := &relaycommon.RelayInfo{IsStream: true, StreamStatus: status}
|
|
other := model.NewLogOther()
|
|
|
|
appendStreamStatus(info, other)
|
|
|
|
streamInfo, ok := other.Snapshot()["stream_status"].(map[string]any)
|
|
if !ok {
|
|
t.Fatal("stream_status was not written")
|
|
}
|
|
if got := streamInfo["status"]; got != "ok" {
|
|
t.Fatalf("expected client_gone display status ok, got %v", got)
|
|
}
|
|
if got := streamInfo["end_reason"]; got != string(relaycommon.StreamEndReasonClientGone) {
|
|
t.Fatalf("expected client_gone end reason to be retained, got %v", got)
|
|
}
|
|
}
|