Skip to content

Commit a0db56f

Browse files
committed
Update test cases for validateIndexComponent
Signed-off-by: thepetk <[email protected]>
1 parent 6700c41 commit a0db56f

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

index/generator/library/library_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestValidateIndexComponent(t *testing.T) {
4646
noVersionErr := ".*no version specified.*"
4747
schemaVersionEmptyErr := ".*schema version is empty.*"
4848
multipleVersionErr := ".*has multiple default versions.*"
49+
iconUrlBrokenErr := ".*has broken or not existing icon.*"
4950

5051
tests := []struct {
5152
name string
@@ -112,6 +113,7 @@ func TestValidateIndexComponent(t *testing.T) {
112113
"Case 5: test happy path for for stack component",
113114
schema.Schema{
114115
Name: "nodejs",
116+
Icon: "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/java-maven.jpg",
115117
Architectures: []string{
116118
"amd64",
117119
},
@@ -148,6 +150,7 @@ func TestValidateIndexComponent(t *testing.T) {
148150
"Case 6: test happy path for for sample component with old struct",
149151
schema.Schema{
150152
Name: "nodejs",
153+
Icon: "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/java-maven.jpg",
151154
Git: &schema.Git{
152155
Remotes: map[string]string{
153156
"origin": "https://github.com/redhat-developer/devfile-sample",
@@ -176,10 +179,12 @@ func TestValidateIndexComponent(t *testing.T) {
176179
schema.SampleDevfileType,
177180
&multipleRemotesErr,
178181
},
182+
179183
{
180184
"Case 8: check for missing arch",
181185
schema.Schema{
182186
Name: "nodejs",
187+
Icon: "https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg",
183188
Git: &schema.Git{
184189
Remotes: map[string]string{
185190
"origin": "https://github.com/redhat-developer/devfile-sample",
@@ -195,6 +200,7 @@ func TestValidateIndexComponent(t *testing.T) {
195200
"Case 9: check for missing provider",
196201
schema.Schema{
197202
Name: "nodejs",
203+
Icon: "https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg",
198204
Versions: []schema.Version{
199205
{
200206
Version: "1.0.0",
@@ -220,6 +226,7 @@ func TestValidateIndexComponent(t *testing.T) {
220226
"Case 10: check for missing supportUrl",
221227
schema.Schema{
222228
Name: "nodejs",
229+
Icon: "https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg",
223230
Versions: []schema.Version{
224231
{
225232
Version: "1.0.0",
@@ -354,6 +361,7 @@ func TestValidateIndexComponent(t *testing.T) {
354361
"Case 16: test happy path for for sample component with new struct",
355362
schema.Schema{
356363
Name: "nodejs",
364+
Icon: "https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg",
357365
Versions: []schema.Version{
358366
{
359367
Version: "1.0.0",
@@ -479,6 +487,49 @@ func TestValidateIndexComponent(t *testing.T) {
479487
schema.SampleDevfileType,
480488
&multipleVersionErr,
481489
},
490+
{
491+
"Case 21: test stack component missing iconUrl",
492+
schema.Schema{
493+
Name: "nodejs",
494+
Versions: []schema.Version{
495+
{
496+
Version: "1.0.0",
497+
SchemaVersion: "2.0.0",
498+
Default: true,
499+
Links: map[string]string{
500+
"self": "devfile-catalog/java-maven:latest",
501+
},
502+
Resources: []string{
503+
"devfile.yaml",
504+
},
505+
},
506+
},
507+
},
508+
schema.StackDevfileType,
509+
&iconUrlBrokenErr,
510+
},
511+
{
512+
"Case 22: test stack component has wrong iconUrl",
513+
schema.Schema{
514+
Name: "nodejs",
515+
Icon: "https://github.com/"
516+
Versions: []schema.Version{
517+
{
518+
Version: "1.0.0",
519+
SchemaVersion: "2.0.0",
520+
Default: true,
521+
Links: map[string]string{
522+
"self": "devfile-catalog/java-maven:latest",
523+
},
524+
Resources: []string{
525+
"devfile.yaml",
526+
},
527+
},
528+
},
529+
},
530+
schema.StackDevfileType,
531+
&iconUrlBrokenErr,
532+
},
482533
}
483534

484535
for _, tt := range tests {

0 commit comments

Comments
 (0)