re-write some tests

This commit is contained in:
idk
2020-11-12 22:41:05 -05:00
parent 7fa46ffc98
commit 12d1bf38b2
6 changed files with 48 additions and 11 deletions

View File

@ -39,7 +39,6 @@ type Reply struct {
}
func parseReply(line string) (*Reply, error) {
fmt.Println("PARSER PARTS", line)
line = strings.TrimSpace(line)
parts := strings.Split(line, " ")
if len(parts) < 3 {
@ -54,11 +53,16 @@ func parseReply(line string) (*Reply, error) {
for _, v := range parts[2:] {
if strings.Contains(v, "FROM_PORT") {
r.From = v
if v != "FROM_PORT=0" {
r.From = v
}
} else if strings.Contains(v, "TO_PORT") {
r.To = v
if v != "TO_PORT=0" {
r.To = v
}
} else {
kvPair := strings.SplitN(v, "=", 2)
fmt.Printf("Reply, %s", parts)
if kvPair != nil {
if len(kvPair) != 2 {
return nil, fmt.Errorf("Malformed key-value-pair.\n%s\n", kvPair)