(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestBackendReceiveInterrupted(t *testing.T) { |
| 14 | t.Parallel() |
| 15 | |
| 16 | server := &interruptReader{} |
| 17 | server.push([]byte{'Q', 0, 0, 0, 6}) |
| 18 | |
| 19 | backend := pgproto3.NewBackend(server, nil) |
| 20 | |
| 21 | msg, err := backend.Receive() |
| 22 | if err == nil { |
| 23 | t.Fatal("expected err") |
| 24 | } |
| 25 | if msg != nil { |
| 26 | t.Fatalf("did not expect msg, but %v", msg) |
| 27 | } |
| 28 | |
| 29 | server.push([]byte{'I', 0}) |
| 30 | |
| 31 | msg, err = backend.Receive() |
| 32 | if err != nil { |
| 33 | t.Fatal(err) |
| 34 | } |
| 35 | if msg, ok := msg.(*pgproto3.Query); !ok || msg.String != "I" { |
| 36 | t.Fatalf("unexpected msg: %v", msg) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | func TestBackendReceiveUnexpectedEOF(t *testing.T) { |
| 41 | t.Parallel() |
nothing calls this directly
no test coverage detected