-
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:force require 'A' in Auditlogparts (#801)
* fix:require 'A' in Auditlogparts,force to break AuditLog when reached 'Z' * feat: drops the A case in Transation.AuditLog as it implies A and Z will be present and in the right position due to the types parsing. * breaking: drops A and Z types for auditlog parts as per @anuraaga suggestion. Currently they don't need a type as parser can enforce their presence and they are always expected to be present in the same position. --------- Co-authored-by: José Carlos Chávez <[email protected]>
- Loading branch information
Showing
8 changed files
with
97 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package types | ||
|
||
import "testing" | ||
|
||
func TestParseAuditLogParts(t *testing.T) { | ||
tests := []struct { | ||
input string | ||
expectedParts AuditLogParts | ||
expectedHasError bool | ||
}{ | ||
{"", nil, true}, | ||
{"ABCDEFGHIJKZ", []AuditLogPart("BCDEFGHIJK"), false}, | ||
{"DEFGHZ", nil, true}, | ||
{"ABCD", nil, true}, | ||
{"AMZ", nil, true}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.input, func(t *testing.T) { | ||
parts, err := ParseAuditLogParts(test.input) | ||
if test.expectedHasError { | ||
if err == nil { | ||
t.Error("expected error") | ||
} | ||
} else { | ||
if err != nil { | ||
t.Error("unexpected error") | ||
} | ||
|
||
if want, have := len(test.expectedParts), len(parts); want != have { | ||
t.Errorf("unexpected parts length, want %d, have %d", want, have) | ||
} | ||
|
||
for i, part := range test.expectedParts { | ||
if want, have := part, parts[i]; want != have { | ||
t.Errorf("unexpected part, want %q, have %q", want, have) | ||
} | ||
} | ||
} | ||
}) | ||
} | ||
} |