-
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.
Merge pull request #28 from uselagoon/chore/refactorstructure
Makes default parser transformers use yaml
- Loading branch information
Showing
14 changed files
with
158 additions
and
121 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,2 +1,3 @@ | ||
.idea | ||
.env | ||
.env | ||
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
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) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.