Previously, the `NewWithFactories` function in `runtime_pkg.go` iterated over an empty slice, which prevented any services from being created from the provided factories. This commit fixes the loop to correctly iterate over the keys of the `factories` map, ensuring that services are properly instantiated and registered.
feat(testing): Add Good, Bad, and Ugly tests for NewWithFactories
To improve test quality and ensure the reliability of the `NewWithFactories` function, this commit replaces the existing basic test with a comprehensive test suite following the Good, Bad, Ugly methodology:
- `TestNewWithFactories_Good`: Verifies the happy path, ensuring a service is created and registered successfully.
- `TestNewWithFactories_Bad`: Checks that the function correctly returns an error when a service factory fails.
- `TestNewWithFactories_Ugly`: Confirms that the function panics when a `nil` factory is provided, as this represents an unrecoverable programmer error.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit increases the test coverage of the Core package to over 88%.
- Adds tests for `ServiceStartup` and `ServiceShutdown` methods in `core.go`.
- Adds tests for `App()`, `Config()`, and `Display()` methods in `core.go`.
- Adds a test for `IsEnabled` in `interfaces.go`.
- Adds tests for `NewServiceRuntime`, `Core()`, and `Config()` in `runtime.go`.
- Adds tests for `NewWithFactories`, `ServiceName`, `ServiceStartup`, and `ServiceShutdown` in `runtime_pkg.go`.
- Removes the unused `core/testutil` directory.
- Rewrites the `TestNewWithFactories_Good` test to correctly validate the original `NewWithFactories` function's behavior.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
- Move Go files from core, e, and runtime directories to the project root.
- Unify package declarations to a single 'core' package.
- Update go.work to exclude the cmd directory from the main build.
- Resolve naming conflicts and update import paths.
- Fix tests to work with the new structure.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>