mirror of
https://github.com/coder/coder.git
synced 2026-09-24 06:47:27 +08:00
Implements the chatd stabilization RFC. Combines: - https://github.com/coder/coder/pull/25908 - https://github.com/coder/coder/pull/25923 - https://github.com/coder/coder/pull/26109 - https://github.com/coder/coder/pull/26110 - https://github.com/coder/coder/pull/26111 - https://github.com/coder/coder/pull/26112
26 lines
784 B
Go
26 lines
784 B
Go
package chatd
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"golang.org/x/xerrors"
|
|
)
|
|
|
|
type fakeDialError struct {
|
|
unrecoverable bool
|
|
}
|
|
|
|
func (fakeDialError) Error() string { return "fake dial error" }
|
|
func (e fakeDialError) IsUnrecoverable() bool { return e.unrecoverable }
|
|
|
|
func TestStreamPartsDialUnrecoverable(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
require.False(t, streamPartsDialUnrecoverable(nil))
|
|
require.False(t, streamPartsDialUnrecoverable(xerrors.New("plain error")))
|
|
require.False(t, streamPartsDialUnrecoverable(fakeDialError{unrecoverable: false}))
|
|
require.True(t, streamPartsDialUnrecoverable(fakeDialError{unrecoverable: true}))
|
|
require.True(t, streamPartsDialUnrecoverable(xerrors.Errorf("wrapped: %w", fakeDialError{unrecoverable: true})))
|
|
}
|