This is an automated email from the ASF dual-hosted git repository.

ka94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 0b3b76599 fix: Scope data shouldn't be removed on deletion conflict 
(#5532) (#5533)
0b3b76599 is described below

commit 0b3b76599bc5fb46455d5a759049a4a09ec96c30
Author: Klesh Wong <[email protected]>
AuthorDate: Wed Jun 21 12:33:41 2023 +0800

    fix: Scope data shouldn't be removed on deletion conflict (#5532) (#5533)
    
    * fix: scope get emptied when deletion failed (#5532)
    
    * test: fix broken e2e test
    
    ---------
    
    Co-authored-by: Keon Amini <[email protected]>
---
 .../helpers/pluginhelper/api/scope_generic_helper.go    |  3 ---
 backend/test/e2e/remote/helper.go                       | 17 +++++++++++------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/backend/helpers/pluginhelper/api/scope_generic_helper.go 
b/backend/helpers/pluginhelper/api/scope_generic_helper.go
index 449e76ba7..a5a09766f 100644
--- a/backend/helpers/pluginhelper/api/scope_generic_helper.go
+++ b/backend/helpers/pluginhelper/api/scope_generic_helper.go
@@ -290,9 +290,6 @@ func (gs *GenericScopeApiHelper[Conn, Scope, ScopeConfig]) 
DeleteScope(input *pl
                if err != nil {
                        return nil, err
                }
-               if err = gs.deleteScopeData(params.plugin, params.scopeId); err 
!= nil {
-                       return nil, err
-               }
                return refs, errors.Conflict.New("Found one or more references 
to this scope")
        }
        if err = gs.deleteScopeData(params.plugin, params.scopeId); err != nil {
diff --git a/backend/test/e2e/remote/helper.go 
b/backend/test/e2e/remote/helper.go
index 6038bc6cd..014ff7ecb 100644
--- a/backend/test/e2e/remote/helper.go
+++ b/backend/test/e2e/remote/helper.go
@@ -192,16 +192,21 @@ func DeleteScopeWithDataIntegrityValidation(t *testing.T, 
client *helper.Devlake
                configData[table] = int(count)
        }
        refs := client.DeleteScope(PLUGIN_NAME, connectionId, scopeId, 
deleteDataOnly)
-       for _, table := range PluginDataTables {
-               count, err := db.Count(dal.From(table))
-               require.NoError(t, err)
-               require.Equalf(t, 0, int(count), fmt.Sprintf("data was found in 
table: %s", table))
-       }
-       if !deleteDataOnly && client.LastReturnedStatusCode() == http.StatusOK {
+       if client.LastReturnedStatusCode() == http.StatusOK {
+               for _, table := range PluginDataTables {
+                       count, err := db.Count(dal.From(table))
+                       require.NoError(t, err)
+                       require.Equalf(t, 0, int(count), fmt.Sprintf("data was 
found in table: %s", table))
+               }
                count, err := db.Count(dal.From(PluginScopeTable))
                require.NoError(t, err)
                require.Equalf(t, 0, int(count), fmt.Sprintf("data was found in 
table: %s", PluginScopeTable))
        } else {
+               for _, table := range PluginDataTables {
+                       count, err := db.Count(dal.From(table))
+                       require.NoError(t, err)
+                       require.Greaterf(t, int(count), 0, fmt.Sprintf("no data 
was found in table: %s", table))
+               }
                count, err := db.Count(dal.From(PluginScopeTable))
                require.NoError(t, err)
                require.Greaterf(t, int(count), 0, fmt.Sprintf("no data was 
found in table: %s", PluginScopeTable))

Reply via email to