diff --git a/store/csv.go b/store/csv.go index 4f9bcd8..b175a85 100644 --- a/store/csv.go +++ b/store/csv.go @@ -9,6 +9,7 @@ import ( "strconv" "strings" "time" + "fmt" "github.com/cloudfoundry-incubator/pat/experiment" "github.com/cloudfoundry-incubator/pat/logs" @@ -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 } diff --git a/store/csv_test.go b/store/csv_test.go index abc9141..2937563 100644 --- a/store/csv_test.go +++ b/store/csv_test.go @@ -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() { })