MCPcopy Create free account
hub / github.com/amitsaha/gitbackup / buildTestConfig

Function buildTestConfig

config_file_test.go:15–34  ·  view source on GitHub ↗

buildTestConfig creates a minimal cli.App with appFlags(), runs it with the given args, and returns the appConfig produced by buildConfig.

(args []string)

Source from the content-addressed store, hash-verified

13// buildTestConfig creates a minimal cli.App with appFlags(), runs it with the
14// given args, and returns the appConfig produced by buildConfig.
15func buildTestConfig(args []string) (*appConfig, error) {
16 var result *appConfig
17 var buildErr error
18
19 app := &cli.App{
20 Name: "gitbackup",
21 Flags: appFlags(),
22 Action: func(cCtx *cli.Context) error {
23 result, buildErr = buildConfig(cCtx)
24 return buildErr
25 },
26 }
27
28 // urfave/cli expects the program name as args[0]
29 fullArgs := append([]string{"gitbackup"}, args...)
30 if err := app.Run(fullArgs); err != nil {
31 return nil, fmt.Errorf("app.Run: %w", err)
32 }
33 return result, buildErr
34}
35
36func TestHandleInitConfig(t *testing.T) {
37 tmpDir := t.TempDir()

Calls 2

appFlagsFunction · 0.85
buildConfigFunction · 0.85

Tested by

no test coverage detected