You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FLEcli/cmd/csv_write_test.go

66 lines
1.6 KiB

package cmd
import (
"reflect"
"testing"
)
func Test_csvDate(t *testing.T) {
type args struct {
inputDate string
}
tests := []struct {
name string
args args
wantOutputDate string
}{
{
"Happy case",
args{inputDate: "2020-07-13"},
"13/07/20",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotOutputDate := csvDate(tt.args.inputDate); gotOutputDate != tt.wantOutputDate {
t.Errorf("csvDate() = %v, want %v", gotOutputDate, tt.wantOutputDate)
}
})
}
}
func Test_buildCsv(t *testing.T) {
sampleFilledLog1 := []LogLine{
{MyCall: "ON4KJM/P", Call: "S57LC", Date: "2020-05-24", Time: "1310", Band: "20m", Frequency: "14.045", Mode: "CW", RSTsent: "599", RSTrcvd: "599", MySOTA: "ON/ON-001", Operator: "ON4KJM", Nickname: "ONFF-0259-1"},
{MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", MySOTA: "ON/ON-001", Operator: "ON4KJM"},
}
//add case with no SOTA and with or no comment
expectedOutput1 := []string{
"V2,ON4KJM/P,ON/ON-001,24/05/20,1310,14MHz,CW,S57LC",
"V2,ON4KJM/P,ON/ON-001,24/05/20,1312,14MHz,CW,ON4LY",
}
type args struct {
fullLog []LogLine
}
tests := []struct {
name string
args args
wantCsvList []string
}{
{
"Happy case",
args{fullLog: sampleFilledLog1},
expectedOutput1,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotCsvList := buildCsv(tt.args.fullLog); !reflect.DeepEqual(gotCsvList, tt.wantCsvList) {
t.Errorf("buildCsv() = %v, want %v", gotCsvList, tt.wantCsvList)
}
})
}
}