Skip to content

Commit

Permalink
more test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e committed Oct 2, 2024
1 parent 1f317d1 commit 1374375
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 57 deletions.
60 changes: 30 additions & 30 deletions backend/schema/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ func TestValidate(t *testing.T) {
}
`,
errs: []string{
`4:21-21: duplicate config "FTL_ENDPOINT", first defined at 3:20`,
`5:21-21: duplicate config "FTL_ENDPOINT", first defined at 3:20`,
`4:21: duplicate config "FTL_ENDPOINT", first defined at 3:20`,
`5:21: duplicate config "FTL_ENDPOINT", first defined at 3:20`,
},
},
{name: "DuplicateSecrets",
Expand All @@ -235,8 +235,8 @@ func TestValidate(t *testing.T) {
}
`,
errs: []string{
`4:6-6: duplicate secret "MY_SECRET", first defined at 3:6`,
`5:6-6: duplicate secret "MY_SECRET", first defined at 3:6`,
`4:6: duplicate secret "MY_SECRET", first defined at 3:6`,
`5:6: duplicate secret "MY_SECRET", first defined at 3:6`,
},
},
{name: "ConfigAndSecretsWithSameName",
Expand All @@ -255,7 +255,7 @@ func TestValidate(t *testing.T) {
}
`,
errs: []string{
`4:6-6: duplicate database "MY_DB", first defined at 3:6`,
`4:6: duplicate database "MY_DB", first defined at 3:6`,
},
},
{name: "ValueEnumMismatchedVariantTypes",
Expand All @@ -281,10 +281,10 @@ func TestValidate(t *testing.T) {
}
`,
errs: []string{
`4:13-13: unknown reference "one.C", is the type annotated and exported?`,
`6:6-6: "FSM" has no start states`,
`7:18-18: unknown source verb "one.C"`,
`7:27-27: destination state "one.B" must be a sink but is verb`,
`4:13: unknown reference "one.C", is the type annotated and exported?`,
`6:6: "FSM" has no start states`,
`7:18: unknown source verb "one.C"`,
`7:27: destination state "one.B" must be a sink but is verb`,
},
},
{name: "DuplicateFSM",
Expand All @@ -308,7 +308,7 @@ func TestValidate(t *testing.T) {
}
`,
errs: []string{
`14:6-6: duplicate fsm "FSM", first defined at 9:6`,
`14:6: duplicate fsm "FSM", first defined at 9:6`,
},
},
{name: "NonFSMVerbsWithRetry",
Expand All @@ -322,8 +322,8 @@ func TestValidate(t *testing.T) {
}
`,
errs: []string{
`4:7-7: retries can only be added to subscribers or FSM transitions`,
`6:7-7: retries can only be added to subscribers or FSM transitions`,
`4:7: retries can only be added to subscribers or FSM transitions`,
`6:7: retries can only be added to subscribers or FSM transitions`,
},
},
{name: "InvalidRetryDurations",
Expand Down Expand Up @@ -373,18 +373,18 @@ func TestValidate(t *testing.T) {
}
`,
errs: []string{
`10:7-7: retry must have a minimum backoff`,
`12:7-7: retry must have a minimum backoff`,
`14:7-7: could not parse min backoff duration: could not parse retry duration: duration has unit "m" out of order - units need to be ordered from largest to smallest - eg '1d3h2m'`,
`17:7-7: verb can not have multiple instances of retry`,
`19:7-7: could not parse min backoff duration: could not parse retry duration: duration has unknown unit "mins" - use 'd', 'h', 'm' or 's', eg '1d' or '30s'`,
`21:7-7: max backoff duration (1s) needs to be at least as long as initial backoff (1m)`,
`23:7-7: could not parse min backoff duration: retry backoff can not be larger than 1d`,
`25:7-7: can not define a backoff duration when retry count is 0 and no catch is declared`,
`30:7-7: catch can only be defined on verbs`,
`4:7-7: could not parse min backoff duration: could not parse retry duration: duration has unit "m" out of order - units need to be ordered from largest to smallest - eg '1d3h2m'`,
`6:7-7: could not parse min backoff duration: could not parse retry duration: duration has unit "d" out of order - units need to be ordered from largest to smallest - eg '1d3h2m'`,
`8:7-7: could not parse min backoff duration: retry must have a minimum backoff of 1s`,
`10:7: retry must have a minimum backoff`,
`12:7: retry must have a minimum backoff`,
`14:7: could not parse min backoff duration: could not parse retry duration: duration has unit "m" out of order - units need to be ordered from largest to smallest - eg '1d3h2m'`,
`17:7: verb can not have multiple instances of retry`,
`19:7: could not parse min backoff duration: could not parse retry duration: duration has unknown unit "mins" - use 'd', 'h', 'm' or 's', eg '1d' or '30s'`,
`21:7: max backoff duration (1s) needs to be at least as long as initial backoff (1m)`,
`23:7: could not parse min backoff duration: retry backoff can not be larger than 1d`,
`25:7: can not define a backoff duration when retry count is 0 and no catch is declared`,
`30:7: catch can only be defined on verbs`,
`4:7: could not parse min backoff duration: could not parse retry duration: duration has unit "m" out of order - units need to be ordered from largest to smallest - eg '1d3h2m'`,
`6:7: could not parse min backoff duration: could not parse retry duration: duration has unit "d" out of order - units need to be ordered from largest to smallest - eg '1d3h2m'`,
`8:7: could not parse min backoff duration: retry must have a minimum backoff of 1s`,
},
},
{name: "InvalidRetryInvalidSpace",
Expand Down Expand Up @@ -428,11 +428,11 @@ func TestValidate(t *testing.T) {
}
`,
errs: []string{
`20:6-6: verb wrongEventType: request type test.eventA differs from subscription's event type test.eventB`,
`23:6-6: verb SourceCantSubscribe: must be a sink to subscribe but found response type test.eventB`,
`23:6-6: verb SourceCantSubscribe: request type Unit differs from subscription's event type test.eventB`,
`26:6-6: verb EmptyCantSubscribe: request type Unit differs from subscription's event type test.eventB`,
`7:5-5: invalid name: must consist of only letters, numbers and underscores, and start with a lowercase letter.`,
`20:6: verb wrongEventType: request type test.eventA differs from subscription's event type test.eventB`,
`23:6: verb SourceCantSubscribe: must be a sink to subscribe but found response type test.eventB`,
`23:6: verb SourceCantSubscribe: request type Unit differs from subscription's event type test.eventB`,
`26:6: verb EmptyCantSubscribe: request type Unit differs from subscription's event type test.eventB`,
`7:5: invalid name: must consist of only letters, numbers and underscores, and start with a lowercase letter.`,
},
},
{
Expand Down Expand Up @@ -545,7 +545,7 @@ func TestValidateModuleWithSchema(t *testing.T) {
+calls one.one
}`,
errs: []string{
`4:14-14: verb "one.one" must be exported`,
`4:14: verb "one.one" must be exported`,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion go-runtime/schema/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (cd *combinedData) propagateTypeErrors() {
"unsupported request type %q", refNativeName))
}
if pt.Response == n {
cd.error(builderrors.Errorf(pt.Request.Position().ToErrorPos(),
cd.error(builderrors.Errorf(pt.Response.Position().ToErrorPos(),
"unsupported response type %q", refNativeName))
}
case *schema.Field:
Expand Down
52 changes: 26 additions & 26 deletions go-runtime/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,54 +570,54 @@ func TestErrorReporting(t *testing.T) {
// failing/failing.go
expectedParent := []string{
`12:13-34: expected string literal for argument at index 0`,
`15:18-18: duplicate config declaration for "failing.FTL_CONFIG_ENDPOINT"; already declared at "37:18"`,
`18:18-18: duplicate secret declaration for "failing.FTL_SECRET_ENDPOINT"; already declared at "38:18"`,
`21:14-14: duplicate database declaration for "failing.testDb"; already declared at "41:14"`,
`15:18: duplicate config declaration for "failing.FTL_CONFIG_ENDPOINT"; already declared at "37:18"`,
`18:18: duplicate secret declaration for "failing.FTL_SECRET_ENDPOINT"; already declared at "38:18"`,
`21:14: duplicate database declaration for "failing.testDb"; already declared at "41:14"`,
`24:2-10: unsupported type "error" for field "BadParam"`,
`27:2-17: unsupported type "uint64" for field "AnotherBadParam"`,
`30:3-3: unexpected directive "ftl:export" attached for verb, did you mean to use '//ftl:verb export' instead?`,
`36:45-45: unsupported request type "ftl/failing.Request"`,
`30:3: unexpected directive "ftl:export" attached for verb, did you mean to use '//ftl:verb export' instead?`,
`36:45: unsupported request type "ftl/failing.Request"`,
`36:54-66: unsupported verb parameter type "Request"; verbs must have the signature func(Context, Request?, Resources...)`,
`36:69-69: unsupported response type "ftl/failing.Response"`,
`36:69: unsupported response type "ftl/failing.Response"`,
`41:22-27: first parameter must be of type context.Context but is ftl/failing.Request`,
`41:53-53: unsupported response type "ftl/failing.Response"`,
`41:53: unsupported response type "ftl/failing.Response"`,
`46:43-47: second parameter must not be ftl.Unit`,
`46:59-59: unsupported response type "ftl/failing.Response"`,
`46:59: unsupported response type "ftl/failing.Response"`,
`51:1-2: first parameter must be context.Context`,
`51:18-18: unsupported response type "ftl/failing.Response"`,
`51:18: unsupported response type "ftl/failing.Response"`,
`56:1-2: must have at most two results (<type>, error)`,
`56:45-45: unsupported request type "ftl/failing.Request"`,
`56:45: unsupported request type "ftl/failing.Request"`,
`61:1-2: must at least return an error`,
`61:40-40: unsupported request type "ftl/failing.Request"`,
`65:39-39: unsupported request type "ftl/failing.Request"`,
`65:48-48: must return an error but is ftl/failing.Response`,
`70:45-45: unsupported request type "ftl/failing.Request"`,
`70:63-63: must return an error but is string`,
`70:63-63: second result must not be ftl.Unit`,
`81:3-3: unexpected directive "ftl:verb"`,
`61:40: unsupported request type "ftl/failing.Request"`,
`65:39: unsupported request type "ftl/failing.Request"`,
`65:48: must return an error but is ftl/failing.Response`,
`70:45: unsupported request type "ftl/failing.Request"`,
`70:63: must return an error but is string`,
`70:63: second result must not be ftl.Unit`,
`81:3: unexpected directive "ftl:verb"`,
`90:6-18: "BadValueEnum" is a value enum and cannot be tagged as a variant of type enum "TypeEnum" directly`,
`99:6-35: "BadValueEnumOrderDoesntMatter" is a value enum and cannot be tagged as a variant of type enum "TypeEnum" directly`,
`111:6-6: schema declaration with name "PrivateData" already exists for module "failing"; previously declared at "40:25"`,
`111:6: schema declaration with name "PrivateData" already exists for module "failing"; previously declared at "40:25"`,
`115:21-60: config names must be valid identifiers`,
`121:1-1: schema declaration contains conflicting directives`,
`121:1: schema declaration contains conflicting directives`,
`121:1-26: only one directive expected when directive "ftl:enum" is present, found multiple`,
`143:6-45: enum discriminator "TypeEnum3" cannot contain exported methods`,
`146:6-35: enum discriminator "NoMethodsTypeEnum" must define at least one method`,
`158:3-14: unexpected token "d"`,
`165:2-62: can not publish directly to topics in other modules`,
`171:2-12: struct field unexported must be exported by starting with an uppercase letter`,
`175:6-6: unsupported type "ftl/failing/child.BadChildStruct" for field "child"`,
`180:6-6: duplicate data declaration for "failing.Redeclared"; already declared at "27:6"`,
`197:9-9: direct verb calls are not allowed; use the provided EmptyClient instead. See https://tbd54566975.github.io/ftl/docs/reference/verbs/#calling-verbs`,
`175:6: unsupported type "ftl/failing/child.BadChildStruct" for field "child"`,
`180:6: duplicate data declaration for "failing.Redeclared"; already declared at "27:6"`,
`197:9: direct verb calls are not allowed; use the provided EmptyClient instead. See https://tbd54566975.github.io/ftl/docs/reference/verbs/#calling-verbs`,
}

// failing/child/child.go
expectedChild := []string{
`9:2-6: unsupported type "uint64" for field "Body"`,
`14:2-7: unsupported type "github.com/TBD54566975/ftl/go-runtime/schema/testdata.NonFTLType" for field "Field"`,
`14:8-8: unsupported external type "github.com/TBD54566975/ftl/go-runtime/schema/testdata.NonFTLType"; see FTL docs on using external types: tbd54566975.github.io/ftl/docs/reference/externaltypes/`,
`14:8: unsupported external type "github.com/TBD54566975/ftl/go-runtime/schema/testdata.NonFTLType"; see FTL docs on using external types: tbd54566975.github.io/ftl/docs/reference/externaltypes/`,
`19:6-41: declared type github.com/blah.lib.NonFTLType in typemap does not match native type github.com/TBD54566975/ftl/go-runtime/schema/testdata.lib.NonFTLType`,
`24:6-6: multiple Go type mappings found for "ftl/failing/child.MultipleMappings"`,
`24:6: multiple Go type mappings found for "ftl/failing/child.MultipleMappings"`,
`34:2-13: enum variant "SameVariant" conflicts with existing enum variant of "EnumVariantConflictParent" at "187:2"`,
}
assert.Equal(t, expectedParent, actualParent)
Expand All @@ -643,8 +643,8 @@ func TestValidationFailures(t *testing.T) {
return strings.TrimPrefix(e.Error(), filename+":")
})
expected := []string{
`11:3-3: verb badYear: invalid cron expression "* * * * * 9999": failed to parse cron expression syntax error in year field: '9999'`,
`16:3-3: verb allZeroes: invalid cron expression "0 0 0 0 0": failed to parse cron expression syntax error in day-of-month field: '0'`,
`11:3: verb badYear: invalid cron expression "* * * * * 9999": failed to parse cron expression syntax error in year field: '9999'`,
`16:3: verb allZeroes: invalid cron expression "0 0 0 0 0": failed to parse cron expression syntax error in day-of-month field: '0'`,
}
assert.Equal(t, expected, actual)
}

0 comments on commit 1374375

Please sign in to comment.