Validate Sota chaser log

pull/75/head
Jean-Marc MEESSEN 4 years ago committed by GitHub
parent 4732960e5a
commit 8d03018796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,7 +16,7 @@ But is also the alibi to learn and explore GO.
## Installing ## Installing
The tool is installed by downloading and unpacking the archive for your operating system. The tool is installed by downloading and unpacking the archive for your operating system.
A version is available for Windows, MacOS, Linux and ARM (RaspeberyPi). A version is available for Windows, MacOS, Linux and ARM (RaspberryPi).
Most of them are available as 32 or 64 bit applications. Most of them are available as 32 or 64 bit applications.
A docker version is also available. A docker version is also available.
@ -29,11 +29,11 @@ Detailed installation instructions can be found [at this page](doc/install.md).
Detailed explanations can be found [on this page](doc/usage.md). Detailed explanations can be found [on this page](doc/usage.md).
Most comon use cases are described hereafter as examples. Most common use cases are described hereafter as examples.
### Example: validate the FLE syntax of a file ### Example: validate the FLE syntax of a file
To load and validate the FLE formated file (`myActivation.txt`: To load and validate the FLE formatted file (`myActivation.txt`):
``` ```
./FLEcli load myActivation.txt ./FLEcli load myActivation.txt

@ -1,6 +1,13 @@
# What's new? # What's new?
## v0.1.2 ## v0.1.3
* Enable FLEcli to be used to generate CSV chaser logs
* Fix the display for longer calls (issue #61)
## Previous releases
### v0.1.2
* DATE keyword is now optional * DATE keyword is now optional
* Date can have several delimiter ("-", "/", ".", or " ") * Date can have several delimiter ("-", "/", ".", or " ")
@ -11,8 +18,6 @@
* Time is now correctly inferred when start and end of gap is in the same minute * Time is now correctly inferred when start and end of gap is in the same minute
* Correct some typos and bugs * Correct some typos and bugs
## Previous releases
### v0.1.1 ### v0.1.1
* Improved test coverage * Improved test coverage
* Improved build automation * Improved build automation

@ -59,9 +59,11 @@ func validateDataForSotaCsv(loadedLogFile []LogLine) error {
return fmt.Errorf("No QSO found") return fmt.Errorf("No QSO found")
} }
isNoMySota := false
//MySOTA and MyCall are header values. If missing on the first line, it will be missing at every line //MySOTA and MyCall are header values. If missing on the first line, it will be missing at every line
if loadedLogFile[0].MySOTA == "" { if loadedLogFile[0].MySOTA == "" {
return fmt.Errorf("Missing MY-SOTA reference") //if not set, we might be dealing with a chaser log
isNoMySota = true
} }
if loadedLogFile[0].MyCall == "" { if loadedLogFile[0].MyCall == "" {
return fmt.Errorf("Missing MyCall") return fmt.Errorf("Missing MyCall")
@ -109,6 +111,21 @@ func validateDataForSotaCsv(loadedLogFile []LogLine) error {
} }
errorsBuffer.WriteString(fmt.Sprintf("missing QSO time %s", errorLocation)) errorsBuffer.WriteString(fmt.Sprintf("missing QSO time %s", errorLocation))
} }
//FIXME: if isNoMySota and MySota defined means that it was defined later in the log file
if (isNoMySota && loadedLogFile[i].MySOTA != "") {
if errorsBuffer.String() != "" {
errorsBuffer.WriteString(fmt.Sprintf(", "))
}
errorsBuffer.WriteString(fmt.Sprintf("encountered an unexpexted MySota reference while processing what should be a chaser log %s", errorLocation))
}
if (isNoMySota && loadedLogFile[i].SOTA == "") {
if errorsBuffer.String() != "" {
errorsBuffer.WriteString(fmt.Sprintf(", "))
}
errorsBuffer.WriteString(fmt.Sprintf("missing SOTA reference while attempting to process chaser log %s", errorLocation))
}
} }
if errorsBuffer.String() != "" { if errorsBuffer.String() != "" {
return fmt.Errorf(errorsBuffer.String()) return fmt.Errorf(errorsBuffer.String())

@ -15,7 +15,7 @@ func Test_validateDataForSotaCsv(t *testing.T) {
want error want error
}{ }{
{ {
"Happy Case", "Happy Case (activator)",
args{loadedLogFile: []LogLine{ args{loadedLogFile: []LogLine{
{Date: "date", MyCall: "myCall", MySOTA: "mySota", Mode: "mode", Band: "band", Time: "time", Call: "call"}, {Date: "date", MyCall: "myCall", MySOTA: "mySota", Mode: "mode", Band: "band", Time: "time", Call: "call"},
{Date: "date", MyCall: "myCall", MySOTA: "mySota", Mode: "mode", Band: "band", Time: "time", Call: "call"}, {Date: "date", MyCall: "myCall", MySOTA: "mySota", Mode: "mode", Band: "band", Time: "time", Call: "call"},
@ -23,6 +23,15 @@ func Test_validateDataForSotaCsv(t *testing.T) {
}, },
nil, nil,
}, },
{
"Happy Case (chaser)",
args{loadedLogFile: []LogLine{
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call", SOTA: "Sota1"},
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call", SOTA: "Sota2"},
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call", SOTA: "Sota3"}},
},
nil,
},
{ {
"Missing Date", "Missing Date",
args{loadedLogFile: []LogLine{ args{loadedLogFile: []LogLine{
@ -42,13 +51,31 @@ func Test_validateDataForSotaCsv(t *testing.T) {
fmt.Errorf("Missing MyCall"), fmt.Errorf("Missing MyCall"),
}, },
{ {
"Missing MySota", "Neither Activator nor Chaser",
args{loadedLogFile: []LogLine{
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:01", Call: "call"},
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:02", Call: "call"},
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:03", Call: "call"}},
},
fmt.Errorf("missing SOTA reference while attempting to process chaser log for log entry at 12:01 (#1), missing SOTA reference while attempting to process chaser log for log entry at 12:02 (#2), missing SOTA reference while attempting to process chaser log for log entry at 12:03 (#3)"),
},
{
"SOTA Chaser log with one reference missing",
args{loadedLogFile: []LogLine{
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:01", Call: "call", SOTA: "Sota1"},
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:02", Call: "call"},
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:03", Call: "call", SOTA: "Sota3"}},
},
fmt.Errorf("missing SOTA reference while attempting to process chaser log for log entry at 12:02 (#2)"),
},
{
"SOTA Chaser log with mySota redefinition",
args{loadedLogFile: []LogLine{ args{loadedLogFile: []LogLine{
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call"}, {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:01", Call: "call", SOTA: "Sota1"},
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call"}, {Date: "date", MyCall: "myCall", MySOTA: "mySota", Mode: "mode", Band: "band", Time: "12:02", Call: "call", SOTA: "Sota2"},
{Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call"}}, {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:03", Call: "call", SOTA: "Sota3"}},
}, },
fmt.Errorf("Missing MY-SOTA reference"), fmt.Errorf("encountered an unexpexted MySota reference while processing what should be a chaser log for log entry at 12:02 (#2)"),
}, },
{ {
"Misc. missing data (Band, Time, Mode, Call)", "Misc. missing data (Band, Time, Mode, Call)",

@ -61,13 +61,23 @@ func Test_buildCsv(t *testing.T) {
{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", SOTA: "ON/ON-002"}, {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", SOTA: "ON/ON-002"},
{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", Comment: "QSL Message"}, {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", Comment: "QSL Message"},
} }
//add case with no SOTA and with or no comment
expectedOutput2 := []string{ expectedOutput2 := []string{
"V2,ON4KJM/P,ON/ON-001,24/05/20,1310,14MHz,CW,S57LC,ON/ON-002", "V2,ON4KJM/P,ON/ON-001,24/05/20,1310,14MHz,CW,S57LC,ON/ON-002",
"V2,ON4KJM/P,ON/ON-001,24/05/20,1312,14MHz,CW,ON4LY,,QSL Message", "V2,ON4KJM/P,ON/ON-001,24/05/20,1312,14MHz,CW,ON4LY,,QSL Message",
} }
//Chaser log
chaserLog := []LogLine{
{MyCall: "ON4KJM/P", Call: "S57LC", Date: "2020-05-24", Time: "1310", Band: "20m", Frequency: "14.045", Mode: "CW", RSTsent: "599", RSTrcvd: "599", Operator: "ON4KJM", Nickname: "ONFF-0259-1", SOTA: "ON/ON-002"},
{MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", Operator: "ON4KJM", Comment: "QSL Message", SOTA: "ON/ON-003"},
}
expectedChaserOutput3 := []string{
"V2,ON4KJM/P,,24/05/20,1310,14MHz,CW,S57LC,ON/ON-002",
"V2,ON4KJM/P,,24/05/20,1312,14MHz,CW,ON4LY,ON/ON-003,QSL Message",
}
type args struct { type args struct {
fullLog []LogLine fullLog []LogLine
} }
@ -86,6 +96,11 @@ func Test_buildCsv(t *testing.T) {
args{fullLog: sampleFilledLog2}, args{fullLog: sampleFilledLog2},
expectedOutput2, expectedOutput2,
}, },
{
"Chaser Log",
args{fullLog: chaserLog},
expectedChaserOutput3,
},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {

Loading…
Cancel
Save