refactor: Update AFTN message parsing logic

The code changes in `aviation_parser_test.go` update the AFTN message parsing logic. The `ParseHeader` function now returns an additional error value, allowing for better error handling. The tests have been updated to reflect this change, ensuring that the parsing function handles errors correctly. This refactor improves the reliability and maintainability of the AFTN message parsing functionality.
This commit is contained in:
windyboy
2024-07-20 22:33:22 +08:00
parent 135ef12c4d
commit e8be157bd3
2 changed files with 47 additions and 46 deletions
+3 -3
View File
@@ -125,7 +125,7 @@ NNNN
})
Describe("ParseBody", func() {
Context("with ARR body", func() {
parser := DefaultBodyParser()
parser := NewBodyParser()
It("should parse the body (ARR-AB123-SSR1234-KJFK-KLAX) correctly", func() {
body := "(ARR-AB123-SSR1234-KJFK-KLAX)"
parsedBody, err := parser.Parse(body)
@@ -143,7 +143,7 @@ NNNN
})
Context("with DEP body", func() {
parser := DefaultBodyParser()
parser := NewBodyParser()
It("should parse the body (DEP-AB123-SSR1234-KJFK-1500-KLAX) correctly", func() {
body := "(DEP-AB123-SSR1234-KJFK-1500-KLAX)"
parsedBody, err := parser.Parse(body)
@@ -161,7 +161,7 @@ NNNN
})
Context("with FPL body", func() {
parser := DefaultBodyParser()
parser := NewBodyParser()
It("should parse the body correctly", func() {
body := `(FPL-CCA1532-IS
-A332/H