-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the gen command to use the new cli generator (#489)
* Removed multiple files from pkg/gen/input and pkg/gen/output The commit includes the deletion of several files in the 'pkg/gen/input' and 'pkg/gen/output' directories. This is part of a larger refactoring effort to streamline codebase, improve maintainability, and remove redundant or unnecessary code. * Updated test_all dependencies in Makefile The 'test_all' target in the Makefile has been updated to include new dependencies. These additional binaries are now required for the 'test_all' target to run successfully. * Added test suite for uml2ts package A new test suite has been added for the uml2ts package. This includes importing necessary packages and setting up a context, file system, and error handling. The tests are designed to check conformance of the 'interface' and 'nested_interface' with standard output. A generator description is also provided as part of the testing process. * Refactor test assertion handling The code has been refactored to improve the handling of test assertions. A panic is now thrown if a test contains no assertions, replacing the previous warning log. The error expectation in the generator execution has also been adjusted for better traceability. In addition, a warning is logged when there are no assertions for a specific test in the suite. * Refactor end-to-end tests and improve error message The end-to-end testing code has been refactored for better readability and maintainability. The changes include the use of a new function, `DescribeGenerator`, to simplify test generation. Additionally, the error message displayed when a file cannot be found has been made more descriptive. In the suite test file, the method for reading local TypeScript tests has also been updated to allow specific assertions per test type. * Added stringer interface and logging to file operations - Implemented fmt.Stringer interface in file, fsOutput, reader, and writerOutput structs for better debugging. - Added debug logs for writing to a file, copying filesystems, and copying files in writerOutput. - Counted the number of files copied in writerOutput for more detailed logging. * Added logging and stdout support Enhanced the parsing function with debug logs for better traceability. Added a new boolean field 'stdout' to the 'fromPath' struct in path.go, allowing plugins to expect standard output. Updated static.go to use this new feature by setting 'stdout' as true for the Uml2Ts plugin. * Refactor gen command and error handling Significant changes have been made to the 'gen' command. The code now uses a configuration object instead of parsing arguments directly. Error handling has been improved by adding more checks after each operation, ensuring that any issues are caught and reported immediately. Additionally, the input and output parsing logic has been updated to use new methods from the 'run' package. Finally, the generator execution process has been modified for better clarity and efficiency. * Improved test reliability and refactored Docker image existence check - Enhanced the robustness of tests by adding FlakeAttempts to uml2ts Conformance suite and using ExpectWithOffset in assertions. - Refactored Docker plugin's image existence check into a separate function, ImageExists, for better readability and reusability. - Updated docker plugin tests to use the new ImageExists function. * Optimized string return in writerOutput Removed unnecessary usage of fmt.Sprintf for returning a static string in the writerOutput function. This simplifies the code and potentially improves performance by avoiding unnecessary formatting operations.
- Loading branch information
1 parent
7520daf
commit f566251
Showing
23 changed files
with
169 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package uml2ts_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/spf13/afero" | ||
"github.com/unstoppablemango/tdl/pkg/conform" | ||
"github.com/unstoppablemango/tdl/pkg/gen/cli" | ||
"github.com/unstoppablemango/tdl/pkg/testing/e2e" | ||
) | ||
|
||
var suite e2e.Suite | ||
|
||
func TestUml2ts(t *testing.T) { | ||
g := NewWithT(t) | ||
ctx := context.Background() | ||
fs := afero.NewOsFs() | ||
|
||
var err error | ||
suite, err = conform.ReadLocalGitTests(ctx, fs, "typescript", map[string][]e2e.Assertion{ | ||
"interface": {conform.AssertStdout}, | ||
"nested_interface": {conform.AssertStdout}, | ||
}) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
|
||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Uml2ts Suite") | ||
} | ||
|
||
var _ = Describe("uml2ts Conformance", FlakeAttempts(5), func() { | ||
conform.DescribeGenerator(suite, cli.New("uml2ts", cli.ExpectStdout)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.