viiccwen commented on code in PR #69965:
URL: https://github.com/apache/airflow/pull/69965#discussion_r3595633149
##########
go-sdk/bundle/bundlev1/registry_test.go:
##########
@@ -66,6 +68,49 @@ func (s *RegistrySuite) TestAddDag_DuplicatePanics() {
})
}
+func (s *RegistrySuite) TestAddDag_AcceptsValidIds() {
+ reg := New()
+ for _, id := range []string{"simple", "with-dash", "with.dot",
"with_underscore", "0numeric", "café_dag", "任務", strings.Repeat("a", 250)} {
+ s.NotPanics(func() { reg.AddDag(id) })
+ }
+}
+
+func (s *RegistrySuite) TestAddDag_InvalidCharsPanic() {
+ for _, id := range []string{"", "with space", "with/slash",
"with:colon", "with\ttab"} {
+ s.PanicsWithError(
+ fmt.Sprintf(
+ "Dag ID %q must be made of alphanumeric
characters, dashes, dots, and underscores",
+ id,
+ ),
+ func() { New().AddDag(id) },
+ )
+ }
+}
+
+func (s *RegistrySuite) TestAddDag_TooLongPanics() {
+ s.PanicsWithError("Dag ID must be less than 250 characters, not 251",
func() {
+ New().AddDag(strings.Repeat("a", 251))
+ })
+}
Review Comment:
the current 250/251 boundary tests use only ASCII. Replacing this with
`len(value)` would still pass every test while incorrectly rejecting, for
example, a valid 250-character Chinese ID because it occupies 750 bytes.
Could we cover both 250 and 251 multibyte characters at the boundary? That
would protect the reason for using rune count rather than byte length.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]