Skip to content

Commit f6b8f1b

Browse files
committed
fix(test): updates tests for the recent changes
1 parent 6cb1c63 commit f6b8f1b

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

apps/operator/internal/controller/database/resources_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestFormatPostgresURI(t *testing.T) {
2929
host: "localhost",
3030
dbName: "mydb",
3131
port: 5432,
32-
expected: "postgres://user:pass@localhost:5432/mydb",
32+
expected: "postgres://user:pass@localhost:5432/mydb?sslmode=disable",
3333
},
3434
{
3535
name: "special chars in password",
@@ -38,7 +38,7 @@ func TestFormatPostgresURI(t *testing.T) {
3838
host: "db.example.com",
3939
dbName: "app_db",
4040
port: 5432,
41-
expected: "postgres://user:p%40ss%3Aword%2F@db.example.com:5432/app_db",
41+
expected: "postgres://user:p%40ss%3Aword%2F@db.example.com:5432/app_db?sslmode=disable",
4242
},
4343
{
4444
name: "special chars in username",
@@ -47,7 +47,7 @@ func TestFormatPostgresURI(t *testing.T) {
4747
host: "postgres-host",
4848
dbName: "database",
4949
port: 5432,
50-
expected: "postgres://user%2Badmin:password@postgres-host:5432/database",
50+
expected: "postgres://user%2Badmin:password@postgres-host:5432/database?sslmode=disable",
5151
},
5252
{
5353
name: "custom port",
@@ -56,7 +56,7 @@ func TestFormatPostgresURI(t *testing.T) {
5656
host: "db-instance",
5757
dbName: "prod_db",
5858
port: 5433,
59-
expected: "postgres://admin:secret123@db-instance:5433/prod_db",
59+
expected: "postgres://admin:secret123@db-instance:5433/prod_db?sslmode=disable",
6060
},
6161
{
6262
name: "IPv6 host",
@@ -65,7 +65,7 @@ func TestFormatPostgresURI(t *testing.T) {
6565
host: "::1",
6666
dbName: "testdb",
6767
port: 5432,
68-
expected: "postgres://user:pass@::1:5432/testdb",
68+
expected: "postgres://user:pass@::1:5432/testdb?sslmode=disable",
6969
},
7070
}
7171

apps/operator/internal/cue/tekton_test.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ func TestRenderTektonResources_AllResources(t *testing.T) {
6767
t.Fatalf("RenderTektonResources failed: %v", err)
6868
}
6969

70-
// With webhookDomain set, we expect 11 objects:
71-
// 6 Tasks (git-clone, kaniko-build, git-update-manifest, argocd-sync, db-migrate, postgrest-reload) + 1 Pipeline + 1 TriggerBinding + 1 TriggerTemplate + 1 EventListener + 1 Ingress
72-
expectedCount := 11
70+
// With webhookDomain set, we expect 13 objects:
71+
// 6 Tasks (git-clone, kaniko-build, git-update-manifest, argocd-sync, db-migrate, postgrest-reload)
72+
// + 2 Pipelines (from-code-to-cluster + db-migrate)
73+
// + 1 TriggerBinding + 2 TriggerTemplates (gitea + db-migrate) + 1 EventListener + 1 Ingress
74+
expectedCount := 13
7375
if len(objects) != expectedCount {
7476
t.Errorf("Expected %d objects, got %d", expectedCount, len(objects))
7577
for i, obj := range objects {
@@ -80,9 +82,9 @@ func TestRenderTektonResources_AllResources(t *testing.T) {
8082
// Verify each expected kind is present
8183
expectedKinds := map[string]int{
8284
"Task": 6,
83-
"Pipeline": 1,
85+
"Pipeline": 2,
8486
"TriggerBinding": 1,
85-
"TriggerTemplate": 1,
87+
"TriggerTemplate": 2,
8688
"EventListener": 1,
8789
"Ingress": 1,
8890
}
@@ -115,8 +117,9 @@ func TestRenderTektonResources_WithoutWebhook(t *testing.T) {
115117
t.Fatalf("RenderTektonResources failed: %v", err)
116118
}
117119

118-
// Without webhookDomain: 10 objects (no Ingress)
119-
expectedCount := 10
120+
// Without webhookDomain: 12 objects (no Ingress)
121+
// 6 Tasks + 2 Pipelines + 1 TriggerBinding + 2 TriggerTemplates + 1 EventListener
122+
expectedCount := 12
120123
if len(objects) != expectedCount {
121124
t.Errorf("Expected %d objects (no webhook), got %d", expectedCount, len(objects))
122125
for i, obj := range objects {
@@ -255,17 +258,15 @@ func TestRenderTektonResources_BuildOnlyPipeline(t *testing.T) {
255258
t.Fatalf("RenderTektonResources failed: %v", err)
256259
}
257260

258-
// Verify pipeline name is "build-only"
259-
foundPipeline := false
261+
// Verify the primary pipeline with name "build-only" exists among rendered pipelines.
262+
// Note: db-migrate pipeline is always rendered alongside the primary pipeline.
263+
foundBuildOnly := false
260264
for _, obj := range objects {
261-
if obj.GetKind() == "Pipeline" {
262-
if obj.GetName() != "build-only" {
263-
t.Errorf("Expected pipeline name 'build-only', got %q", obj.GetName())
264-
}
265-
foundPipeline = true
265+
if obj.GetKind() == "Pipeline" && obj.GetName() == "build-only" {
266+
foundBuildOnly = true
266267
}
267268
}
268-
if !foundPipeline {
269-
t.Error("Pipeline not found in rendered objects")
269+
if !foundBuildOnly {
270+
t.Error("Expected primary pipeline 'build-only' not found in rendered objects")
270271
}
271272
}

0 commit comments

Comments
 (0)