Fixtures
Fixtures are a way to define a set of data that can be pre-populated for dev mode. Fixtures are essentially a verb that is called when the service is started in dev mode.
When not running in dev mode fixtures are not called, and are not present in the schema. This is to prevent fixtures from being called in production. This may change in the future to allow fixtures to be used in contract testing between services.
FTL also supports manual fixtures that can be called by the user through the console or CLI. This is useful for defining dev mode helper functions that are not usable in production.
Note: Test fixtures are not implemented yet, this will be implemented in the future.
Examples
- Go
- Kotlin
- Java
- Schema
//ftl:fixture
func Fixture(ctx context.Context) error {
// ...
}
//ftl:fixture manual
func ManualFixture(ctx context.Context) error {
// ...
}
import xyz.block.ftl.Fixture
@Fixture
fun fixture() {
}
@Fixture(manual=true)
fun manualFixture() {
}
import xyz.block.ftl.Fixture;
class MyFixture {
@Fixture
void fixture() {
}
@Fixture(manual=true)
void manualFixture() {
}
}
module example {
verb fixture(Unit) Unit
+fixture
verb manualFixture(Unit) Unit
+fixture manual
}