Skip to content

Commit 70e1dbb

Browse files
committed
test: add YAML test cases for app descriptor validation with empty and omitted variables
1 parent 05f12bf commit 70e1dbb

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: App with an empty variable
2+
description: App withan empty variable
3+
bricks:
4+
- arduino:arduino_cloud:
5+
variables:
6+
ARDUINO_DEVICE_ID: "my-device-id"
7+
ARDUINO_SECRET:

internal/orchestrator/app/validator_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,33 @@ func TestValidateAppDescriptorBricks(t *testing.T) {
2323
expectedErr *string
2424
}{
2525
{
26-
name: "valid app descriptor with no bricks",
26+
name: "valid with missing bricks",
2727
filename: "no-bricks-app.yaml",
2828
expectedErr: nil,
2929
},
3030
{
31-
name: "valid app descriptor with empty list of bricks",
31+
name: "valid with empty list of bricks",
3232
filename: "empty-bricks-app.yaml",
3333
expectedErr: nil,
3434
},
3535
{
36-
name: "invalid app descriptor with missing required variable",
37-
filename: "missing-required-app.yaml",
36+
name: "valid if required variable is empty string",
37+
filename: "empty-required-app.yaml",
38+
expectedErr: nil,
39+
},
40+
{
41+
name: "invalid if required variable is omitted",
42+
filename: "omitted-required-app.yaml",
3843
expectedErr: f.Ptr("variable \"ARDUINO_DEVICE_ID\" is required by brick \"arduino:arduino_cloud\""),
3944
},
4045
{
41-
name: "invalid app descriptor with a missing required variable among two",
42-
filename: "mixed-required-app.yaml",
46+
name: "invalid if required variable among two is omitted",
47+
filename: "omitted-mixed-required-app.yaml",
4348
expectedErr: f.Ptr("variable \"ARDUINO_SECRET\" is required by brick \"arduino:arduino_cloud\""),
4449
},
50+
4551
{
46-
name: "invalid app descriptor with not found brick id",
52+
name: "invalid if brick id not found",
4753
filename: "not-found-brick-app.yaml",
4854
expectedErr: f.Ptr("brick \"arduino:not_existing_brick\" not found"),
4955
},

0 commit comments

Comments
 (0)