40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
|
|
package notify
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"errors"
|
||
|
|
"net"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestDedicatedAttachPreservesRemoteRejection(t *testing.T) {
|
||
|
|
for _, op := range []string{"attach", "attach-shared", "replace", "replace-shared"} {
|
||
|
|
t.Run(op, func(t *testing.T) {
|
||
|
|
bulk := newBulkHandle(context.Background(), nil, clientFileScope(), BulkOpenRequest{BulkID: "rejected", DataID: 1, Dedicated: true}, 0, nil, nil, 0, nil, nil, nil, nil, nil)
|
||
|
|
rejection := errors.New("remote application rejected bulk")
|
||
|
|
bulk.markAcceptReady(rejection)
|
||
|
|
bulk.markReset(rejection)
|
||
|
|
left, right := net.Pipe()
|
||
|
|
defer left.Close()
|
||
|
|
defer right.Close()
|
||
|
|
var err error
|
||
|
|
switch op {
|
||
|
|
case "attach":
|
||
|
|
err = bulk.attachDedicatedConn(left)
|
||
|
|
case "attach-shared":
|
||
|
|
err = bulk.attachDedicatedConnShared(left)
|
||
|
|
case "replace":
|
||
|
|
_, _, err = bulk.replaceDedicatedConn(left)
|
||
|
|
case "replace-shared":
|
||
|
|
_, _, err = bulk.replaceDedicatedConnShared(left)
|
||
|
|
}
|
||
|
|
if !errors.Is(err, rejection) {
|
||
|
|
t.Fatalf("attach lost rejection: %v", err)
|
||
|
|
}
|
||
|
|
if bulk.dedicatedConnSnapshot() != nil {
|
||
|
|
t.Fatal("rejected bulk retained connection")
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|