-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow long change group names (#337)
Co-authored-by: Dmitriy Kalinin <dkalinin@vmware.com>
- Loading branch information
1 parent
3dd4181
commit b2c6da6
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2021 VMware, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package diffgraph_test | ||
|
||
import ( | ||
"testing" | ||
"strings" | ||
|
||
ctldgraph "github.com/k14s/kapp/pkg/kapp/diffgraph" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNewChangeGroupFromAnnString(t *testing.T) { | ||
names := []string{ | ||
"valid", | ||
"valid-name", | ||
"valid/valid", | ||
"valid-name/valid", | ||
"valid-name.com", | ||
"valid-name.com/valid", | ||
"valid-name.com/valid-name_Another_Name--valid", | ||
"valid-name.com/valid-name_CustomResourceDefinition--valid", | ||
// Allow arbitrary long names since it might be populated with data via placeholders | ||
"valid-name.com/valid-name_CustomResourceDefinition--valid"+strings.Repeat("a", 1000), | ||
// Example from pinniped of a long name | ||
"change-groups.kapp.k14s.io/crds-authentication.concierge.pinniped.dev-WebhookAuthenticator", | ||
} | ||
for _, name := range names { | ||
cg, err := ctldgraph.NewChangeGroupFromAnnString(name) | ||
require.NoError(t, err) | ||
require.Equal(t, cg.Name, name) | ||
} | ||
|
||
names = []string{ | ||
"_", | ||
"invalid/", | ||
"invalid/_", | ||
"/_", | ||
} | ||
for _, name := range names { | ||
_, err := ctldgraph.NewChangeGroupFromAnnString(name) | ||
require.Error(t, err) | ||
} | ||
} |