Skip to content

Commit

Permalink
fix: delete mock file if mockName is same
Browse files Browse the repository at this point in the history
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
  • Loading branch information
charankamarapu committed Sep 8, 2023
1 parent 30be10c commit c4c73bb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions keploy/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,15 @@ func New(conf Config) error {
}

if mode == MODE_RECORD {
if _, err := os.Stat(path + "/keploy/" + conf.Name); !os.IsNotExist(err) {
cmd := exec.Command("sudo", "rm", "-rf", path+"/keploy/"+conf.Name)
if _, err := os.Stat(path + "/stubs/" + conf.Name + "-mocks.yaml"); !os.IsNotExist(err) {
cmd := exec.Command("sudo", "rm", "-rf", path+"/stubs/"+conf.Name+"-mocks.yaml")
_, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to replace existing mock file %w", err)
}
}
if _, err := os.Stat(path + "/stubs/" + conf.Name + "-config.yaml"); !os.IsNotExist(err) {
cmd := exec.Command("sudo", "rm", "-rf", path+"/stubs/"+conf.Name+"-config.yaml")
_, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to replace existing mock file %w", err)
Expand Down

0 comments on commit c4c73bb

Please sign in to comment.