fix(test): finish fixing organisation refactoring tests failures
All checks were successful
test / test (push) Successful in 53s
All checks were successful
test / test (push) Successful in 53s
This commit is contained in:
parent
6a91b556a5
commit
ce2fb4208d
2 changed files with 30 additions and 8 deletions
|
|
@ -152,6 +152,7 @@ kind: edgeconnect-deployment
|
|||
metadata:
|
||||
name: "test-app"
|
||||
appVersion: "1.0.0"
|
||||
organization: "testorg"
|
||||
spec:
|
||||
dockerApp:
|
||||
image: "nginx:latest"
|
||||
|
|
@ -385,42 +386,60 @@ func TestMetadata_Validate(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "valid metadata",
|
||||
metadata: Metadata{Name: "test-app", AppVersion: "1.0.0"},
|
||||
metadata: Metadata{Name: "test-app", AppVersion: "1.0.0", Organization: "testorg"},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "empty name",
|
||||
metadata: Metadata{Name: "", AppVersion: "1.0.0"},
|
||||
metadata: Metadata{Name: "", AppVersion: "1.0.0", Organization: "testorg"},
|
||||
wantErr: true,
|
||||
errMsg: "metadata.name is required",
|
||||
},
|
||||
{
|
||||
name: "name with leading whitespace",
|
||||
metadata: Metadata{Name: " test-app", AppVersion: "1.0.0"},
|
||||
metadata: Metadata{Name: " test-app", AppVersion: "1.0.0", Organization: "testorg"},
|
||||
wantErr: true,
|
||||
errMsg: "cannot have leading/trailing whitespace",
|
||||
},
|
||||
{
|
||||
name: "name with trailing whitespace",
|
||||
metadata: Metadata{Name: "test-app ", AppVersion: "1.0.0"},
|
||||
metadata: Metadata{Name: "test-app ", AppVersion: "1.0.0", Organization: "testorg"},
|
||||
wantErr: true,
|
||||
errMsg: "cannot have leading/trailing whitespace",
|
||||
},
|
||||
{
|
||||
name: "empty app version",
|
||||
metadata: Metadata{Name: "test-app", AppVersion: ""},
|
||||
metadata: Metadata{Name: "test-app", AppVersion: "", Organization: "testorg"},
|
||||
wantErr: true,
|
||||
errMsg: "metadata.appVersion is required",
|
||||
},
|
||||
{
|
||||
name: "app version with leading whitespace",
|
||||
metadata: Metadata{Name: "test-app", AppVersion: " 1.0.0"},
|
||||
metadata: Metadata{Name: "test-app", AppVersion: " 1.0.0", Organization: "testorg"},
|
||||
wantErr: true,
|
||||
errMsg: "cannot have leading/trailing whitespace",
|
||||
},
|
||||
{
|
||||
name: "app version with trailing whitespace",
|
||||
metadata: Metadata{Name: "test-app", AppVersion: "1.0.0 "},
|
||||
metadata: Metadata{Name: "test-app", AppVersion: "1.0.0 ", Organization: "testorg"},
|
||||
wantErr: true,
|
||||
errMsg: "cannot have leading/trailing whitespace",
|
||||
},
|
||||
{
|
||||
name: "empty organization",
|
||||
metadata: Metadata{Name: "test-app", AppVersion: "1.0.0", Organization: ""},
|
||||
wantErr: true,
|
||||
errMsg: "metadata.organization is required",
|
||||
},
|
||||
{
|
||||
name: "organization with leading whitespace",
|
||||
metadata: Metadata{Name: "test-app", AppVersion: "1.0.0", Organization: " testorg"},
|
||||
wantErr: true,
|
||||
errMsg: "cannot have leading/trailing whitespace",
|
||||
},
|
||||
{
|
||||
name: "organization with trailing whitespace",
|
||||
metadata: Metadata{Name: "test-app", AppVersion: "1.0.0", Organization: "testorg "},
|
||||
wantErr: true,
|
||||
errMsg: "cannot have leading/trailing whitespace",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -122,9 +122,12 @@ func (m *Metadata) Validate() error {
|
|||
}
|
||||
|
||||
if m.Organization == "" {
|
||||
return fmt.Errorf("organization is required")
|
||||
return fmt.Errorf("metadata.organization is required")
|
||||
}
|
||||
|
||||
if strings.TrimSpace(m.Organization) != m.Organization {
|
||||
return fmt.Errorf("metadata.Organization cannot have leading/trailing whitespace")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue