cmd/netwatch-server/main.go parsed the command line, ran the check-cidr and prepare-data-dir subcommands and built the fx application itself; the Go style guide puts all of that in internal/ or pkg/. The new package internal/cli does it, with the same arguments, messages and exit codes. main() is now os.Exit(cli.Main(os.Stderr, Appname, Version, os.Args[1:], cli.RunServer)): Main takes the writer for errors and the function that runs the server, so its tests give it a buffer and a function that fails them. Appname and Version stay in main, where the build sets Version. The function behind prepare-data-dir also takes the volume and the user's name, so its own tests give it a temporary directory and the user they run as. Model: opus-5-5
This commit was merged in pull request #178.
This commit is contained in:
@@ -334,9 +334,9 @@ func stopWhileHeld(
|
||||
return <-stopped
|
||||
}
|
||||
|
||||
// startApp starts a Buffer through fx, as main does, with the DATA_DIR
|
||||
// and DATA_DIR_MAX_BYTES the calling test has set, and returns it with
|
||||
// the app, for tests that stop the app themselves.
|
||||
// startApp starts a Buffer through fx, as cli.RunServer does, with the
|
||||
// DATA_DIR and DATA_DIR_MAX_BYTES the calling test has set, and returns
|
||||
// it with the app, for tests that stop the app themselves.
|
||||
func startApp(t *testing.T) (*reportbuf.Buffer, *fxtest.App) {
|
||||
t.Helper()
|
||||
|
||||
@@ -358,8 +358,8 @@ func startApp(t *testing.T) (*reportbuf.Buffer, *fxtest.App) {
|
||||
return buf, app
|
||||
}
|
||||
|
||||
// startBuffer starts a Buffer through fx, as main does, with the
|
||||
// DATA_DIR and DATA_DIR_MAX_BYTES the calling test has set.
|
||||
// startBuffer starts a Buffer through fx, as cli.RunServer does, with
|
||||
// the DATA_DIR and DATA_DIR_MAX_BYTES the calling test has set.
|
||||
func startBuffer(t *testing.T) *reportbuf.Buffer {
|
||||
t.Helper()
|
||||
|
||||
@@ -1120,8 +1120,8 @@ func TestHealthCheckFailsWhileWritesFail(t *testing.T) {
|
||||
}
|
||||
|
||||
// startBufferWithHandlers starts a Buffer and the Handlers that store
|
||||
// reports in it through fx, as main does, with the DATA_DIR the calling
|
||||
// test has set.
|
||||
// reports in it through fx, as cli.RunServer does, with the DATA_DIR
|
||||
// the calling test has set.
|
||||
func startBufferWithHandlers(
|
||||
t *testing.T,
|
||||
) (*reportbuf.Buffer, *handlers.Handlers) {
|
||||
|
||||
Reference in New Issue
Block a user