MCPcopy Create free account
hub / github.com/facebook/time / TestSourceHandshakeRequestFormat

Function TestSourceHandshakeRequestFormat

ntrip/client_test.go:70–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestSourceHandshakeRequestFormat(t *testing.T) {
71 client, server := net.Pipe()
72 defer server.Close()
73
74 cfg := Config{
75 Caster: "caster.example.com:2101",
76 Mountpoint: "/EXAMPLE_MOUNT",
77 Password: "my$ecr3t",
78 Username: "user1",
79 UserAgent: "NTRIP MyApp/1.0",
80 }
81 ntripClient := NewClient(cfg)
82
83 errCh := make(chan error, 1)
84 go func() {
85 errCh <- ntripClient.sourceHandshake(client)
86 }()
87
88 // Read the complete request.
89 reader := bufio.NewReader(server)
90 var request strings.Builder
91 for {
92 line, err := reader.ReadString('\n')
93 require.NoError(t, err)
94 request.WriteString(line)
95 if strings.TrimSpace(line) == "" {
96 break
97 }
98 }
99
100 expected := "SOURCE my$ecr3t EXAMPLE_MOUNT\r\nSource-Agent: NTRIP MyApp/1.0\r\nSTR: \r\n\r\n"
101 require.Equal(t, expected, request.String())
102 require.NoError(t, <-errCh)
103}
104
105func TestSourceHandshakeMountpointStripsSlash(t *testing.T) {
106 client, server := net.Pipe()

Callers

nothing calls this directly

Calls 4

sourceHandshakeMethod · 0.95
NewClientFunction · 0.70
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…