From 4da99479e220b55ff827ad529137499e8b03b910 Mon Sep 17 00:00:00 2001 From: Valentin Kiselev Date: Wed, 11 Dec 2024 18:36:36 +0300 Subject: [PATCH] chore: add unit tests --- internal/config/load.go | 6 +++--- internal/config/load_test.go | 24 ++++++++++++------------ lefthook.yml | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/config/load.go b/internal/config/load.go index 251ea411..24c9d225 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -476,7 +476,7 @@ 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 { @@ -484,7 +484,7 @@ func mergeActionsSlice(src, dest []interface{}) []interface{} { case map[string]interface{}: switch name := destAction["name"].(type) { case string: - mergable[name] = destAction + mergeable[name] = destAction default: } @@ -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{} diff --git a/internal/config/load_test.go b/internal/config/load_test.go index 53a6a250..672bdb81 100644 --- a/internal/config/load_test.go +++ b/internal/config/load_test.go @@ -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"}, }, }, }, @@ -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"}, }, }, }, diff --git a/lefthook.yml b/lefthook.yml index 34fa4f5c..d1e390ad 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -3,7 +3,7 @@ skip_lfs: true pre-commit: parallel: true actions: - - name: check code + - name: lint & test glob: "*.go" group: actions: