1
0
Fork 0
mirror of https://github.com/on4kjm/FLEcli.git synced 2025-02-17 04:22:36 +01:00
FLEcli/cmd/csv_write_test.go

66 lines
1.6 KiB
Go
Raw Normal View History

2020-07-13 22:40:49 +02:00
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"},
}
2020-07-16 17:22:12 +02:00
//add case with no SOTA and with or no comment
2020-07-13 22:40:49 +02:00
expectedOutput1 := []string{
2020-07-16 17:22:12 +02:00
"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",
2020-07-13 22:40:49 +02:00
}
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)
}
})
}
}