MCPcopy
hub / github.com/keploy/keploy / Validate

Function Validate

cli/contract.go:111–141  ·  view source on GitHub ↗
(ctx context.Context, logger *zap.Logger, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator)

Source from the content-addressed store, hash-verified

109}
110
111func Validate(ctx context.Context, logger *zap.Logger, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command {
112 var cmd = &cobra.Command{
113 Use: "test",
114 Short: "Validate contract for specified services",
115 Example: `keploy contract test --service="email,notify" --path /local/path`,
116
117 PreRunE: func(cmd *cobra.Command, _ []string) error {
118 return cmdConfigurator.Validate(ctx, cmd)
119 },
120 RunE: func(cmd *cobra.Command, _ []string) error {
121 svc, err := serviceFactory.GetService(ctx, "contract")
122 if err != nil {
123 utils.LogError(logger, err, "failed to get service", zap.String("command", cmd.Name()))
124 return nil
125 }
126 var contract contractSvc.Service
127 var ok bool
128 if contract, ok = svc.(contractSvc.Service); !ok {
129 utils.LogError(logger, nil, "service doesn't satisfy contract service interface")
130 return nil
131 }
132 err = contract.Validate(ctx)
133 if err != nil {
134 utils.LogError(logger, err, "failed to validate contract")
135 }
136 return nil
137 },
138 }
139
140 return cmd
141}

Callers 1

ContractFunction · 0.85

Calls 6

ValidateMethod · 0.95
LogErrorFunction · 0.92
NameMethod · 0.80
ValidateMethod · 0.65
GetServiceMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected