Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package debugger
|
|
|
|
import (
|
|
"net"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestApplyDebuggerOptionsDefaults(t *testing.T) {
|
|
o := applyDebuggerOptions()
|
|
require.Equal(t, DefaultAddress, o.address)
|
|
require.Equal(t, DefaultWorkingDir, o.workingDir)
|
|
require.NotNil(t, o.disconnectChan)
|
|
}
|
|
|
|
func TestApplyDebuggerOptionsWithOverrides(t *testing.T) {
|
|
c := make(chan struct{})
|
|
l, err := net.Listen("tcp", "127.0.0.1:0")
|
|
require.NoError(t, err)
|
|
t.Cleanup(func() {
|
|
require.NoError(t, l.Close())
|
|
})
|
|
|
|
clientRan := false
|
|
serverStarted := false
|
|
|
|
o := applyDebuggerOptions(
|
|
Address("127.0.0.1:9999"),
|
|
DisconnectChannel(c),
|
|
Listener(l),
|
|
WorkingDir("/tmp/work"),
|
|
BinaryArgs("a", "b"),
|
|
ClientRunHook(func() { clientRan = true }),
|
|
ServerStartHook(func() { serverStarted = true }),
|
|
)
|
|
|
|
require.Equal(t, "127.0.0.1:9999", o.address)
|
|
require.Equal(t, c, o.disconnectChan)
|
|
require.Equal(t, l, o.listener)
|
|
require.Equal(t, "/tmp/work", o.workingDir)
|
|
require.Equal(t, []string{"a", "b"}, o.binaryArgs)
|
|
|
|
o.clientRunHook()
|
|
o.serverStartHook()
|
|
require.True(t, clientRan)
|
|
require.True(t, serverStarted)
|
|
}
|
|
|
|
func TestDisableDelveLogging(t *testing.T) {
|
|
require.NoError(t, disableDelveLogging())
|
|
}
|