mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 17:17:22 +01:00
89f47f8ebe
* fix(yay): reset to origin/HEAD for clean_menu * fix(yay): correct operation order for preparer * test(yay): fix flaky test
63 lines
1.2 KiB
Go
63 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/Jguer/yay/v12/pkg/settings"
|
|
)
|
|
|
|
// Test order of pre-download-sources hooks
|
|
func TestPreDownloadSourcesHooks(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
cfg *settings.Configuration
|
|
wantHook []string
|
|
}{
|
|
{
|
|
name: "clean, diff, edit",
|
|
cfg: &settings.Configuration{
|
|
CleanMenu: true,
|
|
DiffMenu: true,
|
|
EditMenu: true,
|
|
},
|
|
wantHook: []string{"clean", "diff", "edit"},
|
|
},
|
|
{
|
|
name: "clean, edit",
|
|
cfg: &settings.Configuration{
|
|
CleanMenu: true,
|
|
DiffMenu: false,
|
|
EditMenu: true,
|
|
},
|
|
wantHook: []string{"clean", "edit"},
|
|
},
|
|
{
|
|
name: "clean, diff",
|
|
cfg: &settings.Configuration{
|
|
CleanMenu: true,
|
|
DiffMenu: true,
|
|
EditMenu: false,
|
|
},
|
|
wantHook: []string{"clean", "diff"},
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
preper := NewPreparer(nil, nil, tc.cfg)
|
|
|
|
assert.Len(t, preper.hooks, len(tc.wantHook))
|
|
|
|
got := make([]string, 0, len(preper.hooks))
|
|
|
|
for _, hook := range preper.hooks {
|
|
got = append(got, hook.Name)
|
|
}
|
|
|
|
assert.Equal(t, tc.wantHook, got)
|
|
})
|
|
}
|
|
}
|