okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
b0282b1
main
1package daemon 2 3import ( 4"bufio" 5"context" 6"errors" 7"strings" 8"testing" 9) 10 11// Store publication can fail after commit, so reconnect must rebuild from the 12// durable snapshot rather than consume incomplete canonical publication. 13func TestHistoryPublicationFailureRequiresFreshSnapshot (t * testing.T ) { 14client := NewChatClient (NewConnection (ConnectionSnapshot {Port :1 },nil ),"s" ) 15client .afterGeneration ,client .afterSeq = "abcdefghijklmnopqrstuv" ,7 16wire := `data: {"generation":"abcdefghijklmnopqrstuv","cursor":8,"events":[{"type":"error","sequence":8,"data":{"run_id":null,"code":"history_publication_failed","message":"temporarily unavailable"}}]}` + "\n\n" 17callbacks := 0 18err := client .readStream (context .Background (),bufio .NewScanner (strings .NewReader (wire )),nil ,func (StreamEvent )error {callbacks ++ ;return nil }) 19var failure * StreamError 20if ! errors .As (err ,& failure )|| failure .Kind != StreamTransient || callbacks != 0 || client .afterSeq != - 1 || client .afterGeneration != "" { 21t .Fatalf ("publication failure did not require a fresh snapshot: error=%v callbacks=%d cursor=%s/%d" ,err ,callbacks ,client .afterGeneration ,client .afterSeq ) 22 } 23}