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:
|
metadata:
|
||||||
name: "test-app"
|
name: "test-app"
|
||||||
appVersion: "1.0.0"
|
appVersion: "1.0.0"
|
||||||
|
organization: "testorg"
|
||||||
spec:
|
spec:
|
||||||
dockerApp:
|
dockerApp:
|
||||||
image: "nginx:latest"
|
image: "nginx:latest"
|
||||||
|
|
@ -385,42 +386,60 @@ func TestMetadata_Validate(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "valid metadata",
|
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,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "empty name",
|
name: "empty name",
|
||||||
metadata: Metadata{Name: "", AppVersion: "1.0.0"},
|
metadata: Metadata{Name: "", AppVersion: "1.0.0", Organization: "testorg"},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
errMsg: "metadata.name is required",
|
errMsg: "metadata.name is required",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "name with leading whitespace",
|
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,
|
wantErr: true,
|
||||||
errMsg: "cannot have leading/trailing whitespace",
|
errMsg: "cannot have leading/trailing whitespace",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "name with 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,
|
wantErr: true,
|
||||||
errMsg: "cannot have leading/trailing whitespace",
|
errMsg: "cannot have leading/trailing whitespace",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "empty app version",
|
name: "empty app version",
|
||||||
metadata: Metadata{Name: "test-app", AppVersion: ""},
|
metadata: Metadata{Name: "test-app", AppVersion: "", Organization: "testorg"},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
errMsg: "metadata.appVersion is required",
|
errMsg: "metadata.appVersion is required",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "app version with leading whitespace",
|
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,
|
wantErr: true,
|
||||||
errMsg: "cannot have leading/trailing whitespace",
|
errMsg: "cannot have leading/trailing whitespace",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "app version with 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,
|
wantErr: true,
|
||||||
errMsg: "cannot have leading/trailing whitespace",
|
errMsg: "cannot have leading/trailing whitespace",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -122,9 +122,12 @@ func (m *Metadata) Validate() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Organization == "" {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue