123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786 |
- //go:build !integration
- // +build !integration
- package upgrade
- import (
- "context"
- "io"
- "os"
- "strings"
- "testing"
- "github.com/Jguer/aur"
- "github.com/Jguer/go-alpm/v2"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- "github.com/Jguer/yay/v12/pkg/db"
- "github.com/Jguer/yay/v12/pkg/db/mock"
- "github.com/Jguer/yay/v12/pkg/dep"
- "github.com/Jguer/yay/v12/pkg/query"
- "github.com/Jguer/yay/v12/pkg/settings"
- "github.com/Jguer/yay/v12/pkg/settings/parser"
- "github.com/Jguer/yay/v12/pkg/text"
- "github.com/Jguer/yay/v12/pkg/topo"
- "github.com/Jguer/yay/v12/pkg/vcs"
- mockaur "github.com/Jguer/yay/v12/pkg/dep/mock"
- )
- func ptrString(s string) *string {
- return &s
- }
- func TestUpgradeService_GraphUpgrades(t *testing.T) {
- t.Parallel()
- linuxDepInfo := &dep.InstallInfo{
- Reason: dep.Explicit,
- Source: dep.Sync,
- AURBase: nil,
- LocalVersion: "4.5.0-1",
- Version: "5.0.0-1",
- SyncDBName: ptrString("core"),
- Upgrade: true,
- Devel: false,
- }
- exampleDepInfoDevel := &dep.InstallInfo{
- Source: dep.AUR,
- Reason: dep.Dep,
- AURBase: ptrString("example"),
- LocalVersion: "2.2.1.r32.41baa362-1",
- Version: "latest-commit",
- Upgrade: true,
- Devel: true,
- }
- newDepInfo := &dep.InstallInfo{
- Source: dep.Sync,
- Reason: dep.Dep,
- SyncDBName: ptrString("core"),
- Version: "3.0.1-2",
- LocalVersion: "",
- Upgrade: true,
- Devel: false,
- }
- exampleDepInfoAUR := &dep.InstallInfo{
- Source: dep.AUR,
- Reason: dep.Dep,
- AURBase: ptrString("example"),
- LocalVersion: "2.2.1.r32.41baa362-1",
- Version: "2.2.1.r69.g8a10460-1",
- Upgrade: true,
- Devel: false,
- }
- yayDepInfo := &dep.InstallInfo{
- Reason: dep.Explicit,
- Source: dep.AUR,
- AURBase: ptrString("yay"),
- LocalVersion: "10.2.3",
- Version: "10.2.4",
- Upgrade: true,
- Devel: false,
- }
- coreDB := mock.NewDB("core")
- dbExe := &mock.DBExecutor{
- InstalledRemotePackageNamesFn: func() []string {
- return []string{"yay", "example-git"}
- },
- InstalledRemotePackagesFn: func() map[string]mock.IPackage {
- mapRemote := make(map[string]mock.IPackage)
- mapRemote["yay"] = &mock.Package{
- PName: "yay",
- PBase: "yay",
- PVersion: "10.2.3",
- PReason: alpm.PkgReasonExplicit,
- }
- mapRemote["example-git"] = &mock.Package{
- PName: "example-git",
- PBase: "example",
- PVersion: "2.2.1.r32.41baa362-1",
- PReason: alpm.PkgReasonDepend,
- }
- return mapRemote
- },
- LocalSatisfierExistsFn: func(string) bool { return false },
- SyncSatisfierFn: func(s string) mock.IPackage {
- return &mock.Package{
- PName: "new-dep",
- PVersion: "3.0.1-2",
- PDB: coreDB,
- }
- },
- SyncUpgradesFn: func(bool) (map[string]db.SyncUpgrade, error) {
- mapUpgrades := make(map[string]db.SyncUpgrade)
- mapUpgrades["linux"] = db.SyncUpgrade{
- Package: &mock.Package{
- PName: "linux",
- PVersion: "5.0.0-1",
- PReason: alpm.PkgReasonDepend,
- PDB: coreDB,
- PDepends: mock.DependList{Depends: []alpm.Depend{
- {Name: "new-dep", Version: "3.0.1"},
- }},
- },
- LocalVersion: "4.5.0-1",
- Reason: alpm.PkgReasonExplicit,
- }
- mapUpgrades["new-dep"] = db.SyncUpgrade{
- Package: &mock.Package{
- PName: "new-dep",
- PVersion: "3.0.1-2",
- PReason: alpm.PkgReasonDepend,
- PDB: coreDB,
- },
- LocalVersion: "",
- Reason: alpm.PkgReasonDepend,
- }
- return mapUpgrades, nil
- },
- ReposFn: func() []string { return []string{"core"} },
- }
- vcsStore := &vcs.Mock{
- ToUpgradeReturn: []string{"example-git"},
- }
- mockAUR := &mockaur.MockAUR{
- GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
- return []aur.Pkg{
- {Name: "yay", Version: "10.2.4", PackageBase: "yay"},
- {
- Name: "example-git", Version: "2.2.1.r69.g8a10460-1",
- PackageBase: "example", Depends: []string{"new-dep"},
- },
- }, nil
- },
- }
- type fields struct {
- input io.Reader
- output io.Writer
- noConfirm bool
- devel bool
- }
- type args struct {
- graph *topo.Graph[string, *dep.InstallInfo]
- enableDowngrade bool
- }
- tests := []struct {
- name string
- fields fields
- args args
- mustExist map[string]*dep.InstallInfo
- mustNotExist map[string]bool
- wantExclude []string
- wantErr bool
- }{
- {
- name: "no input",
- fields: fields{
- input: strings.NewReader("\n"),
- output: io.Discard,
- noConfirm: false,
- },
- args: args{
- graph: nil,
- enableDowngrade: false,
- },
- mustExist: map[string]*dep.InstallInfo{
- "yay": yayDepInfo,
- "linux": linuxDepInfo,
- "example-git": exampleDepInfoAUR,
- "new-dep": newDepInfo,
- },
- mustNotExist: map[string]bool{},
- wantErr: false,
- wantExclude: []string{},
- },
- {
- name: "no input devel",
- fields: fields{
- input: strings.NewReader("\n"),
- output: io.Discard,
- noConfirm: false,
- devel: true,
- },
- args: args{
- graph: nil,
- enableDowngrade: false,
- },
- mustExist: map[string]*dep.InstallInfo{
- "yay": yayDepInfo,
- "linux": linuxDepInfo,
- "example-git": exampleDepInfoDevel,
- },
- mustNotExist: map[string]bool{},
- wantErr: false,
- wantExclude: []string{},
- },
- {
- name: "exclude example-git",
- fields: fields{
- input: strings.NewReader("2\n"),
- output: io.Discard,
- noConfirm: false,
- },
- args: args{
- graph: nil,
- enableDowngrade: false,
- },
- mustExist: map[string]*dep.InstallInfo{
- "yay": yayDepInfo,
- "linux": linuxDepInfo,
- },
- mustNotExist: map[string]bool{"example-git": true, "new-dep": true},
- wantErr: false,
- wantExclude: []string{"example-git", "new-dep"},
- },
- {
- name: "exclude new-dep should have no effect",
- fields: fields{
- input: strings.NewReader("1 3 4\n"),
- output: io.Discard,
- noConfirm: false,
- },
- args: args{
- graph: nil,
- enableDowngrade: false,
- },
- mustExist: map[string]*dep.InstallInfo{
- "example-git": exampleDepInfoAUR,
- "new-dep": newDepInfo,
- },
- mustNotExist: map[string]bool{"linux": true, "yay": true},
- wantErr: false,
- wantExclude: []string{"linux", "yay"},
- },
- {
- name: "exclude yay",
- fields: fields{
- input: strings.NewReader("1\n"),
- output: io.Discard,
- noConfirm: false,
- },
- args: args{
- graph: nil,
- enableDowngrade: false,
- },
- mustExist: map[string]*dep.InstallInfo{
- "linux": linuxDepInfo,
- "example-git": exampleDepInfoAUR,
- },
- mustNotExist: map[string]bool{"yay": true},
- wantErr: false,
- wantExclude: []string{"yay"},
- },
- {
- name: "exclude linux",
- fields: fields{
- input: strings.NewReader("3\n"),
- output: io.Discard,
- noConfirm: false,
- },
- args: args{
- graph: nil,
- enableDowngrade: false,
- },
- mustExist: map[string]*dep.InstallInfo{
- "yay": yayDepInfo,
- "example-git": exampleDepInfoAUR,
- "new-dep": newDepInfo,
- },
- mustNotExist: map[string]bool{"linux": true},
- wantErr: false,
- wantExclude: []string{"linux"},
- },
- {
- name: "only linux",
- fields: fields{
- input: strings.NewReader("^3\n"),
- output: io.Discard,
- noConfirm: false,
- },
- args: args{
- graph: nil,
- enableDowngrade: false,
- },
- mustExist: map[string]*dep.InstallInfo{
- "linux": linuxDepInfo,
- },
- mustNotExist: map[string]bool{"yay": true, "example-git": true},
- wantErr: false,
- wantExclude: []string{"yay", "example-git", "new-dep"},
- },
- {
- name: "exclude all",
- fields: fields{
- input: strings.NewReader("1-4\n"),
- output: io.Discard,
- noConfirm: false,
- },
- args: args{
- graph: nil,
- enableDowngrade: false,
- },
- mustExist: map[string]*dep.InstallInfo{},
- mustNotExist: map[string]bool{"yay": true, "example-git": true, "linux": true},
- wantErr: false,
- wantExclude: []string{"yay", "example-git", "linux", "new-dep"},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- grapher := dep.NewGrapher(dbExe, mockAUR,
- false, true, false, false, false, text.NewLogger(tt.fields.output, os.Stderr,
- tt.fields.input, true, "test"))
- cfg := &settings.Configuration{
- Devel: tt.fields.devel, Mode: parser.ModeAny,
- }
- logger := text.NewLogger(tt.fields.output, os.Stderr,
- tt.fields.input, true, "test")
- u := &UpgradeService{
- log: logger,
- grapher: grapher,
- aurCache: mockAUR,
- dbExecutor: dbExe,
- vcsStore: vcsStore,
- cfg: cfg,
- noConfirm: tt.fields.noConfirm,
- AURWarnings: query.NewWarnings(logger),
- }
- got, err := u.GraphUpgrades(context.Background(), tt.args.graph, tt.args.enableDowngrade, func(*Upgrade) bool { return true })
- if (err != nil) != tt.wantErr {
- t.Errorf("UpgradeService.GraphUpgrades() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- excluded, err := u.UserExcludeUpgrades(got)
- require.NoError(t, err)
- for node, info := range tt.mustExist {
- assert.True(t, got.Exists(node), node)
- assert.Equal(t, info, got.GetNodeInfo(node).Value)
- }
- for node := range tt.mustNotExist {
- assert.False(t, got.Exists(node), node)
- }
- assert.ElementsMatch(t, tt.wantExclude, excluded)
- })
- }
- }
- func TestUpgradeService_GraphUpgradesNoUpdates(t *testing.T) {
- t.Parallel()
- dbExe := &mock.DBExecutor{
- InstalledRemotePackageNamesFn: func() []string {
- return []string{"yay", "example-git"}
- },
- InstalledRemotePackagesFn: func() map[string]mock.IPackage {
- mapRemote := make(map[string]mock.IPackage)
- mapRemote["yay"] = &mock.Package{
- PName: "yay",
- PBase: "yay",
- PVersion: "10.2.3",
- PReason: alpm.PkgReasonExplicit,
- }
- mapRemote["example-git"] = &mock.Package{
- PName: "example-git",
- PBase: "example",
- PVersion: "2.2.1.r32.41baa362-1",
- PReason: alpm.PkgReasonDepend,
- }
- return mapRemote
- },
- SyncUpgradesFn: func(bool) (map[string]db.SyncUpgrade, error) {
- mapUpgrades := make(map[string]db.SyncUpgrade)
- return mapUpgrades, nil
- },
- ReposFn: func() []string { return []string{"core"} },
- }
- vcsStore := &vcs.Mock{
- ToUpgradeReturn: []string{},
- }
- mockAUR := &mockaur.MockAUR{
- GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
- return []aur.Pkg{}, nil
- },
- }
- type fields struct {
- input io.Reader
- output io.Writer
- noConfirm bool
- devel bool
- }
- type args struct {
- graph *topo.Graph[string, *dep.InstallInfo]
- enableDowngrade bool
- }
- tests := []struct {
- name string
- fields fields
- args args
- mustExist map[string]*dep.InstallInfo
- mustNotExist map[string]bool
- wantExclude []string
- wantErr bool
- }{
- {
- name: "no input",
- fields: fields{
- input: strings.NewReader(""),
- output: io.Discard,
- noConfirm: false,
- },
- args: args{
- graph: nil,
- enableDowngrade: false,
- },
- mustExist: map[string]*dep.InstallInfo{},
- mustNotExist: map[string]bool{},
- wantErr: false,
- wantExclude: []string{},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- grapher := dep.NewGrapher(dbExe, mockAUR,
- false, true, false, false, false, text.NewLogger(tt.fields.output, os.Stderr,
- tt.fields.input, true, "test"))
- cfg := &settings.Configuration{
- Devel: tt.fields.devel,
- Mode: parser.ModeAny,
- }
- logger := text.NewLogger(tt.fields.output, os.Stderr,
- tt.fields.input, true, "test")
- u := &UpgradeService{
- log: logger,
- grapher: grapher,
- aurCache: mockAUR,
- dbExecutor: dbExe,
- vcsStore: vcsStore,
- cfg: cfg,
- noConfirm: tt.fields.noConfirm,
- AURWarnings: query.NewWarnings(logger),
- }
- got, err := u.GraphUpgrades(context.Background(), tt.args.graph, tt.args.enableDowngrade, func(*Upgrade) bool { return true })
- if (err != nil) != tt.wantErr {
- t.Errorf("UpgradeService.GraphUpgrades() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- excluded, err := u.UserExcludeUpgrades(got)
- require.NoError(t, err)
- for node, info := range tt.mustExist {
- assert.True(t, got.Exists(node), node)
- assert.Equal(t, info, got.GetNodeInfo(node).Value)
- }
- for node := range tt.mustNotExist {
- assert.False(t, got.Exists(node), node)
- }
- assert.ElementsMatch(t, tt.wantExclude, excluded)
- })
- }
- }
- func TestUpgradeService_Warnings(t *testing.T) {
- t.Parallel()
- dbExe := &mock.DBExecutor{
- InstalledRemotePackageNamesFn: func() []string {
- return []string{"orphan", "outdated", "missing", "orphan-ignored"}
- },
- InstalledRemotePackagesFn: func() map[string]mock.IPackage {
- mapRemote := make(map[string]mock.IPackage)
- mapRemote["orphan"] = &mock.Package{
- PName: "orphan",
- PBase: "orphan",
- PVersion: "10.2.3",
- PReason: alpm.PkgReasonExplicit,
- }
- mapRemote["outdated"] = &mock.Package{
- PName: "outdated",
- PBase: "outdated",
- PVersion: "10.2.3",
- PReason: alpm.PkgReasonExplicit,
- }
- mapRemote["missing"] = &mock.Package{
- PName: "missing",
- PBase: "missing",
- PVersion: "10.2.3",
- PReason: alpm.PkgReasonExplicit,
- }
- mapRemote["orphan-ignored"] = &mock.Package{
- PName: "orphan-ignored",
- PBase: "orphan-ignored",
- PVersion: "10.2.3",
- PReason: alpm.PkgReasonExplicit,
- PShouldIgnore: true,
- }
- return mapRemote
- },
- LocalSatisfierExistsFn: func(string) bool { return false },
- SyncSatisfierFn: func(s string) mock.IPackage {
- return nil
- },
- SyncUpgradesFn: func(bool) (map[string]db.SyncUpgrade, error) {
- mapUpgrades := make(map[string]db.SyncUpgrade)
- return mapUpgrades, nil
- },
- ReposFn: func() []string { return []string{"core"} },
- }
- vcsStore := &vcs.Mock{
- ToUpgradeReturn: []string{},
- }
- mockAUR := &mockaur.MockAUR{
- GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
- return []aur.Pkg{
- {
- Name: "outdated", Version: "10.2.4", PackageBase: "orphan",
- OutOfDate: 100, Maintainer: "bob",
- },
- {
- Name: "orphan", Version: "10.2.4", PackageBase: "orphan",
- Maintainer: "",
- },
- }, nil
- },
- }
- logger := text.NewLogger(io.Discard, os.Stderr,
- strings.NewReader("\n"), true, "test")
- grapher := dep.NewGrapher(dbExe, mockAUR,
- false, true, false, false, false, logger)
- cfg := &settings.Configuration{
- Devel: false, Mode: parser.ModeAUR,
- }
- u := &UpgradeService{
- log: logger,
- grapher: grapher,
- aurCache: mockAUR,
- dbExecutor: dbExe,
- vcsStore: vcsStore,
- cfg: cfg,
- noConfirm: true,
- AURWarnings: query.NewWarnings(logger),
- }
- _, err := u.GraphUpgrades(context.Background(), nil, false, func(*Upgrade) bool { return true })
- require.NoError(t, err)
- assert.Equal(t, []string{"missing"}, u.AURWarnings.Missing)
- assert.Equal(t, []string{"outdated"}, u.AURWarnings.OutOfDate)
- assert.Equal(t, []string{"orphan"}, u.AURWarnings.Orphans)
- }
- func TestUpgradeService_GraphUpgrades_zfs_dkms(t *testing.T) {
- t.Parallel()
- zfsDKMSInfo := &dep.InstallInfo{
- Reason: dep.Explicit,
- Source: dep.AUR,
- AURBase: ptrString("zfs-dkms"),
- LocalVersion: "2.1.10-1",
- Version: "2.1.11-1",
- Upgrade: true,
- Devel: false,
- }
- zfsUtilsInfo := &dep.InstallInfo{
- Reason: dep.Dep,
- Source: dep.AUR,
- AURBase: ptrString("zfs-utils"),
- LocalVersion: "2.1.10-1",
- Version: "2.1.11-1",
- Upgrade: true,
- Devel: false,
- }
- vcsStore := &vcs.Mock{ToUpgradeReturn: []string{}}
- mockAUR := &mockaur.MockAUR{
- GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
- if len(query.Needles) == 2 {
- return []aur.Pkg{
- {
- Name: "zfs-dkms", Version: "2.1.11-1",
- PackageBase: "zfs-dkms", Depends: []string{"zfs-utils=2.1.11"},
- },
- {Name: "zfs-utils", Version: "2.1.11-1", PackageBase: "zfs-utils"},
- }, nil
- }
- if len(query.Needles) == 1 {
- return []aur.Pkg{
- {Name: "zfs-utils", Version: "2.1.11-1", PackageBase: "zfs-utils"},
- }, nil
- }
- panic("not implemented")
- },
- }
- type fields struct {
- input io.Reader
- noConfirm bool
- devel bool
- }
- type args struct {
- graph *topo.Graph[string, *dep.InstallInfo]
- enableDowngrade bool
- }
- tests := []struct {
- name string
- fields fields
- args args
- mustExist map[string]*dep.InstallInfo
- mustNotExist map[string]bool
- wantExclude []string
- wantErr bool
- remotePackages []string
- }{
- {
- name: "no input",
- fields: fields{
- input: strings.NewReader("\n"),
- noConfirm: false,
- },
- args: args{
- graph: nil,
- enableDowngrade: false,
- },
- mustExist: map[string]*dep.InstallInfo{
- "zfs-dkms": zfsDKMSInfo,
- "zfs-utils": zfsUtilsInfo,
- },
- remotePackages: []string{"zfs-utils", "zfs-dkms"},
- mustNotExist: map[string]bool{},
- wantErr: false,
- wantExclude: []string{},
- },
- {
- name: "no input - inverted order",
- fields: fields{
- input: strings.NewReader("\n"),
- noConfirm: false,
- },
- args: args{
- graph: nil,
- enableDowngrade: false,
- },
- mustExist: map[string]*dep.InstallInfo{
- "zfs-dkms": zfsDKMSInfo,
- "zfs-utils": zfsUtilsInfo,
- },
- remotePackages: []string{"zfs-dkms", "zfs-utils"},
- mustNotExist: map[string]bool{},
- wantErr: false,
- wantExclude: []string{},
- },
- }
- for _, tt := range tests {
- tt := tt
- t.Run(tt.name, func(t *testing.T) {
- t.Parallel()
- dbExe := &mock.DBExecutor{
- InstalledRemotePackageNamesFn: func() []string {
- return tt.remotePackages
- },
- InstalledRemotePackagesFn: func() map[string]mock.IPackage {
- mapRemote := make(map[string]mock.IPackage)
- mapRemote["zfs-dkms"] = &mock.Package{
- PName: "zfs-dkms",
- PBase: "zfs-dkms",
- PVersion: "2.1.10-1",
- PReason: alpm.PkgReasonExplicit,
- PDepends: mock.DependList{Depends: []alpm.Depend{
- {Name: "zfs-utils", Version: "2.1.10-1"},
- }},
- }
- mapRemote["zfs-utils"] = &mock.Package{
- PName: "zfs-utils",
- PBase: "zfs-utils",
- PVersion: "2.1.10-1",
- PReason: alpm.PkgReasonDepend,
- }
- return mapRemote
- },
- LocalSatisfierExistsFn: func(string) bool { return false },
- SyncSatisfierFn: func(s string) mock.IPackage {
- return nil
- },
- SyncUpgradesFn: func(bool) (map[string]db.SyncUpgrade, error) {
- mapUpgrades := make(map[string]db.SyncUpgrade)
- return mapUpgrades, nil
- },
- ReposFn: func() []string { return []string{"core"} },
- }
- logger := text.NewLogger(io.Discard, os.Stderr,
- tt.fields.input, true, "test")
- grapher := dep.NewGrapher(dbExe, mockAUR,
- false, true, false, false, false, logger)
- cfg := &settings.Configuration{
- Devel: tt.fields.devel, Mode: parser.ModeAny,
- }
- u := &UpgradeService{
- log: logger,
- grapher: grapher,
- aurCache: mockAUR,
- dbExecutor: dbExe,
- vcsStore: vcsStore,
- cfg: cfg,
- noConfirm: tt.fields.noConfirm,
- AURWarnings: query.NewWarnings(logger),
- }
- got, err := u.GraphUpgrades(context.Background(), tt.args.graph, tt.args.enableDowngrade, func(*Upgrade) bool { return true })
- if (err != nil) != tt.wantErr {
- t.Errorf("UpgradeService.GraphUpgrades() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- excluded, err := u.UserExcludeUpgrades(got)
- require.NoError(t, err)
- for node, info := range tt.mustExist {
- assert.True(t, got.Exists(node), node)
- assert.Equal(t, info, got.GetNodeInfo(node).Value)
- }
- for node := range tt.mustNotExist {
- assert.False(t, got.Exists(node), node)
- }
- assert.ElementsMatch(t, tt.wantExclude, excluded)
- })
- }
- }
|