Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
772a5c6ba3 |
@@ -79,6 +79,36 @@ func TestParseCSVRejectsAFileWithNoASes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestParseCSVSkipsARecordThatDoesNotParse parses an as.csv with a record
|
||||
// that has too few fields between two valid records. It expects both valid
|
||||
// ASes and no error, so that one bad record does not stop make asupdate.
|
||||
func TestParseCSVSkipsARecordThatDoesNotParse(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
const asCSV = "asn,handle,description,country-code\n" +
|
||||
"1,LVLT-1,Level 3 Parent LLC,US\n" +
|
||||
"2,UDEL-DCN\n" +
|
||||
"3,MIT-GATEWAYS,Massachusetts Institute of Technology,US\n"
|
||||
|
||||
got, err := parseCSV(strings.NewReader(asCSV))
|
||||
if err != nil {
|
||||
t.Fatalf("parseCSV: %v", err)
|
||||
}
|
||||
|
||||
want := []ASInfo{
|
||||
{ASN: 1, Handle: "LVLT-1", Description: "Level 3 Parent LLC"},
|
||||
{
|
||||
ASN: 3,
|
||||
Handle: "MIT-GATEWAYS",
|
||||
Description: "Massachusetts Institute of Technology",
|
||||
},
|
||||
}
|
||||
|
||||
if !slices.Equal(got, want) {
|
||||
t.Errorf("parseCSV = %+v, want %+v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestParseCSVStopsWhenTheDownloadBreaksOff parses an as.csv whose download
|
||||
// breaks off after the first record. From then on every read fails, as on a
|
||||
// broken connection. It expects parseCSV to return that error, so that make
|
||||
|
||||
Reference in New Issue
Block a user