Skip to content

Commit

Permalink
feat: add more unitest and fix the helm diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Terryhung committed Oct 23, 2024
1 parent 89c2778 commit 47bef33
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 16 deletions.
4 changes: 2 additions & 2 deletions charts/flyte-binary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ Chart for basic single Flyte executable deployment
| flyte-core-components.admin.disableClusterResourceManager | bool | `false` | |
| flyte-core-components.admin.disableScheduler | bool | `false` | |
| flyte-core-components.admin.disabled | bool | `false` | |
| flyte-core-components.admin.seedProjectsWithDetails[0].description | string | `"Default project setup."` | |
| flyte-core-components.admin.seedProjectsWithDetails[0].name | string | `"flytesnacks"` | |
| flyte-core-components.admin.seedProjects[0] | string | `"flytesnacks"` | |
| flyte-core-components.admin.seedProjectsWithDetails.name | string | `"flytesnacks"` | |
| flyte-core-components.admin.seedProjectsWithDetails.description | string | `"Default project setup"` | |
| flyte-core-components.dataCatalog.disabled | bool | `false` | |
| flyte-core-components.propeller.disableWebhook | bool | `false` | |
| flyte-core-components.propeller.disabled | bool | `false` | |
Expand Down
2 changes: 1 addition & 1 deletion charts/flyte-binary/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ flyte-core-components:
# a default description will be auto-generated for the project.
seedProjectsWithDetails:
- name: flytesnacks
description: Default project setup."
description: Default project setup.
# propeller Configuration to disable propeller or any of its components
propeller:
# disabled Disables flytepropeller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ data:
seedProjects:
- flytesnacks
seedProjectsWithDetails:
- name: flytesnacks
description: Default project setup
- description: Default project setup.
name: flytesnacks
dataCatalog:
disabled: false
propeller:
Expand Down Expand Up @@ -363,7 +363,7 @@ spec:
app.kubernetes.io/instance: flyte
app.kubernetes.io/component: flyte-binary
annotations:
checksum/configuration: faaefbd3b3b2ddfd4e718bd77c02c632c75e7111dad0a6e25dc415dc88add73f
checksum/configuration: 886440a42b3eeec802cfe60d37885f69e35ffd83e53e625b3c877da5e8c7eb38
checksum/configuration-secret: d5d93f4e67780b21593dc3799f0f6682aab0765e708e4020939975d14d44f929
checksum/cluster-resource-templates: 7dfa59f3d447e9c099b8f8ffad3af466fecbc9cf9f8c97295d9634254a55d4ae
spec:
Expand Down
61 changes: 51 additions & 10 deletions flyteadmin/pkg/repositories/config/seed_data_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package config

import "testing"
import (
"testing"

mocket "github.com/Selvatico/go-mocket"
"github.com/stretchr/testify/assert"
"gorm.io/gorm"
)

func TestMergeSeedProjectsWithUniqueNames(t *testing.T) {
tests := []struct {
Expand Down Expand Up @@ -235,15 +241,50 @@ func TestUniqueProjectsFromNames(t *testing.T) {
t.Errorf("unexpected project %q in result", name)
}
}

uniqueNames := make([]string, 0)
seen := make(map[string]bool)
for _, name := range tt.names {
if !seen[name] {
seen[name] = true
uniqueNames = append(uniqueNames, name)
}
}
})
}
}

func TestSeedProjects(t *testing.T) {
gormDb := GetDbForTest(t)
defer mocket.Catcher.Reset()

mocket.Catcher.Reset()
mocket.Catcher.NewMock().WithQuery(`SELECT * FROM "projects"`).WithReply([]map[string]interface{}{})

projects := []SeedProject{
{
Name: "Project 1",
Description: "New Description",
},
}

// Execute
err := SeedProjects(gormDb, projects)

// Assert
assert.NoError(t, err)
}

func TestSeedProjectsWithDuplicateKey(t *testing.T) {
gormDb := GetDbForTest(t)
defer mocket.Catcher.Reset()

// Mock the SELECT query for existence check
mocket.Catcher.Reset()
mocket.Catcher.NewMock().WithQuery(`INSERT INTO "projects"`).WithError(gorm.ErrDuplicatedKey)

projects := []SeedProject{
{
Name: "Project 1",
Description: "New Description",
},
}

// Execute
err := SeedProjects(gormDb, projects)

// Assert
assert.Error(t, err)

}

0 comments on commit 47bef33

Please sign in to comment.