From 92e4cc41a66097790728dff174d6fc1638cd327c Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Tue, 3 Sep 2024 20:43:17 -0700 Subject: [PATCH 1/2] Bump Go runtime to 1.23.0, improved api, comparator, util tests --- .env.test | 5 +- .github/workflows/master.yml | 4 +- go.mod | 4 +- resources/fixtures/api/default_snapshot.json | 35 +++++++++++++ .../fixtures/api/error_invalid_domain.json | 19 +++++++ .../{ => comparator}/changed_config.json | 0 .../{ => comparator}/changed_group.json | 0 .../{ => comparator}/changed_strategy.json | 0 .../fixtures/{ => comparator}/default.json | 0 .../{ => comparator}/default_empty.json | 0 .../default_empty_config.json | 0 .../{ => comparator}/deleted_component.json | 0 .../{ => comparator}/deleted_config.json | 0 .../{ => comparator}/deleted_group.json | 0 .../{ => comparator}/deleted_strategy.json | 0 .../deleted_strategy_value.json | 0 .../{ => comparator}/new_component.json | 0 .../fixtures/{ => comparator}/new_config.json | 0 .../fixtures/{ => comparator}/new_group.json | 0 .../{ => comparator}/new_strategy.json | 0 .../{ => comparator}/new_strategy_value.json | 0 resources/fixtures/util/default.json | 49 +++++++++++++++++++ src/core/api_test.go | 42 ++++++++++------ src/core/comparator_test.go | 32 ++++++------ src/core/core_test.go | 3 +- src/utils/util_test.go | 2 +- 26 files changed, 155 insertions(+), 40 deletions(-) create mode 100644 resources/fixtures/api/default_snapshot.json create mode 100644 resources/fixtures/api/error_invalid_domain.json rename resources/fixtures/{ => comparator}/changed_config.json (100%) rename resources/fixtures/{ => comparator}/changed_group.json (100%) rename resources/fixtures/{ => comparator}/changed_strategy.json (100%) rename resources/fixtures/{ => comparator}/default.json (100%) rename resources/fixtures/{ => comparator}/default_empty.json (100%) rename resources/fixtures/{ => comparator}/default_empty_config.json (100%) rename resources/fixtures/{ => comparator}/deleted_component.json (100%) rename resources/fixtures/{ => comparator}/deleted_config.json (100%) rename resources/fixtures/{ => comparator}/deleted_group.json (100%) rename resources/fixtures/{ => comparator}/deleted_strategy.json (100%) rename resources/fixtures/{ => comparator}/deleted_strategy_value.json (100%) rename resources/fixtures/{ => comparator}/new_component.json (100%) rename resources/fixtures/{ => comparator}/new_config.json (100%) rename resources/fixtures/{ => comparator}/new_group.json (100%) rename resources/fixtures/{ => comparator}/new_strategy.json (100%) rename resources/fixtures/{ => comparator}/new_strategy_value.json (100%) create mode 100644 resources/fixtures/util/default.json diff --git a/.env.test b/.env.test index 352effe..914a0a5 100644 --- a/.env.test +++ b/.env.test @@ -2,11 +2,10 @@ PORT=8000 MONGO_URI=mongodb://localhost:27017 MONGO_DB=switcher-gitops-test -SWITCHER_API_URL=https://switcherapi.com/api/gitops-graphql -SWITCHER_API_JWT_SECRET=[YOUR_JWT_SECRET] +SWITCHER_API_URL=https://switcherapi.com/api +SWITCHER_API_JWT_SECRET= # Only for testing purposes. Values are loaded from accounts -API_DOMAIN_ID= GIT_USER= GIT_TOKEN= GIT_TOKEN_READ_ONLY= diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index c38e292..17ebb4f 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -17,10 +17,10 @@ jobs: with: fetch-depth: 0 - - name: Set up Go 1.22.4 + - name: Set up Go 1.23.0 uses: actions/setup-go@v5 with: - go-version: '1.22.4' + go-version: '1.23.0' - name: Start MongoDB uses: supercharge/mongodb-github-action@1.11.0 diff --git a/go.mod b/go.mod index cc4cd1e..3506d71 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/switcherapi/switcher-gitops -go 1.22 +go 1.23 -toolchain go1.22.4 +toolchain go1.23.0 require ( github.com/go-git/go-billy/v5 v5.5.0 diff --git a/resources/fixtures/api/default_snapshot.json b/resources/fixtures/api/default_snapshot.json new file mode 100644 index 0000000..e63a444 --- /dev/null +++ b/resources/fixtures/api/default_snapshot.json @@ -0,0 +1,35 @@ +{ + "data": { + "domain": { + "name": "GitOps", + "version": 1718772781488, + "group": [ + { + "name": "Group 1", + "description": "", + "activated": true, + "config": [ + { + "key": "FEATURE_1", + "description": "", + "activated": true, + "strategies": [ + { + "strategy": "VALUE_VALIDATION", + "activated": false, + "operation": "EXIST", + "values": [ + "test2" + ] + } + ], + "components": [ + "app1" + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/resources/fixtures/api/error_invalid_domain.json b/resources/fixtures/api/error_invalid_domain.json new file mode 100644 index 0000000..be19e66 --- /dev/null +++ b/resources/fixtures/api/error_invalid_domain.json @@ -0,0 +1,19 @@ +{ + "errors": [ + { + "message": "Cast to ObjectId failed for value \"INVALID_DOMAIN\" (type string) at path \"_id\" for model \"Domain\"", + "locations": [ + { + "line": 3, + "column": 9 + } + ], + "path": [ + "domain" + ] + } + ], + "data": { + "domain": null + } +} \ No newline at end of file diff --git a/resources/fixtures/changed_config.json b/resources/fixtures/comparator/changed_config.json similarity index 100% rename from resources/fixtures/changed_config.json rename to resources/fixtures/comparator/changed_config.json diff --git a/resources/fixtures/changed_group.json b/resources/fixtures/comparator/changed_group.json similarity index 100% rename from resources/fixtures/changed_group.json rename to resources/fixtures/comparator/changed_group.json diff --git a/resources/fixtures/changed_strategy.json b/resources/fixtures/comparator/changed_strategy.json similarity index 100% rename from resources/fixtures/changed_strategy.json rename to resources/fixtures/comparator/changed_strategy.json diff --git a/resources/fixtures/default.json b/resources/fixtures/comparator/default.json similarity index 100% rename from resources/fixtures/default.json rename to resources/fixtures/comparator/default.json diff --git a/resources/fixtures/default_empty.json b/resources/fixtures/comparator/default_empty.json similarity index 100% rename from resources/fixtures/default_empty.json rename to resources/fixtures/comparator/default_empty.json diff --git a/resources/fixtures/default_empty_config.json b/resources/fixtures/comparator/default_empty_config.json similarity index 100% rename from resources/fixtures/default_empty_config.json rename to resources/fixtures/comparator/default_empty_config.json diff --git a/resources/fixtures/deleted_component.json b/resources/fixtures/comparator/deleted_component.json similarity index 100% rename from resources/fixtures/deleted_component.json rename to resources/fixtures/comparator/deleted_component.json diff --git a/resources/fixtures/deleted_config.json b/resources/fixtures/comparator/deleted_config.json similarity index 100% rename from resources/fixtures/deleted_config.json rename to resources/fixtures/comparator/deleted_config.json diff --git a/resources/fixtures/deleted_group.json b/resources/fixtures/comparator/deleted_group.json similarity index 100% rename from resources/fixtures/deleted_group.json rename to resources/fixtures/comparator/deleted_group.json diff --git a/resources/fixtures/deleted_strategy.json b/resources/fixtures/comparator/deleted_strategy.json similarity index 100% rename from resources/fixtures/deleted_strategy.json rename to resources/fixtures/comparator/deleted_strategy.json diff --git a/resources/fixtures/deleted_strategy_value.json b/resources/fixtures/comparator/deleted_strategy_value.json similarity index 100% rename from resources/fixtures/deleted_strategy_value.json rename to resources/fixtures/comparator/deleted_strategy_value.json diff --git a/resources/fixtures/new_component.json b/resources/fixtures/comparator/new_component.json similarity index 100% rename from resources/fixtures/new_component.json rename to resources/fixtures/comparator/new_component.json diff --git a/resources/fixtures/new_config.json b/resources/fixtures/comparator/new_config.json similarity index 100% rename from resources/fixtures/new_config.json rename to resources/fixtures/comparator/new_config.json diff --git a/resources/fixtures/new_group.json b/resources/fixtures/comparator/new_group.json similarity index 100% rename from resources/fixtures/new_group.json rename to resources/fixtures/comparator/new_group.json diff --git a/resources/fixtures/new_strategy.json b/resources/fixtures/comparator/new_strategy.json similarity index 100% rename from resources/fixtures/new_strategy.json rename to resources/fixtures/comparator/new_strategy.json diff --git a/resources/fixtures/new_strategy_value.json b/resources/fixtures/comparator/new_strategy_value.json similarity index 100% rename from resources/fixtures/new_strategy_value.json rename to resources/fixtures/comparator/new_strategy_value.json diff --git a/resources/fixtures/util/default.json b/resources/fixtures/util/default.json new file mode 100644 index 0000000..fff0302 --- /dev/null +++ b/resources/fixtures/util/default.json @@ -0,0 +1,49 @@ +{ + "domain": { + "group": [ + { + "name": "Release 1", + "description": "Showcase configuration", + "activated": true, + "config": [ + { + "key": "MY_SWITCHER_1", + "description": "My first switcher", + "activated": true, + "strategies": [ + { + "strategy": "VALUE_VALIDATION", + "activated": false, + "operation": "EXIST", + "values": [ + "user_1" + ] + } + ], + "components": [ + "switcher-playground" + ] + }, + { + "key": "MY_SWITCHER_2", + "description": "", + "activated": false, + "strategies": [], + "components": [ + "switcher-playground" + ] + }, + { + "key": "MY_SWITCHER_3", + "description": "", + "activated": true, + "strategies": [], + "components": [ + "benchmark" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/src/core/api_test.go b/src/core/api_test.go index 8d794a3..2f33d6c 100644 --- a/src/core/api_test.go +++ b/src/core/api_test.go @@ -8,16 +8,19 @@ import ( "github.com/stretchr/testify/assert" "github.com/switcherapi/switcher-gitops/src/config" "github.com/switcherapi/switcher-gitops/src/model" + "github.com/switcherapi/switcher-gitops/src/utils" ) -func TestFetchSnapshot(t *testing.T) { - if !canRunIntegratedTests() { - t.Skip(SkipMessage) - } +const SWITCHER_API_JWT_SECRET = "SWITCHER_API_JWT_SECRET" +func TestFetchSnapshot(t *testing.T) { t.Run("Should return snapshot", func(t *testing.T) { - apiService := NewApiService(config.GetEnv("SWITCHER_API_JWT_SECRET"), config.GetEnv("SWITCHER_API_URL")) - snapshot, _ := apiService.FetchSnapshot(config.GetEnv("API_DOMAIN_ID"), "default") + responsePayload := utils.ReadJsonFromFile("../../resources/fixtures/api/default_snapshot.json") + fakeApiServer := givenApiResponse(http.StatusOK, responsePayload) + defer fakeApiServer.Close() + + apiService := NewApiService(SWITCHER_API_JWT_SECRET, fakeApiServer.URL) + snapshot, _ := apiService.FetchSnapshot("domainId", "default") assert.Contains(t, snapshot, "domain", "Missing domain in snapshot") assert.Contains(t, snapshot, "version", "Missing version in snapshot") @@ -26,8 +29,12 @@ func TestFetchSnapshot(t *testing.T) { }) t.Run("Should return data from snapshot", func(t *testing.T) { - apiService := NewApiService(config.GetEnv("SWITCHER_API_JWT_SECRET"), config.GetEnv("SWITCHER_API_URL")) - snapshot, _ := apiService.FetchSnapshot(config.GetEnv("API_DOMAIN_ID"), "default") + responsePayload := utils.ReadJsonFromFile("../../resources/fixtures/api/default_snapshot.json") + fakeApiServer := givenApiResponse(http.StatusOK, responsePayload) + defer fakeApiServer.Close() + + apiService := NewApiService(SWITCHER_API_JWT_SECRET, fakeApiServer.URL) + snapshot, _ := apiService.FetchSnapshot("domainId", "default") data := apiService.NewDataFromJson([]byte(snapshot)) assert.NotNil(t, data.Snapshot.Domain, "domain", "Missing domain in data") @@ -36,22 +43,29 @@ func TestFetchSnapshot(t *testing.T) { }) t.Run("Should return error - invalid API key", func(t *testing.T) { - apiService := NewApiService("INVALID_KEY", config.GetEnv("SWITCHER_API_URL")) - snapshot, _ := apiService.FetchSnapshot(config.GetEnv("API_DOMAIN_ID"), "default") + fakeApiServer := givenApiResponse(http.StatusUnauthorized, `{ "error": "Invalid API token" }`) + defer fakeApiServer.Close() + + apiService := NewApiService("INVALID_KEY", fakeApiServer.URL) + snapshot, _ := apiService.FetchSnapshot("domainId", "default") assert.Contains(t, snapshot, "Invalid API token") }) t.Run("Should return error - invalid domain", func(t *testing.T) { - apiService := NewApiService(config.GetEnv("SWITCHER_API_JWT_SECRET"), config.GetEnv("SWITCHER_API_URL")) + responsePayload := utils.ReadJsonFromFile("../../resources/fixtures/api/error_invalid_domain.json") + fakeApiServer := givenApiResponse(http.StatusUnauthorized, responsePayload) + defer fakeApiServer.Close() + + apiService := NewApiService(SWITCHER_API_JWT_SECRET, fakeApiServer.URL) snapshot, _ := apiService.FetchSnapshot("INVALID_DOMAIN", "default") assert.Contains(t, snapshot, "errors") }) t.Run("Should return error - invalid API URL", func(t *testing.T) { - apiService := NewApiService(config.GetEnv("SWITCHER_API_JWT_SECRET"), "http://localhost:8080") - _, err := apiService.FetchSnapshot(config.GetEnv("API_DOMAIN_ID"), "default") + apiService := NewApiService(config.GetEnv(SWITCHER_API_JWT_SECRET), "http://localhost:8080") + _, err := apiService.FetchSnapshot("domainId", "default") AssertNotNil(t, err) }) @@ -67,7 +81,7 @@ func TestApplyChangesToAPI(t *testing.T) { }`) defer fakeApiServer.Close() - apiService := NewApiService("[SWITCHER_API_JWT_SECRET]", fakeApiServer.URL) + apiService := NewApiService(SWITCHER_API_JWT_SECRET, fakeApiServer.URL) // Test response, _ := apiService.ApplyChangesToAPI("domainId", "default", diff) diff --git a/src/core/comparator_test.go b/src/core/comparator_test.go index 76db790..6b6855e 100644 --- a/src/core/comparator_test.go +++ b/src/core/comparator_test.go @@ -8,7 +8,7 @@ import ( "github.com/switcherapi/switcher-gitops/src/utils" ) -const DEFAULT_JSON = "../../resources/fixtures/default.json" +const DEFAULT_JSON = "../../resources/fixtures/comparator/default.json" func TestCheckGroupSnapshot(t *testing.T) { c := NewComparatorService() @@ -16,7 +16,7 @@ func TestCheckGroupSnapshot(t *testing.T) { t.Run("Should return changes in group", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/changed_group.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/changed_group.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -46,7 +46,7 @@ func TestCheckGroupSnapshot(t *testing.T) { t.Run("Should return new group", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/new_group.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/new_group.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -84,7 +84,7 @@ func TestCheckGroupSnapshot(t *testing.T) { t.Run("Should return deleted group", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/deleted_group.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/deleted_group.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -110,7 +110,7 @@ func TestCheckGroupSnapshot(t *testing.T) { t.Run("Should return new group from empty group", func(t *testing.T) { // Given - jsonLeft := utils.ReadJsonFromFile("../../resources/fixtures/default_empty.json") + jsonLeft := utils.ReadJsonFromFile("../../resources/fixtures/comparator/default_empty.json") jsonRight := utils.ReadJsonFromFile(DEFAULT_JSON) snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -128,7 +128,7 @@ func TestCheckGroupSnapshot(t *testing.T) { t.Run("Should return new group from empty config", func(t *testing.T) { // Given - jsonLeft := utils.ReadJsonFromFile("../../resources/fixtures/default_empty_config.json") + jsonLeft := utils.ReadJsonFromFile("../../resources/fixtures/comparator/default_empty_config.json") jsonRight := utils.ReadJsonFromFile(DEFAULT_JSON) snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -151,7 +151,7 @@ func TestCheckConfigSnapshot(t *testing.T) { t.Run("Should return changes in config", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/changed_config.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/changed_config.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -182,7 +182,7 @@ func TestCheckConfigSnapshot(t *testing.T) { t.Run("Should return new config", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/new_config.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/new_config.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -215,7 +215,7 @@ func TestCheckConfigSnapshot(t *testing.T) { t.Run("Should return deleted config", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/deleted_config.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/deleted_config.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -247,7 +247,7 @@ func TestCheckStrategySnapshot(t *testing.T) { t.Run("Should return changes in strategy", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/changed_strategy.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/changed_strategy.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -278,7 +278,7 @@ func TestCheckStrategySnapshot(t *testing.T) { t.Run("Should return new strategy", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/new_strategy.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/new_strategy.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -313,7 +313,7 @@ func TestCheckStrategySnapshot(t *testing.T) { t.Run("Should return deleted strategy", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/deleted_strategy.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/deleted_strategy.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -342,7 +342,7 @@ func TestCheckStrategySnapshot(t *testing.T) { t.Run("Should return new strategy value", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/new_strategy_value.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/new_strategy_value.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -373,7 +373,7 @@ func TestCheckStrategySnapshot(t *testing.T) { t.Run("Should return deleted strategy value", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/deleted_strategy_value.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/deleted_strategy_value.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -408,7 +408,7 @@ func TestCheckComponentSnapshot(t *testing.T) { t.Run("Should return new component", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/new_component.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/new_component.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) @@ -438,7 +438,7 @@ func TestCheckComponentSnapshot(t *testing.T) { t.Run("Should return deleted component", func(t *testing.T) { // Given jsonLeft := utils.ReadJsonFromFile(DEFAULT_JSON) - jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/deleted_component.json") + jsonRight := utils.ReadJsonFromFile("../../resources/fixtures/comparator/deleted_component.json") snapshotLeft := c.NewSnapshotFromJson([]byte(jsonLeft)) snapshotRight := c.NewSnapshotFromJson([]byte(jsonRight)) diff --git a/src/core/core_test.go b/src/core/core_test.go index 9cd33d2..3bf7989 100644 --- a/src/core/core_test.go +++ b/src/core/core_test.go @@ -46,8 +46,7 @@ func canRunIntegratedTests() bool { return config.GetEnv("GIT_REPO_URL") != "" && config.GetEnv("GIT_TOKEN") != "" && config.GetEnv("GIT_TOKEN_READ_ONLY") != "" && - config.GetEnv("GIT_BRANCH") != "" && - config.GetEnv("API_DOMAIN_ID") != "" + config.GetEnv("GIT_BRANCH") != "" } func AssertNotNil(t *testing.T, object interface{}) { diff --git a/src/utils/util_test.go b/src/utils/util_test.go index 85a2225..975ea5a 100644 --- a/src/utils/util_test.go +++ b/src/utils/util_test.go @@ -27,7 +27,7 @@ func TestFormatJSONError(t *testing.T) { } func TestReadJsonFileToObject(t *testing.T) { - json := ReadJsonFromFile("../../resources/fixtures/default.json") + json := ReadJsonFromFile("../../resources/fixtures/util/default.json") AssertNotNil(t, json) AssertContains(t, json, "Release 1") } From 97c748cb8662ed4712fae42d31d9828b1c792740 Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Tue, 3 Sep 2024 20:44:23 -0700 Subject: [PATCH 2/2] chore: removed unused test config --- .github/workflows/master.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 17ebb4f..ae0e58c 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -38,7 +38,6 @@ jobs: MONGO_DB: switcher-gitops-test SWITCHER_API_URL: ${{ secrets.SWITCHER_API_URL }} SWITCHER_API_JWT_SECRET: ${{ secrets.SWITCHER_API_JWT_SECRET }} - API_DOMAIN_ID: ${{ secrets.API_DOMAIN_ID }} GIT_TOKEN: ${{ secrets.GIT_TOKEN }} GIT_USER: ${{ secrets.GIT_USER }} GIT_TOKEN_READ_ONLY: ${{ secrets.GIT_TOKEN_READ_ONLY }}