Skip to content

Commit b65c968

Browse files
authored
fix(sql): w_node_context constraint (#5163)
Signed-off-by: francois samin <francois.samin@corp.ovh.com>
1 parent 5cc5308 commit b65c968

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

engine/api/integration/dao_model_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,15 @@ func TestCRUDModel(t *testing.T) {
1919
ok, err := ModelExists(db, p.Name)
2020
require.NoError(t, err)
2121

22-
if ok {
23-
p, err := LoadModelByName(db, p.Name)
22+
if !ok {
23+
err = InsertModel(db, p)
2424
require.NoError(t, err)
25-
// Eventually we have to clean all project_integration linked
26-
_, err = db.Exec("delete from project_integration where integration_model_id = $1", p.ID)
25+
} else {
26+
p1, err := LoadModelByName(db, p.Name)
2727
require.NoError(t, err)
28-
require.NoError(t, DeleteModel(db, p.ID))
28+
p = &p1
2929
}
3030

31-
err = InsertModel(db, p)
32-
require.NoError(t, err)
33-
3431
model, err := LoadModelByNameWithClearPassword(db, p.Name)
3532
require.NoError(t, err)
3633

engine/api/websocket_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ package api
22

33
import (
44
"context"
5+
"net/url"
6+
"strings"
7+
"testing"
8+
"time"
9+
510
"github.com/ovh/cds/engine/api/authentication"
611
"github.com/ovh/cds/engine/api/authentication/builtin"
712
"github.com/ovh/cds/engine/api/test/assets"
813
"github.com/ovh/cds/engine/api/workflow"
914
"github.com/ovh/cds/sdk"
1015
"github.com/ovh/cds/sdk/cdsclient"
1116
"github.com/stretchr/testify/require"
12-
"net/url"
13-
"strings"
14-
"testing"
15-
"time"
1617
)
1718

1819
func Test_websocketWrongFilters(t *testing.T) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- +migrate Up
2+
3+
ALTER TABLE "w_node_context" DROP CONSTRAINT IF EXISTS "fk_w_node_context_integration";
4+
SELECT create_foreign_key('FK_W_NODE_CONTEXT_INTEGRATION', 'w_node_context', 'project_integration', 'project_integration_id', 'id');
5+
6+
-- +migrate Down
7+
SELECT 1;

0 commit comments

Comments
 (0)