Added tests to the spool package, and reworked the code around that.
This commit is contained in:
parent
bcfaffac24
commit
2661ce9a2b
8 changed files with 143 additions and 102 deletions
20
spool/serialize.go
Normal file
20
spool/serialize.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue