v3.0.0 f19f453

mocks_test.go RawHistoryFolder

1package apps_test
2
3import (
4	"context"
5	"testing"
6
7	"github.com/stretchr/testify/mock"
8
9	"github.com/bnema/gordon/internal/boundaries/out"
10	outmocks "github.com/bnema/gordon/internal/boundaries/out/mocks"
11	"github.com/bnema/gordon/internal/usecase/deployment"
12)
13
14// mockDeployEngine is a mockery-style test double for the unexported
15// apps.deployEngine interface. mockery cannot generate it (unexported),
16// so this hand-written mock follows the same EXPECT()/Return() pattern.
17type mockDeployEngine struct {
18	mock.Mock
19
20	// startDeployFn, abandonDeployFn and executeDeployFn override the testify
21	// expectations when set, for tests that script per-call results or block
22	// execution.
23	startDeployFn   func(ctx context.Context, input deployment.DeployInput) (*deployment.StartDeployResult, error)
24	abandonDeployFn func(ctx context.Context, claim deployment.DeployClaim) error
25	executeDeployFn func(ctx context.Context, claim deployment.DeployClaim) (*deployment.DeployResult, error)
26}
27
28func newMockDeployEngine(t *testing.T) *mockDeployEngine {
29	m := &mockDeployEngine{}
30	m.Test(t)
31	t.Cleanup(func() { m.AssertExpectations(t) })
32	return m
33}
34
35func (m *mockDeployEngine) StartDeploy(ctx context.Context, input deployment.DeployInput) (*deployment.StartDeployResult, error) {
36	if m.startDeployFn != nil {
37		return m.startDeployFn(ctx, input)
38	}
39	args := m.Called(ctx, input)
40	if args.Get(0) == nil {
41		return nil, args.Error(1)
42	}
43	return args.Get(0).(*deployment.StartDeployResult), args.Error(1)
44}
45
46func (m *mockDeployEngine) AbandonDeploy(ctx context.Context, claim deployment.DeployClaim) error {
47	if m.abandonDeployFn != nil {
48		return m.abandonDeployFn(ctx, claim)
49	}
50	args := m.Called(ctx, claim)
51	return args.Error(0)
52}
53
54func (m *mockDeployEngine) ExecuteDeploy(ctx context.Context, claim deployment.DeployClaim) (*deployment.DeployResult, error) {
55	if m.executeDeployFn != nil {
56		return m.executeDeployFn(ctx, claim)
57	}
58	args := m.Called(ctx, claim)
59	if args.Get(0) == nil {
60		return nil, args.Error(1)
61	}
62	return args.Get(0).(*deployment.DeployResult), args.Error(1)
63}
64
65func (m *mockDeployEngine) Stop(ctx context.Context, app, opID string) (*deployment.LifecycleResult, error) {
66	args := m.Called(ctx, app, opID)
67	if args.Get(0) == nil {
68		return nil, args.Error(1)
69	}
70	return args.Get(0).(*deployment.LifecycleResult), args.Error(1)
71}
72
73func (m *mockDeployEngine) Start(ctx context.Context, app, opID string) (*deployment.LifecycleResult, error) {
74	args := m.Called(ctx, app, opID)
75	if args.Get(0) == nil {
76		return nil, args.Error(1)
77	}
78	return args.Get(0).(*deployment.LifecycleResult), args.Error(1)
79}
80
81func (m *mockDeployEngine) Restart(ctx context.Context, app, service, opID string) (*deployment.LifecycleResult, error) {
82	args := m.Called(ctx, app, service, opID)
83	if args.Get(0) == nil {
84		return nil, args.Error(1)
85	}
86	return args.Get(0).(*deployment.LifecycleResult), args.Error(1)
87}
88
89func (m *mockDeployEngine) Remove(ctx context.Context, app, opID string) (*deployment.LifecycleResult, error) {
90	args := m.Called(ctx, app, opID)
91	if args.Get(0) == nil {
92		return nil, args.Error(1)
93	}
94	return args.Get(0).(*deployment.LifecycleResult), args.Error(1)
95}
96
97func newMockAppState(t *testing.T) *outmocks.MockAppState {
98	return outmocks.NewMockAppState(t)
99}
100
101func newMockSecretWriter(t *testing.T) *outmocks.MockSecretWriter {
102	return outmocks.NewMockSecretWriter(t)
103}
104
105var _ out.AppState = (*outmocks.MockAppState)(nil)
106var _ out.SecretWriter = (*outmocks.MockSecretWriter)(nil)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close