Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for normalising expected diffs (#1859)
* [Feature]: Create a normalisation command in keploy CLI (#1589) * Initialised Normalise Command Signed-off-by: Akash <akashsingh2210670@gmail.com> * Path init Signed-off-by: Akash <akashsingh2210670@gmail.com> * Successfully found the expected and actual responses for failing tests Signed-off-by: Akash <akashsingh2210670@gmail.com> * Files are being updated but structs are not proper: func WriteTestcase doesnt match yaml file Signed-off-by: Akash <akashsingh2210670@gmail.com> * Updating testcase files successfully Signed-off-by: Akash <akashsingh2210670@gmail.com> * Added flags to collect test-set and test-cases from user Signed-off-by: Akash <akashsingh2210670@gmail.com> * Fixed lint errors Signed-off-by: Akash <akashsingh2210670@gmail.com> * Fixed lint errors Signed-off-by: Akash <akashsingh2210670@gmail.com> * Refactored PR for Keploy v2 and fixed merge conflicts Signed-off-by: Akash Singh <akashsingh2210670@gmail.com> * Normalise Test cases Signed-off-by: Akash Singh <akashsingh2210670@gmail.com> * Addressed comments and refactored changes Signed-off-by: Akash Singh <akashsingh2210670@gmail.com> * Fixed Lint Signed-off-by: Akash Singh <akashsingh2210670@gmail.com> * Fixed Lint Signed-off-by: Akash Singh <akashsingh2210670@gmail.com> * Refactoring and Adding Additional Flags Signed-off-by: Akash Singh <akashsingh2210670@gmail.com> * Added Normalise to replay service Signed-off-by: Akash Singh <akashsingh2210670@gmail.com> * Fixed lint Signed-off-by: Akash Singh <akashsingh2210670@gmail.com> --------- Signed-off-by: Akash <akashsingh2210670@gmail.com> Signed-off-by: Akash Singh <akashsingh2210670@gmail.com> Co-authored-by: Animesh Pathak <53110238+Sonichigo@users.noreply.github.com> * feat: add normalization Signed-off-by: charankamarapu <kamarapucharan@gmail.com> * fix: bugs Signed-off-by: charankamarapu <kamarapucharan@gmail.com> * fix: bugs Signed-off-by: charankamarapu <kamarapucharan@gmail.com> * fix: bugs Signed-off-by: charankamarapu <kamarapucharan@gmail.com> * fix: resolve comments Signed-off-by: charankamarapu <kamarapucharan@gmail.com> --------- Signed-off-by: Akash <akashsingh2210670@gmail.com> Signed-off-by: Akash Singh <akashsingh2210670@gmail.com> Signed-off-by: charankamarapu <kamarapucharan@gmail.com> Co-authored-by: Sky Singh <114267538+Akash-Singh04@users.noreply.github.com> Co-authored-by: Animesh Pathak <53110238+Sonichigo@users.noreply.github.com>
- Loading branch information
1 parent
c0dbdbb
commit 4410963
Showing
8 changed files
with
231 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
"go.keploy.io/server/v2/config" | ||
replaySvc "go.keploy.io/server/v2/pkg/service/replay" | ||
"go.keploy.io/server/v2/utils" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func init() { | ||
Register("normalize", Normalize) | ||
} | ||
|
||
// Normalize retrieves the command to normalize Keploy | ||
func Normalize(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command { | ||
var normalizeCmd = &cobra.Command{ | ||
Use: "normalize", | ||
Short: "Normalize Keploy", | ||
Example: "keploy normalize --test-run testrun --tests test-set-1:test-case-1 test-case-2,test-set-2:test-case-1 test-case-2 ", | ||
PreRunE: func(cmd *cobra.Command, _ []string) error { | ||
return cmdConfigurator.ValidateFlags(ctx, cmd) | ||
}, | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
svc, err := serviceFactory.GetService(ctx, cmd.Name()) | ||
if err != nil { | ||
utils.LogError(logger, err, "failed to get service") | ||
return nil | ||
} | ||
var replay replaySvc.Service | ||
var ok bool | ||
if replay, ok = svc.(replaySvc.Service); !ok { | ||
utils.LogError(logger, nil, "service doesn't satisfy replay service interface") | ||
return nil | ||
} | ||
if err := replay.Normalize(ctx); err != nil { | ||
utils.LogError(logger, err, "failed to normalize test cases") | ||
return nil | ||
} | ||
return nil | ||
}, | ||
} | ||
if err := cmdConfigurator.AddFlags(normalizeCmd); err != nil { | ||
utils.LogError(logger, err, "failed to add normalize cmd flags") | ||
return nil | ||
} | ||
return normalizeCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters