MCPcopy
hub / github.com/probelabs/goreplay / TestInputFileMultipleFilesWithRequestsOnly

Function TestInputFileMultipleFilesWithRequestsOnly

input_file_test.go:90–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestInputFileMultipleFilesWithRequestsOnly(t *testing.T) {
91 rnd := rand.Int63()
92
93 file1, _ := os.OpenFile(fmt.Sprintf("/tmp/%d_0", rnd), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0660)
94 file1.Write([]byte("1 1 1\ntest1"))
95 file1.Write([]byte(payloadSeparator))
96 file1.Write([]byte("1 1 3\ntest2"))
97 file1.Write([]byte(payloadSeparator))
98 file1.Close()
99
100 file2, _ := os.OpenFile(fmt.Sprintf("/tmp/%d_1", rnd), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0660)
101 file2.Write([]byte("1 1 2\ntest3"))
102 file2.Write([]byte(payloadSeparator))
103 file2.Write([]byte("1 1 4\ntest4"))
104 file2.Write([]byte(payloadSeparator))
105 file2.Close()
106
107 input := NewFileInput(fmt.Sprintf("/tmp/%d*", rnd), false, 100, 0, false)
108
109 for i := '1'; i <= '4'; i++ {
110 msg, _ := input.PluginRead()
111 if msg.Meta[4] != byte(i) {
112 t.Error("Should emit requests in right order", string(msg.Meta))
113 }
114 }
115
116 os.Remove(file1.Name())
117 os.Remove(file2.Name())
118}
119
120func TestInputFileRequestsWithLatency(t *testing.T) {
121 rnd := rand.Int63()

Callers

nothing calls this directly

Calls 5

PluginReadMethod · 0.95
NewFileInputFunction · 0.85
WriteMethod · 0.80
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected