Parse parses raw txtar data into a [Fixture].
(t *testing.T, data []byte)
| 228 | |
| 229 | // Parse parses raw txtar data into a [Fixture]. |
| 230 | func Parse(t *testing.T, data []byte) Fixture { |
| 231 | t.Helper() |
| 232 | |
| 233 | archive := txtar.Parse(data) |
| 234 | require.NotEmpty(t, archive.Files, "fixture archive has no files") |
| 235 | |
| 236 | sections := make(map[string][]byte, len(archive.Files)) |
| 237 | for _, f := range archive.Files { |
| 238 | sections[f.Name] = f.Data |
| 239 | } |
| 240 | return Fixture{sections: sections, t: t} |
| 241 | } |
| 242 | |
| 243 | // Request extracts the "request" fixture from raw txtar data. |
| 244 | func Request(t *testing.T, fixture []byte) []byte { |