-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hook mongosh
conversion code into CLI
#16
base: main
Are you sure you want to change the base?
Conversation
opendocdb-cts/main.go
Outdated
|
||
b, err := mongosh.ConvertFixtures(fxs) | ||
|
||
f, err := os.OpenFile(filepath.Join(cli.Convert.OutDir, "convert.js"), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like os.Create
?
opendocdb-cts/go.mod
Outdated
@@ -10,6 +10,7 @@ require ( | |||
github.com/neilotoole/slogt v1.1.0 | |||
github.com/pmezard/go-difflib v1.0.0 | |||
github.com/stretchr/testify v1.10.0 | |||
go.mongodb.org/mongo-driver v1.17.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not import it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about requests and responses?
return err | ||
} | ||
|
||
f, err := os.Create(filepath.Join(cli.Convert.OutDir, "convert.js")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why filename is fixed? Why it is a single file?
@@ -38,6 +40,10 @@ var cli struct { | |||
|
|||
Fmt struct{} `cmd:"" help:"Reformat CTS files."` | |||
|
|||
Convert struct { | |||
OutDir string `type:"path" arg:"" help:"Output directory."` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it create a directory if it doesn't exist?
@@ -58,6 +64,29 @@ func fmtCommand() error { | |||
return data.SaveTestSuites(tss, cli.Dir, nil) | |||
} | |||
|
|||
// runCommand implements the "convert" command. | |||
func convertCommand() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write a test?
Closes #10.