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

Function TestGroup_instalOptional

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

Source from the content-addressed store, hash-verified

15)
16
17func TestGroup_instalOptional(t *testing.T) {
18 t.Parallel()
19
20 testCases := []struct {
21 name string
22 group func(*gomock.Controller) *Group
23 mockSvc func(*mocks.Logger)
24 want error
25 }{
26 {
27 name: "at least one dependency is not installed",
28 group: func(ctrl *gomock.Controller) *Group {
29 dep1 := mocks.NewDependency(ctrl)
30 dep2 := mocks.NewDependency(ctrl)
31 dep3 := mocks.NewDependency(ctrl)
32
33 group := NewGroup([]Dependency{dep1, dep2, dep3}, "description", "")
34
35 dep1.EXPECT().Installed().Return(true)
36 dep2.EXPECT().Installed().Return(true)
37 dep3.EXPECT().Installed().Return(false)
38
39 dep3.EXPECT().Install().Return(nil)
40 dep3.EXPECT().RequiresRoot().Return(true)
41
42 return group
43 },
44 mockSvc: func(l *mocks.Logger) {
45 l.EXPECT().Infoln("description")
46 },
47 want: nil,
48 },
49 {
50 name: "all of the dependencies are already installed",
51 group: func(ctrl *gomock.Controller) *Group {
52 dep1 := mocks.NewDependency(ctrl)
53 dep2 := mocks.NewDependency(ctrl)
54 dep3 := mocks.NewDependency(ctrl)
55
56 group := NewGroup([]Dependency{dep1, dep2, dep3}, "description", "")
57
58 dep1.EXPECT().Installed().Return(true)
59 dep2.EXPECT().Installed().Return(true)
60 dep3.EXPECT().Installed().Return(true)
61
62 return group
63 },
64 mockSvc: func(_ *mocks.Logger) {
65 },
66 want: nil,
67 },
68 {
69 name: "dependency installation throws an error",
70 group: func(ctrl *gomock.Controller) *Group {
71 dep1 := mocks.NewDependency(ctrl)
72 dep2 := mocks.NewDependency(ctrl)
73 dep3 := mocks.NewDependency(ctrl)
74

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected