(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator)
| 15 | } |
| 16 | |
| 17 | func Templatize(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command { |
| 18 | var cmd = &cobra.Command{ |
| 19 | Use: "templatize", |
| 20 | Short: "templatize the keploy testcases", |
| 21 | Example: `keploy templatize -t "test-set-1,teset-set-3" for particular testsets and keploy templatize for all testsets`, |
| 22 | PreRunE: func(cmd *cobra.Command, _ []string) error { |
| 23 | return cmdConfigurator.Validate(ctx, cmd) |
| 24 | }, |
| 25 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 26 | // Get the replay service. |
| 27 | svc, err := serviceFactory.GetService(ctx, cmd.Name()) |
| 28 | if err != nil { |
| 29 | utils.LogError(logger, err, "failed to get service", zap.String("command", cmd.Name())) |
| 30 | return nil |
| 31 | } |
| 32 | var tools toolsSvc.Service |
| 33 | var ok bool |
| 34 | if tools, ok = svc.(toolsSvc.Service); !ok { |
| 35 | utils.LogError(logger, nil, "service doesn't satisfy tools service interface") |
| 36 | return nil |
| 37 | } |
| 38 | if err := tools.Templatize(ctx); err != nil { |
| 39 | utils.LogError(logger, err, "failed to templatize test cases") |
| 40 | return nil |
| 41 | } |
| 42 | return nil |
| 43 | }, |
| 44 | } |
| 45 | |
| 46 | err := cmdConfigurator.AddFlags(cmd) |
| 47 | if err != nil { |
| 48 | utils.LogError(logger, err, "failed to add templatize flags") |
| 49 | return nil |
| 50 | } |
| 51 | |
| 52 | return cmd |
| 53 | } |
nothing calls this directly
no test coverage detected