File: transport_tcp_test.go

package info (click to toggle)
golang-dbus 5.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, bookworm-proposed-updates, forky, sid, trixie
  • size: 592 kB
  • sloc: makefile: 2
file content (26 lines) | stat: -rw-r--r-- 517 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package dbus

import (
	"fmt"
	"net"
	"testing"
)

func TestTcpConnection(t *testing.T) {
	listener, err := net.Listen("tcp", "127.0.0.1:0")
	if err != nil {
		t.Fatal("Failed to create listener")
	}
	host, port, err := net.SplitHostPort(listener.Addr().String())
	if err != nil {
		t.Fatal("Failed to parse host/port")
	}

	conn, err := Dial(fmt.Sprintf("tcp:host=%s,port=%s", host, port))
	if err != nil {
		t.Error("Expected no error, got", err)
	}
	if conn == nil {
		t.Error("Expected connection, got nil")
	}
}