From dc8ca9f7eb18d209242a4e5a0a280f0424e2d257 Mon Sep 17 00:00:00 2001 From: dido18 Date: Wed, 10 Dec 2025 16:48:34 +0100 Subject: [PATCH 1/3] Update validator_test.go --- internal/orchestrator/app/validator_test.go | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/internal/orchestrator/app/validator_test.go b/internal/orchestrator/app/validator_test.go index 13e3e9d3..f0b27477 100644 --- a/internal/orchestrator/app/validator_test.go +++ b/internal/orchestrator/app/validator_test.go @@ -33,6 +33,22 @@ func TestValidateAppDescriptorBricks(t *testing.T) { }, }, }, + { + ID: "arduino:brick-with-hidden-variable", + Name: "Hidden variable brick", + Variables: []bricksindex.BrickVariable{ + { + Name: "I_AM_HIDDEN", + Description: "I am an hidden variable", + Hidden: true, + }, + { + Name: "I_AM_HIDDEN_AND_REQUIRED", + Description: "I am an hidden and required variable", + DefaultValue: "", // Required (no default value) + }, + }, + }, }, } @@ -134,6 +150,15 @@ bricks: NOT_EXISTING_VARIABLE: "this-is-a-not-existing-variable-for-the-brick" ARDUINO_DEVICE_ID: "my-device-id" ARDUINO_SECRET: "my-secret" +`, + expectedError: nil, + }, + { + name: "hidden variables are not required to be set", + yamlContent: ` +name: App with +bricks: + - arduino:brick-with-hidden-variable: `, expectedError: nil, }, From 5a67a5daa54c733fe37114553f166c31fb2625c8 Mon Sep 17 00:00:00 2001 From: dido18 Date: Mon, 15 Dec 2025 10:43:05 +0100 Subject: [PATCH 2/3] Update tests for hidden required variables in validator --- internal/orchestrator/app/validator_test.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/internal/orchestrator/app/validator_test.go b/internal/orchestrator/app/validator_test.go index f0b27477..b4c692e0 100644 --- a/internal/orchestrator/app/validator_test.go +++ b/internal/orchestrator/app/validator_test.go @@ -38,14 +38,8 @@ func TestValidateAppDescriptorBricks(t *testing.T) { Name: "Hidden variable brick", Variables: []bricksindex.BrickVariable{ { - Name: "I_AM_HIDDEN", - Description: "I am an hidden variable", - Hidden: true, - }, - { - Name: "I_AM_HIDDEN_AND_REQUIRED", - Description: "I am an hidden and required variable", - DefaultValue: "", // Required (no default value) + Name: "I_AM_HIDDEN_WITHOUT_DEFAULT", + Hidden: true, }, }, }, @@ -154,13 +148,13 @@ bricks: expectedError: nil, }, { - name: "hidden variables are not required to be set", + name: "is required works also for hidden variables", yamlContent: ` name: App with bricks: - arduino:brick-with-hidden-variable: `, - expectedError: nil, + expectedError: errors.New("variable \"I_AM_HIDDEN_WITHOUT_DEFAULT\" is required by brick \"arduino:brick-with-hidden-variable\""), }, } From 1639031cb7d06a6f3aa518af3a53fa557b7b3756 Mon Sep 17 00:00:00 2001 From: dido18 Date: Mon, 15 Dec 2025 11:00:53 +0100 Subject: [PATCH 3/3] Add test for hidden variable with default value not required --- internal/orchestrator/app/validator_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/orchestrator/app/validator_test.go b/internal/orchestrator/app/validator_test.go index b4c692e0..0e87028f 100644 --- a/internal/orchestrator/app/validator_test.go +++ b/internal/orchestrator/app/validator_test.go @@ -41,6 +41,11 @@ func TestValidateAppDescriptorBricks(t *testing.T) { Name: "I_AM_HIDDEN_WITHOUT_DEFAULT", Hidden: true, }, + { + Name: "I_AM_HIDDEN_WITH_DEFAULT", + Hidden: true, + DefaultValue: "default-value", + }, }, }, }, @@ -156,6 +161,17 @@ bricks: `, expectedError: errors.New("variable \"I_AM_HIDDEN_WITHOUT_DEFAULT\" is required by brick \"arduino:brick-with-hidden-variable\""), }, + { + name: "an hiddden variable with default value is not required", + yamlContent: ` +name: App with +bricks: + - arduino:brick-with-hidden-variable: + variables: + I_AM_HIDDEN_WITHOUT_DEFAULT: "some-value" +`, + expectedError: nil, + }, } for _, tc := range testCases {