-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
types.ftl.go
to register sumtypes, which fixes enco…
…ding in unit tests (#1909) Fixes #1577 This change introduces a new generated file `types.ftl.go` in the user-defined package itself to make sure sumtype registrations get called when running unit tests. Notes: * This change also includes a subpackage `subpackage` in the test data that is not yet unit tested. Unit tests should be added (identical to the parent package's unit tests) after #1903 is resolved. Some work will also need to be done to extend the `types.ftl.go` generation to working on subpackages. * This works by extending the existing logic operating on `mainModuleContext`, which means that code now generates not only just the literal `main` package, but also the conceptual _main_ package's additional artifacts. I couldn't come up with a name that would be better, so it's left as-is in this PR, but please let me know if you think of something better.
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Code generated by FTL. DO NOT EDIT. | ||
package {{.Name}} | ||
{{if .LocalSumTypes }} | ||
import "github.com/TBD54566975/ftl/go-runtime/ftl/reflection" | ||
|
||
func init() { | ||
reflection.Register( | ||
{{- range .LocalSumTypes}} | ||
reflection.SumType[{{.Discriminator}}]( | ||
{{- range .Variants}} | ||
*new({{.Name}}), | ||
{{- end}} | ||
), | ||
{{- end}} | ||
) | ||
} | ||
{{- end}} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module = "typeregistry" | ||
language = "go" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module ftl/typeregistry | ||
|
||
go 1.22.2 | ||
|
||
toolchain go1.22.4 | ||
|
||
require ( | ||
github.com/TBD54566975/ftl v1.1.5 | ||
github.com/alecthomas/assert/v2 v2.10.0 | ||
) | ||
|
||
require ( | ||
connectrpc.com/connect v1.16.1 // indirect | ||
connectrpc.com/grpcreflect v1.2.0 // indirect | ||
connectrpc.com/otelconnect v0.7.0 // indirect | ||
github.com/BurntSushi/toml v1.4.0 // indirect | ||
github.com/TBD54566975/scaffolder v1.0.0 // indirect | ||
github.com/alecthomas/atomic v0.1.0-alpha2 // indirect | ||
github.com/alecthomas/concurrency v0.0.2 // indirect | ||
github.com/alecthomas/participle/v2 v2.1.1 // indirect | ||
github.com/alecthomas/repr v0.4.0 // indirect | ||
github.com/alecthomas/types v0.16.0 // indirect | ||
github.com/alessio/shellescape v1.4.2 // indirect | ||
github.com/aws/aws-sdk-go-v2 v1.30.1 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.13 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.13 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.1 // indirect | ||
github.com/aws/smithy-go v1.20.3 // indirect | ||
github.com/benbjohnson/clock v1.3.5 // indirect | ||
github.com/danieljoos/wincred v1.2.0 // indirect | ||
github.com/go-logr/logr v1.4.2 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/godbus/dbus/v5 v5.1.0 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/hexops/gotextdiff v1.0.3 // indirect | ||
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438 // indirect | ||
github.com/jackc/pgpassfile v1.0.0 // indirect | ||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect | ||
github.com/jackc/pgx/v5 v5.6.0 // indirect | ||
github.com/jackc/puddle/v2 v2.2.1 // indirect | ||
github.com/jpillora/backoff v1.0.0 // indirect | ||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/multiformats/go-base36 v0.2.0 // indirect | ||
github.com/puzpuzpuz/xsync/v3 v3.2.0 // indirect | ||
github.com/swaggest/jsonschema-go v0.3.72 // indirect | ||
github.com/swaggest/refl v1.3.0 // indirect | ||
github.com/zalando/go-keyring v0.2.5 // indirect | ||
go.opentelemetry.io/otel v1.27.0 // indirect | ||
go.opentelemetry.io/otel/metric v1.27.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.27.0 // indirect | ||
golang.org/x/crypto v0.24.0 // indirect | ||
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect | ||
golang.org/x/mod v0.18.0 // indirect | ||
golang.org/x/net v0.26.0 // indirect | ||
golang.org/x/sync v0.7.0 // indirect | ||
golang.org/x/sys v0.21.0 // indirect | ||
golang.org/x/text v0.16.0 // indirect | ||
google.golang.org/protobuf v1.34.2 // indirect | ||
) | ||
|
||
replace github.com/TBD54566975/ftl => ../../../../.. |