parent
b91fcb8e9b
commit
a1d5a02646
|
@ -43,10 +43,11 @@ cscli explain --dsn "file://myfile.log" --type nginx
|
||||||
}
|
}
|
||||||
|
|
||||||
var f *os.File
|
var f *os.File
|
||||||
|
dir := os.TempDir()
|
||||||
|
|
||||||
// we create a temporary log file if a log line has been provided
|
// we create a temporary log file if a log line has been provided
|
||||||
if logLine != "" {
|
if logLine != "" {
|
||||||
logFile = "./cscli_test_tmp.log"
|
logFile = filepath.Join(dir, "cscli_test_tmp.log")
|
||||||
f, err := os.Create(logFile) // nolint: govet
|
f, err := os.Create(logFile) // nolint: govet
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -77,6 +78,7 @@ cscli explain --dsn "file://myfile.log" --type nginx
|
||||||
|
|
||||||
cmdArgs := []string{"-c", ConfigFilePath, "-type", logType, "-dsn", dsn, "-dump-data", "./", "-no-api"}
|
cmdArgs := []string{"-c", ConfigFilePath, "-type", logType, "-dsn", dsn, "-dump-data", "./", "-no-api"}
|
||||||
crowdsecCmd := exec.Command("crowdsec", cmdArgs...)
|
crowdsecCmd := exec.Command("crowdsec", cmdArgs...)
|
||||||
|
crowdsecCmd.Dir = dir
|
||||||
output, err := crowdsecCmd.CombinedOutput()
|
output, err := crowdsecCmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(string(output))
|
fmt.Println(string(output))
|
||||||
|
@ -90,8 +92,8 @@ cscli explain --dsn "file://myfile.log" --type nginx
|
||||||
log.Fatalf("unable to remove tmp log file '%s': %+v", logFile, err)
|
log.Fatalf("unable to remove tmp log file '%s': %+v", logFile, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parserDumpFile := filepath.Join("./", cstest.ParserResultFileName)
|
parserDumpFile := filepath.Join(dir, cstest.ParserResultFileName)
|
||||||
bucketStateDumpFile := filepath.Join("./", cstest.BucketPourResultFileName)
|
bucketStateDumpFile := filepath.Join(dir, cstest.BucketPourResultFileName)
|
||||||
|
|
||||||
parserDump, err := cstest.LoadParserDump(parserDumpFile)
|
parserDump, err := cstest.LoadParserDump(parserDumpFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue