1
0
Fork 0

Added tests to the spool package, and reworked the code around that.

This commit is contained in:
Julien Dessaux 2020-02-22 12:35:05 +01:00
parent bcfaffac24
commit 2661ce9a2b
8 changed files with 143 additions and 102 deletions

20
spool/serialize.go Normal file
View file

@ -0,0 +1,20 @@
package spool
import (
"bareos-zabbix-check/job"
"encoding/csv"
"fmt"
"io"
)
// Serialize writes a spool on the disk
func Serialize(handle io.Writer, jobs []job.Job) error {
lines := make([][]string, len(jobs))
for i := 0; i < len(jobs); i++ {
job := jobs[i]
lines[i] = make([]string, 2)
lines[i][0] = job.Name
lines[i][1] = fmt.Sprintf("%d", job.Timestamp)
}
return csv.NewWriter(handle).WriteAll(lines)
}