diff --git a/.github/workflows/api-unit-test.yml b/.github/workflows/api-unit-test.yml index 3e0a377bd..f9ec06c2c 100644 --- a/.github/workflows/api-unit-test.yml +++ b/.github/workflows/api-unit-test.yml @@ -76,7 +76,7 @@ jobs: defaults: run: working-directory: ./ - # if: github.ref == 'refs/heads/main' && github.event.head_commit.author.name != 'GitHubActions' + if: github.ref == 'refs/heads/main' && github.event.head_commit.author.name != 'GitHubActions' steps: - uses: actions/checkout@v4 @@ -102,7 +102,7 @@ jobs: defaults: run: working-directory: ./ - # if: github.ref == 'refs/heads/main' && github.event.head_commit.author.name != 'GitHubActions' + if: github.ref == 'refs/heads/main' && github.event.head_commit.author.name != 'GitHubActions' steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/cli-unit-test.yml b/.github/workflows/cli-unit-test.yml index d58706bcf..e3cafeca8 100644 --- a/.github/workflows/cli-unit-test.yml +++ b/.github/workflows/cli-unit-test.yml @@ -73,7 +73,7 @@ jobs: defaults: run: working-directory: ./ - # if: github.ref == 'refs/heads/main' && github.event.head_commit.author.name != 'GitHubActions' + if: github.ref == 'refs/heads/main' && github.event.head_commit.author.name != 'GitHubActions' steps: - uses: actions/checkout@v4 @@ -99,7 +99,7 @@ jobs: defaults: run: working-directory: ./ - # if: github.ref == 'refs/heads/main' && github.event.head_commit.author.name != 'GitHubActions' + if: github.ref == 'refs/heads/main' && github.event.head_commit.author.name != 'GitHubActions' steps: - uses: actions/checkout@v4 diff --git a/API/controllers/entity_test.go b/API/controllers/entity_test.go index 7afb70614..787c93468 100644 --- a/API/controllers/entity_test.go +++ b/API/controllers/entity_test.go @@ -10,6 +10,7 @@ import ( test_utils "p3/test/utils" "p3/utils" "slices" + "strings" "testing" "time" @@ -613,21 +614,21 @@ func TestGetLayersObjectsWithSimpleFilter(t *testing.T) { assert.True(t, condition) } -// func TestGetLayersObjectsWithDoubleFilter(t *testing.T) { -// endpoint := test_utils.GetEndpoint("layersObjects", "racks-1-layer") -// expectedMessage := "successfully processed request" -// response := e2e.ValidateManagedRequest(t, "GET", endpoint+"?root=site-no-temperature.building-1.room-*", nil, http.StatusOK, expectedMessage) +func TestGetLayersObjectsWithDoubleFilter(t *testing.T) { + endpoint := test_utils.GetEndpoint("layersObjects", "racks-1-layer") + expectedMessage := "successfully processed request" + response := e2e.ValidateManagedRequest(t, "GET", endpoint+"?root=site-no-temperature.building-1.room-*", nil, http.StatusOK, expectedMessage) -// data, exists := response["data"].([]any) -// assert.True(t, exists) -// assert.Equal(t, 2, len(data)) + data, exists := response["data"].([]any) + assert.True(t, exists) + assert.Equal(t, 2, len(data)) -// condition := true -// for _, rack := range data { -// condition = condition && strings.HasPrefix(rack.(map[string]any)["parentId"].(string), "site-no-temperature.building-1.room-") -// condition = condition && rack.(map[string]any)["category"] == "rack" -// condition = condition && rack.(map[string]any)["name"] == "rack-1" -// } + condition := true + for _, rack := range data { + condition = condition && strings.HasPrefix(rack.(map[string]any)["parentId"].(string), "site-no-temperature.building-1.room-") + condition = condition && rack.(map[string]any)["category"] == "rack" + condition = condition && rack.(map[string]any)["name"] == "rack-1" + } -// assert.True(t, condition) -// } + assert.True(t, condition) +} diff --git a/CLI/controllers/commandController_test.go b/CLI/controllers/commandController_test.go index 5ca6af61d..1fabc6452 100644 --- a/CLI/controllers/commandController_test.go +++ b/CLI/controllers/commandController_test.go @@ -777,29 +777,29 @@ func TestIsEntityDrawableObjectNotFound(t *testing.T) { assert.Equal(t, "object not found", err.Error()) } -// func TestIsEntityDrawable(t *testing.T) { -// tests := []struct { -// name string -// drawableObjects []int -// expectedIsDrawable bool -// }{ -// {"CategoryIsNotDrawable", []int{models.EntityStrToInt("device")}, false}, -// {"CategoryIsDrawable", []int{models.EntityStrToInt("rack")}, true}, -// } - -// for _, tt := range tests { -// t.Run(tt.name, func(t *testing.T) { -// controller, mockAPI, _ := layersSetup(t) -// controllers.State.DrawableObjs = tt.drawableObjects - -// test_utils.MockGetObject(mockAPI, rack1) - -// isDrawable, err := controller.IsEntityDrawable(models.PhysicalPath + "BASIC/A/R1/A01") -// assert.Equal(t, tt.expectedIsDrawable, isDrawable) -// assert.Nil(t, err) -// }) -// } -// } +func TestIsEntityDrawable(t *testing.T) { + tests := []struct { + name string + drawableObjects []int + expectedIsDrawable bool + }{ + {"CategoryIsNotDrawable", []int{models.EntityStrToInt("device")}, false}, + {"CategoryIsDrawable", []int{models.EntityStrToInt("rack")}, true}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + controller, mockAPI, _ := layersSetup(t) + controllers.State.DrawableObjs = tt.drawableObjects + + test_utils.MockGetObject(mockAPI, rack1) + + isDrawable, err := controller.IsEntityDrawable(models.PhysicalPath + "BASIC/A/R1/A01") + assert.Equal(t, tt.expectedIsDrawable, isDrawable) + assert.Nil(t, err) + }) + } +} // Tests IsAttrDrawable (and IsCategoryAttrDrawable) func TestIsAttrDrawableObjectNotFound(t *testing.T) { diff --git a/README.md b/README.md index de0505fcc..49ce8617a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ditrit_OGrEE-Core&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ditrit_OGrEE-Core) [![API Coverage](https://raw.githubusercontent.com/ditrit/OGrEE-Core/coverage_badges/api_coverage_badge.svg)](https://github.com/ditrit/OGrEE-Core/actions/workflows/api-unit-test.yml) -[![CLI Coverage](https://raw.githubusercontent.com/ditrit/OGrEE-Core/coverage_badges/cli_coverage_badge.svg)](https://github.com/ditrit/OGrEE-Core/actions/workflows/cli-unit-test.yml) +[![CLI Coverage](https://raw.githubusercontent.com/ditrit/OGrEE-Core/cli_coverage_badge/cli_coverage_badge.svg)](https://github.com/ditrit/OGrEE-Core/actions/workflows/cli-unit-test.yml) [![⚙️ Build - Publish](https://github.com/ditrit/OGrEE-Core/actions/workflows/build-deploy.yaml/badge.svg)](https://github.com/ditrit/OGrEE-Core/actions/workflows/build-deploy.yaml)