Skip to content

Commit

Permalink
Make generated json files end with newlines (#2087)
Browse files Browse the repository at this point in the history
  • Loading branch information
efd6 authored Oct 1, 2024
1 parent 8b55069 commit 74eb18f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion internal/docs/sample_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package docs

import (
"bytes"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -54,7 +55,7 @@ func renderSampleEvent(packageRoot, dataStreamName string) (string, error) {
stripDataStreamFolderSuffix(dataStreamName)))
}
builder.WriteString("```json\n")
builder.Write(formatted)
builder.Write(bytes.TrimSpace(formatted))
builder.WriteString("\n```")
return builder.String(), nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/testrunner/runners/pipeline/testresult.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func writeTestResult(testCasePath string, result *testResult, specVersion semver
if err != nil {
return fmt.Errorf("marshalling test result failed: %w", err)
}
err = os.WriteFile(filepath.Join(testCaseDir, expectedTestResultFile(testCaseFile)), data, 0644)
err = os.WriteFile(filepath.Join(testCaseDir, expectedTestResultFile(testCaseFile)), append(data, '\n'), 0644)
if err != nil {
return fmt.Errorf("writing test result failed: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/testrunner/runners/system/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ func writeSampleEvent(path string, doc common.MapStr, specVersion semver.Version
return fmt.Errorf("marshalling sample event failed: %w", err)
}

err = os.WriteFile(filepath.Join(path, "sample_event.json"), body, 0644)
err = os.WriteFile(filepath.Join(path, "sample_event.json"), append(body, '\n'), 0644)
if err != nil {
return fmt.Errorf("writing sample event failed: %w", err)
}
Expand Down
1 change: 0 additions & 1 deletion test/packages/parallel/ti_anomali_logsdb/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ An example event for `threatstream` looks as following:
}
}
}

```

**Exported fields**
Expand Down

0 comments on commit 74eb18f

Please sign in to comment.