Skip to content

Commit

Permalink
Test updates for our new action name rules
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Dec 12, 2024
1 parent 402865c commit 6995f13
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions nomad/structs/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,28 @@ func TestAction_Validate(t *testing.T) {
expectedError: errors.New(`invalid name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'`),
},
{
name: "invalid character name",
name: "invalid character name with spaces",
inputAction: &Action{
Name: `\//?|?|?%&%@$&£@$)`,
Name: "invalid name with spaces",
Command: "env",
},
expectedError: errors.New(`invalid name '\//?|?|?%&%@$&£@$)'`),
expectedError: errors.New(`invalid name 'invalid name with spaces'`),
},
{
name: "invalid character name with nulls",
inputAction: &Action{
Name: "invalid\x00name",
Command: "env",
},
expectedError: fmt.Errorf("1 error occurred:\n\t* invalid name 'invalid\x00name'\n\n"), // had to use fmt.Errorf to show the null character
},
{
name: "Emoji characters are valid",
inputAction: &Action{
Name: "🇳🇴🇲🇦🇩",
Command: "env",
},
expectedError: nil,
},
{
name: "valid",
Expand Down

0 comments on commit 6995f13

Please sign in to comment.