MCPcopy
hub / github.com/runfinch/finch / TestInstallOptionalDeps

Function TestInstallOptionalDeps

pkg/dependency/dependency_test.go:110–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

108}
109
110func TestInstallOptionalDeps(t *testing.T) {
111 t.Parallel()
112
113 testCases := []struct {
114 name string
115 groups func(*gomock.Controller) []*Group
116 mockSvc func(*mocks.Logger)
117 want error
118 }{
119 {
120 name: "at least one dependency is not installed yet",
121 groups: func(ctrl *gomock.Controller) []*Group {
122 dep1_1 := mocks.NewDependency(ctrl)
123 dep1_2 := mocks.NewDependency(ctrl)
124 dep2_1 := mocks.NewDependency(ctrl)
125
126 group1 := NewGroup([]Dependency{dep1_1, dep1_2}, "dep group 1 description", "dep group 1 error message")
127 group2 := NewGroup([]Dependency{dep2_1}, "dep group 2 description", "dep group 2 error message")
128 groups := []*Group{group1, group2}
129
130 dep1_1.EXPECT().Installed().Return(false)
131 dep1_1.EXPECT().RequiresRoot().Return(true)
132 dep1_1.EXPECT().Install().Return(nil)
133
134 dep1_2.EXPECT().Installed().Return(true)
135 dep2_1.EXPECT().Installed().Return(true)
136
137 return groups
138 },
139 mockSvc: func(l *mocks.Logger) {
140 l.EXPECT().Infoln("dep group 1 description")
141 },
142 want: nil,
143 },
144 {
145 name: "all dependencies are installed",
146 groups: func(ctrl *gomock.Controller) []*Group {
147 dep1_1 := mocks.NewDependency(ctrl)
148 dep2_1 := mocks.NewDependency(ctrl)
149
150 group1 := NewGroup([]Dependency{dep1_1}, "", "")
151 group2 := NewGroup([]Dependency{dep2_1}, "", "")
152 groups := []*Group{group1, group2}
153
154 dep1_1.EXPECT().Installed().Return(true)
155 dep2_1.EXPECT().Installed().Return(true)
156
157 return groups
158 },
159 mockSvc: func(_ *mocks.Logger) {
160 },
161 want: nil,
162 },
163 {
164 name: "dependency installation throws an error",
165 groups: func(ctrl *gomock.Controller) []*Group {
166 dep1_1 := mocks.NewDependency(ctrl)
167 dep1_2 := mocks.NewDependency(ctrl)

Callers

nothing calls this directly

Calls 12

EXPECTMethod · 0.95
EXPECTMethod · 0.95
NewDependencyFunction · 0.92
NewLoggerFunction · 0.92
NewGroupFunction · 0.85
InstallOptionalDepsFunction · 0.85
InstalledMethod · 0.65
RequiresRootMethod · 0.65
InstallMethod · 0.65
InfolnMethod · 0.65
ErrorfMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected