-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
157 additions
and
106 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
.env | ||
/internal/handler/testassets/bin | ||
internal/handler/testassets/bin/* | ||
|
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 was deleted.
Oops, something went wrong.
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,49 @@ | ||
--- | ||
transforms: | ||
- type: handler.EnvironmentVariable | ||
lookupvalue: | ||
- name: Key | ||
value: PHP_VERSION | ||
exactMatch: true | ||
transformations: | ||
- name: Name | ||
value: PHP | ||
- name: Category | ||
value: Language | ||
- name: Description | ||
value: The currently installed PHP version | ||
keyfact: true | ||
- type: cyclonedx.Component | ||
lookupvalue: | ||
- name: Name | ||
value: drupal/core | ||
exactMatch: true | ||
transformations: | ||
- name: Name | ||
value: Drupal | ||
- name: Category | ||
value: Application | ||
keyfact: true | ||
- type: cyclonedx.Component | ||
lookupvalue: | ||
- name: Name | ||
value: alpine | ||
exactMatch: true | ||
transformations: | ||
- name: Name | ||
value: Alpine Linux | ||
- name: Category | ||
value: OS | ||
- name: Description | ||
value: Base image Alpine Linux version | ||
keyfact: true | ||
- type: cyclonedx.Component | ||
lookupvalue: | ||
- name: Name | ||
value: drush/drush | ||
transformations: | ||
- name: Name | ||
value: Drush | ||
- name: Category | ||
value: Helper | ||
keyfact: true |
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
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,64 @@ | ||
package handler | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestLoadTransformsFromDisk(t *testing.T) { | ||
type args struct { | ||
filename string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want []FactTransform | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "test1 - json", | ||
args: args{filename: "testassets/testLoadTransformsFromDisk/test1.json"}, | ||
want: []FactTransform{ | ||
{ | ||
Type: "test1", | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "test2 - yaml", | ||
args: args{filename: "testassets/testLoadTransformsFromDisk/test2.yaml"}, | ||
want: []FactTransform{ | ||
{ | ||
Type: "test2", | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "test3 - json", | ||
args: args{filename: "testassets/testLoadTransformsFromDisk/test3.yml"}, | ||
want: []FactTransform{ | ||
{ | ||
Type: "test3", | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "test4 - unsupported file type", | ||
args: args{filename: "testassets/testLoadTransformsFromDisk/test4.unsp"}, | ||
want: []FactTransform{}, | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := LoadTransformsFromDisk(tt.args.filename) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("LoadTransformsFromDisk() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if !reflect.DeepEqual(got, tt.want) && tt.wantErr == false { | ||
t.Errorf("LoadTransformsFromDisk() got = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
internal/handler/testassets/testLoadTransformsFromDisk/test1.json
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,7 @@ | ||
{ | ||
"transforms": [ | ||
{ | ||
"type": "test1" | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
internal/handler/testassets/testLoadTransformsFromDisk/test2.yaml
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,3 @@ | ||
--- | ||
transforms: | ||
- type: test2 |
3 changes: 3 additions & 0 deletions
3
internal/handler/testassets/testLoadTransformsFromDisk/test3.yml
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,3 @@ | ||
--- | ||
transforms: | ||
- type: test3 |
3 changes: 3 additions & 0 deletions
3
internal/handler/testassets/testLoadTransformsFromDisk/test4.unsp
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,3 @@ | ||
--- | ||
transforms: | ||
- type: test4 |
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