Skip to content
This repository was archived by the owner on Jan 19, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions store/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strconv"
"strings"
"time"
"fmt"

"github.com/cloudfoundry-incubator/pat/experiment"
"github.com/cloudfoundry-incubator/pat/logs"
Expand Down Expand Up @@ -185,19 +186,36 @@ func (store *CsvStore) LoadAll() (samples []experiment.Experiment, err error) {
if err != nil {
return nil, err
}

var err_string string

samples = make([]experiment.Experiment, 0)
for _, f := range files {
base := strings.Split(f.Name(), ".")[0]
name := strings.SplitN(base, "-", 2)[1]
if len(name) > 0 {
loaded, err := store.load(f.Name(), name)
if err == nil {
samples = append(samples, loaded)
}
}
}

Iscsvfile := strings.Contains(f.Name(), ".csv")
if (Iscsvfile) {
base := strings.Split(f.Name(), ".")[0]
Isdash := strings.Contains(base, "-")
var name string = ""
if (Isdash) {
name = strings.SplitN(base, "-", 2)[1]
}
if len(name) <= 0 {
name = base
}
loaded, err := store.load(f.Name(), name)
if err == nil {
samples = append(samples, loaded)
}
} else {
err_string = err_string + "," + f.Name()

}

}
if len(err_string) > 0 {
return samples, fmt.Errorf("these files are ignored %s", err_string)
}

return
}

Expand Down
7 changes: 7 additions & 0 deletions store/csv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ var _ = Describe("Csv Store", func() {
Ω(data(samples[2].GetData())).Should(HaveLen(3))
})

It("Check CSVs files ", func() {
os.Create(dir+"/wrong-file-format")
_ , err := store.LoadAll()
Ω(err).Should(HaveOccurred())
Ω(err.Error()).To(Equal("these files are ignored ,wrong-file-format"))
})

PIt("Throws exception if header is not in correct order", func() {
})

Expand Down