Skip to content

Commit

Permalink
chore: add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Dec 11, 2024
1 parent 1d7f9f1 commit 4da9947
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions internal/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,15 @@ func mergeActions(src, dest map[string]interface{}) error {
}

func mergeActionsSlice(src, dest []interface{}) []interface{} {
mergable := make(map[string]map[string]interface{})
mergeable := make(map[string]map[string]interface{})
result := make([]interface{}, 0, len(dest))

for _, maybeAction := range dest {
switch destAction := maybeAction.(type) {
case map[string]interface{}:
switch name := destAction["name"].(type) {
case string:
mergable[name] = destAction
mergeable[name] = destAction
default:
}

Expand All @@ -498,7 +498,7 @@ func mergeActionsSlice(src, dest []interface{}) []interface{} {
case map[string]interface{}:
switch name := srcAction["name"].(type) {
case string:
destAction, ok := mergable[name]
destAction, ok := mergeable[name]
if ok {
var srcSubActions []interface{}
var destSubActions []interface{}
Expand Down
24 changes: 12 additions & 12 deletions internal/config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,9 @@ pre-commit:
Hooks: map[string]*Hook{
"pre-commit": {
Actions: []*Action{
&Action{Run: "1"},
&Action{Run: "local 2", Name: "second"},
&Action{Run: "3"},
{Run: "1"},
{Run: "local 2", Name: "second"},
{Run: "3"},
},
},
},
Expand Down Expand Up @@ -781,26 +781,26 @@ pre-commit:
Hooks: map[string]*Hook{
"pre-commit": {
Actions: []*Action{
&Action{
{
Name: "group 1",
Glob: "*.rb",
Group: &Group{
Parallel: true,
Actions: []*Action{
&Action{Run: "1.1"},
&Action{Run: "1.2"},
&Action{
{Run: "1.1"},
{Run: "1.2"},
{
Name: "nested",
Group: &Group{
Actions: []*Action{
&Action{Run: "1.nested.1"},
&Action{Run: "1.nested.2 local", Name: "nested 2"},
&Action{Run: "1.nested.3"},
{Run: "1.nested.1"},
{Run: "1.nested.2 local", Name: "nested 2"},
{Run: "1.nested.3"},
},
},
},
&Action{Run: "1.3"},
&Action{Run: "1.4"},
{Run: "1.3"},
{Run: "1.4"},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ skip_lfs: true
pre-commit:
parallel: true
actions:
- name: check code
- name: lint & test
glob: "*.go"
group:
actions:
Expand Down

0 comments on commit 4da9947

Please sign in to comment.