(t *testing.T)
| 146 | } |
| 147 | |
| 148 | func TestInputFileMultipleFilesWithRequestsAndResponses(t *testing.T) { |
| 149 | rnd := rand.Int63() |
| 150 | |
| 151 | file1, _ := os.OpenFile(fmt.Sprintf("/tmp/%d_0", rnd), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0660) |
| 152 | file1.Write([]byte("1 1 1\nrequest1")) |
| 153 | file1.Write([]byte(payloadSeparator)) |
| 154 | file1.Write([]byte("2 1 1\nresponse1")) |
| 155 | file1.Write([]byte(payloadSeparator)) |
| 156 | file1.Write([]byte("1 2 3\nrequest2")) |
| 157 | file1.Write([]byte(payloadSeparator)) |
| 158 | file1.Write([]byte("2 2 3\nresponse2")) |
| 159 | file1.Write([]byte(payloadSeparator)) |
| 160 | file1.Close() |
| 161 | |
| 162 | file2, _ := os.OpenFile(fmt.Sprintf("/tmp/%d_1", rnd), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0660) |
| 163 | file2.Write([]byte("1 3 2\nrequest3")) |
| 164 | file2.Write([]byte(payloadSeparator)) |
| 165 | file2.Write([]byte("2 3 2\nresponse3")) |
| 166 | file2.Write([]byte(payloadSeparator)) |
| 167 | file2.Write([]byte("1 4 4\nrequest4")) |
| 168 | file2.Write([]byte(payloadSeparator)) |
| 169 | file2.Write([]byte("2 4 4\nresponse4")) |
| 170 | file2.Write([]byte(payloadSeparator)) |
| 171 | file2.Close() |
| 172 | |
| 173 | input := NewFileInput(fmt.Sprintf("/tmp/%d*", rnd), false, 100, 0, false) |
| 174 | |
| 175 | for i := '1'; i <= '4'; i++ { |
| 176 | msg, _ := input.PluginRead() |
| 177 | if msg.Meta[0] != '1' && msg.Meta[4] != byte(i) { |
| 178 | t.Error("Shound emit requests in right order", string(msg.Meta)) |
| 179 | } |
| 180 | |
| 181 | msg, _ = input.PluginRead() |
| 182 | if msg.Meta[0] != '2' && msg.Meta[4] != byte(i) { |
| 183 | t.Error("Shound emit responses in right order", string(msg.Meta)) |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | os.Remove(file1.Name()) |
| 188 | os.Remove(file2.Name()) |
| 189 | } |
| 190 | |
| 191 | func TestInputFileLoop(t *testing.T) { |
| 192 | rnd := rand.Int63() |
nothing calls this directly
no test coverage detected