yay/preparer_test.go
Jo fdcf6ef664
ci(yay): add integration test framework (#2178)
* add integration test framework

* fix integration tests

* fix integration tests
2023-05-22 21:38:02 +00:00

66 lines
1.2 KiB
Go

//go:build !integration
// +build !integration
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)
})
}
}