Skip to content

Instantly share code, notes, and snippets.

@artemnikitin
Created October 30, 2019 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artemnikitin/b959d6f59d8bbad1ee5b5bb5947b7814 to your computer and use it in GitHub Desktop.
Save artemnikitin/b959d6f59d8bbad1ee5b5bb5947b7814 to your computer and use it in GitHub Desktop.
Cleanup test output
// Replacement for https://github.com/elastic/cloud-on-k8s/blob/master/test/e2e/cmd/run/run.go#L346-L365
var f *os.File
if h.logToFile {
f, err = os.Create(testsLogFile)
if err != nil {
log.Error(err, "Can't create file for test output")
return
}
defer f.Close()
}
scanner := bufio.NewScanner(stream)
for scanner.Scan() {
text := scanner.Text()
fmt.Println(text)
if h.logToFile {
err = json.Unmarshal([]byte(text), &GoTestJSON{})
if err == nil {
f.WriteString(text)
f.WriteString("\n")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment