From d842e35503ee08a5e21c2a0e09a2dc40ad206d1a Mon Sep 17 00:00:00 2001 From: Joseph Phillips Date: Mon, 9 Sep 2024 14:17:33 +0200 Subject: [PATCH 1/2] fix: use map[int]string for relation state Unit relation state is actually keyed on the relation ID, and not string as it is for charm state. This fixes it, though an elegant solution without boxing awaits a fix in SQLair to support generic query arguments. --- domain/unitstate/state/state.go | 2 +- domain/unitstate/state/state_test.go | 13 +++++++------ domain/unitstate/state/types.go | 9 ++++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/domain/unitstate/state/state.go b/domain/unitstate/state/state.go index 486acf69f61..4739c842567 100644 --- a/domain/unitstate/state/state.go +++ b/domain/unitstate/state/state.go @@ -171,7 +171,7 @@ func (st *State) SetUnitStateCharm(ctx domain.AtomicContext, uuid string, state // SetUnitStateRelation sets the input key/value pairs // as the relation state for the input unit UUID. -func (st *State) SetUnitStateRelation(ctx domain.AtomicContext, uuid string, state map[string]string) error { +func (st *State) SetUnitStateRelation(ctx domain.AtomicContext, uuid string, state map[int]string) error { id := unitUUID{UUID: uuid} q := "DELETE from unit_state_relation WHERE unit_uuid = $unitUUID.uuid" diff --git a/domain/unitstate/state/state_test.go b/domain/unitstate/state/state_test.go index 8002fc7cb4c..7af2b85f18c 100644 --- a/domain/unitstate/state/state_test.go +++ b/domain/unitstate/state/state_test.go @@ -211,15 +211,15 @@ func (s *stateSuite) TestUpdateUnitStateRelation(c *gc.C) { // Set some initial state. This should be overwritten. err := s.TxnRunner().StdTxn(ctx, func(ctx context.Context, tx *sql.Tx) error { - q := "INSERT INTO unit_state_relation VALUES (?, 'one-key', 'one-val')" + q := "INSERT INTO unit_state_relation VALUES (?, 1, 'one-val')" _, err := tx.ExecContext(ctx, q, s.unitUUID) return err }) c.Assert(err, jc.ErrorIsNil) - expState := map[string]string{ - "two-key": "two-val", - "three-key": "three-val", + expState := map[int]string{ + 2: "two-val", + 3: "three-val", } err = st.RunAtomic(ctx, func(ctx domain.AtomicContext) error { @@ -227,7 +227,7 @@ func (s *stateSuite) TestUpdateUnitStateRelation(c *gc.C) { }) c.Assert(err, jc.ErrorIsNil) - gotState := make(map[string]string) + gotState := make(map[int]string) err = s.TxnRunner().StdTxn(ctx, func(ctx context.Context, tx *sql.Tx) error { q := "SELECT key, value FROM unit_state_relation WHERE unit_uuid = ?" rows, err := tx.QueryContext(ctx, q, s.unitUUID) @@ -237,7 +237,8 @@ func (s *stateSuite) TestUpdateUnitStateRelation(c *gc.C) { defer func() { _ = rows.Close() }() for rows.Next() { - var k, v string + var k int + var v string if err := rows.Scan(&k, &v); err != nil { return err } diff --git a/domain/unitstate/state/types.go b/domain/unitstate/state/types.go index ab5f402e764..a0d653f2649 100644 --- a/domain/unitstate/state/types.go +++ b/domain/unitstate/state/types.go @@ -26,12 +26,15 @@ type unitState struct { // unitStateVal is a type for holding a key/value pair that is // a constituent in unit state for charm and relation. type unitStateKeyVal struct { - UUID string `db:"unit_uuid"` - Key string `db:"key"` + UUID string `db:"unit_uuid"` + // TODO (manadart 2024-09-09): This should be a generic T congruent with + // the function below. However, at the time of writing, SQLair does not + // support generic argumentation. + Key any `db:"key"` Value string `db:"value"` } -func makeUnitStateKeyVals(unitUUID string, kv map[string]string) []unitStateKeyVal { +func makeUnitStateKeyVals[T comparable](unitUUID string, kv map[T]string) []unitStateKeyVal { keyVals := make([]unitStateKeyVal, 0, len(kv)) for k, v := range kv { keyVals = append(keyVals, unitStateKeyVal{ From 2b70c6c0e686fdbe6e765d1d24cfbca1628520c8 Mon Sep 17 00:00:00 2001 From: Joseph Phillips Date: Mon, 9 Sep 2024 14:48:01 +0200 Subject: [PATCH 2/2] feat: service for setting unit state Adds the unitstate service with a method to set agent state. The specific state methods are recruited within an atomic context based on what is set on the incoming struct. --- domain/unitstate/service/package_test.go | 19 ++ domain/unitstate/service/service.go | 104 ++++++ domain/unitstate/service/service_test.go | 90 +++++ domain/unitstate/service/state_mock_test.go | 346 ++++++++++++++++++++ 4 files changed, 559 insertions(+) create mode 100644 domain/unitstate/service/package_test.go create mode 100644 domain/unitstate/service/service.go create mode 100644 domain/unitstate/service/service_test.go create mode 100644 domain/unitstate/service/state_mock_test.go diff --git a/domain/unitstate/service/package_test.go b/domain/unitstate/service/package_test.go new file mode 100644 index 00000000000..9f8a3119e82 --- /dev/null +++ b/domain/unitstate/service/package_test.go @@ -0,0 +1,19 @@ +// Copyright 2024 Canonical Ltd. +// Licensed under the AGPLv3, see LICENCE file for details. + +package service + +import ( + "testing" + + gc "gopkg.in/check.v1" +) + +//go:generate go run go.uber.org/mock/mockgen -typed -package service -destination state_mock_test.go github.com/juju/juju/domain/unitstate/service State +func TestPackage(t *testing.T) { + gc.TestingT(t) +} + +func ptr[T any](v T) *T { + return &v +} diff --git a/domain/unitstate/service/service.go b/domain/unitstate/service/service.go new file mode 100644 index 00000000000..f4e060a2aca --- /dev/null +++ b/domain/unitstate/service/service.go @@ -0,0 +1,104 @@ +// Copyright 2024 Canonical Ltd. +// Licensed under the AGPLv3, see LICENCE file for details. + +package service + +import ( + "context" + + "github.com/juju/juju/domain" + "github.com/juju/juju/domain/unitstate" + "github.com/juju/juju/internal/errors" +) + +// State defines an interface for interacting with the underlying state. +type State interface { + domain.AtomicStateBase + + // GetUnitUUIDForName returns the UUID for + // the unit identified by the input name. + GetUnitUUIDForName(domain.AtomicContext, string) (string, error) + + // EnsureUnitStateRecord ensures that there is a record + // for the agent state for the unit with the input UUID. + EnsureUnitStateRecord(domain.AtomicContext, string) error + + // UpdateUnitStateUniter updates the agent uniter + // state for the unit with the input UUID. + UpdateUnitStateUniter(domain.AtomicContext, string, string) error + + // UpdateUnitStateStorage updates the agent storage + // state for the unit with the input UUID. + UpdateUnitStateStorage(domain.AtomicContext, string, string) error + + // UpdateUnitStateSecret updates the agent secret + // state for the unit with the input UUID. + UpdateUnitStateSecret(domain.AtomicContext, string, string) error + + // UpdateUnitStateCharm updates the agent charm + // state for the unit with the input UUID. + UpdateUnitStateCharm(domain.AtomicContext, string, map[string]string) error + + // UpdateUnitStateRelation updates the agent relation + // state for the unit with the input UUID. + UpdateUnitStateRelation(domain.AtomicContext, string, map[int]string) error +} + +// Service defines a service for interacting with the underlying state. +type Service struct { + st State +} + +// NewService returns a new Service for interacting with the underlying state. +func NewService(st State) *Service { + return &Service{ + st: st, + } +} + +// SetState persists the input agent state selectively, +// based on its populated values. +func (s *Service) SetState(ctx context.Context, as unitstate.AgentState) error { + return s.st.RunAtomic(ctx, func(ctx domain.AtomicContext) error { + uuid, err := s.st.GetUnitUUIDForName(ctx, as.Name) + if err != nil { + return errors.Errorf("getting unit UUID for %s: %w", as.Name, err) + } + + if err = s.st.EnsureUnitStateRecord(ctx, uuid); err != nil { + return errors.Errorf("ensuring state record for %s: %w", as.Name, err) + } + + if as.UniterState != nil { + if err = s.st.UpdateUnitStateUniter(ctx, uuid, *as.UniterState); err != nil { + return errors.Errorf("setting uniter state for %s: %w", as.Name, err) + } + } + + if as.StorageState != nil { + if err = s.st.UpdateUnitStateStorage(ctx, uuid, *as.StorageState); err != nil { + return errors.Errorf("setting storage state for %s: %w", as.Name, err) + } + } + + if as.SecretState != nil { + if err = s.st.UpdateUnitStateSecret(ctx, uuid, *as.SecretState); err != nil { + return errors.Errorf("setting secret state for %s: %w", as.Name, err) + } + } + + if as.CharmState != nil { + if err = s.st.UpdateUnitStateCharm(ctx, uuid, *as.CharmState); err != nil { + return errors.Errorf("setting charm state for %s: %w", as.Name, err) + } + } + + if as.RelationState != nil { + if err = s.st.UpdateUnitStateRelation(ctx, uuid, *as.RelationState); err != nil { + return errors.Errorf("setting relation state for %s: %w", as.Name, err) + } + } + + return nil + }) +} diff --git a/domain/unitstate/service/service_test.go b/domain/unitstate/service/service_test.go new file mode 100644 index 00000000000..a1c6428e291 --- /dev/null +++ b/domain/unitstate/service/service_test.go @@ -0,0 +1,90 @@ +// Copyright 2024 Canonical Ltd. +// Licensed under the AGPLv3, see LICENCE file for details. + +package service + +import ( + "context" + + jc "github.com/juju/testing/checkers" + "go.uber.org/mock/gomock" + gc "gopkg.in/check.v1" + + "github.com/juju/juju/domain" + "github.com/juju/juju/domain/application/errors" + domaintesting "github.com/juju/juju/domain/testing" + "github.com/juju/juju/domain/unitstate" + unitstateerrors "github.com/juju/juju/domain/unitstate/errors" +) + +type serviceSuite struct { + st *MockState +} + +var _ = gc.Suite(&serviceSuite{}) + +func (s *serviceSuite) TestSetStateAllAttributes(c *gc.C) { + defer s.setupMocks(c).Finish() + + uuid := "some-unit-uuid" + + exp := s.st.EXPECT() + exp.GetUnitUUIDForName(gomock.Any(), "unit/0").Return(uuid, nil) + exp.EnsureUnitStateRecord(gomock.Any(), uuid).Return(nil) + exp.UpdateUnitStateUniter(gomock.Any(), uuid, "some-uniter-state-yaml").Return(nil) + exp.UpdateUnitStateStorage(gomock.Any(), uuid, "some-storage-state-yaml").Return(nil) + exp.UpdateUnitStateSecret(gomock.Any(), uuid, "some-secret-state-yaml").Return(nil) + exp.UpdateUnitStateCharm(gomock.Any(), uuid, map[string]string{"one-key": "one-value"}).Return(nil) + exp.UpdateUnitStateRelation(gomock.Any(), uuid, map[int]string{1: "one-value"}).Return(nil) + + err := NewService(s.st).SetState(context.Background(), unitstate.AgentState{ + Name: "unit/0", + CharmState: ptr(map[string]string{"one-key": "one-value"}), + UniterState: ptr("some-uniter-state-yaml"), + RelationState: ptr(map[int]string{1: "one-value"}), + StorageState: ptr("some-storage-state-yaml"), + SecretState: ptr("some-secret-state-yaml"), + }) + c.Assert(err, jc.ErrorIsNil) +} + +func (s *serviceSuite) TestSetStateSubsetAttributes(c *gc.C) { + defer s.setupMocks(c).Finish() + + uuid := "some-unit-uuid" + + exp := s.st.EXPECT() + exp.GetUnitUUIDForName(gomock.Any(), "unit/0").Return(uuid, nil) + exp.EnsureUnitStateRecord(gomock.Any(), uuid).Return(nil) + exp.UpdateUnitStateUniter(gomock.Any(), uuid, "some-uniter-state-yaml").Return(nil) + + err := NewService(s.st).SetState(context.Background(), unitstate.AgentState{ + Name: "unit/0", + UniterState: ptr("some-uniter-state-yaml"), + }) + c.Assert(err, jc.ErrorIsNil) +} + +func (s *serviceSuite) TestSetStateUnitNotFound(c *gc.C) { + defer s.setupMocks(c).Finish() + + exp := s.st.EXPECT() + exp.GetUnitUUIDForName(gomock.Any(), "unit/0").Return("", errors.UnitNotFound) + + err := NewService(s.st).SetState(context.Background(), unitstate.AgentState{ + Name: "unit/0", + UniterState: ptr("some-uniter-state-yaml"), + }) + c.Check(err, jc.ErrorIs, unitstateerrors.UnitNotFound) +} + +func (s *serviceSuite) setupMocks(c *gc.C) *gomock.Controller { + ctrl := gomock.NewController(c) + + s.st = NewMockState(ctrl) + s.st.EXPECT().RunAtomic(gomock.Any(), gomock.Any()).DoAndReturn(func(ctx context.Context, fn func(ctx domain.AtomicContext) error) error { + return fn(domaintesting.NewAtomicContext(ctx)) + }).AnyTimes() + + return ctrl +} diff --git a/domain/unitstate/service/state_mock_test.go b/domain/unitstate/service/state_mock_test.go new file mode 100644 index 00000000000..deb7cbb5e7f --- /dev/null +++ b/domain/unitstate/service/state_mock_test.go @@ -0,0 +1,346 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/juju/juju/domain/unitstate/service (interfaces: State) +// +// Generated by this command: +// +// mockgen -typed -package service -destination state_mock_test.go github.com/juju/juju/domain/unitstate/service State +// + +// Package service is a generated GoMock package. +package service + +import ( + context "context" + reflect "reflect" + + domain "github.com/juju/juju/domain" + gomock "go.uber.org/mock/gomock" +) + +// MockState is a mock of State interface. +type MockState struct { + ctrl *gomock.Controller + recorder *MockStateMockRecorder +} + +// MockStateMockRecorder is the mock recorder for MockState. +type MockStateMockRecorder struct { + mock *MockState +} + +// NewMockState creates a new mock instance. +func NewMockState(ctrl *gomock.Controller) *MockState { + mock := &MockState{ctrl: ctrl} + mock.recorder = &MockStateMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockState) EXPECT() *MockStateMockRecorder { + return m.recorder +} + +// EnsureUnitStateRecord mocks base method. +func (m *MockState) EnsureUnitStateRecord(arg0 domain.AtomicContext, arg1 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EnsureUnitStateRecord", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// EnsureUnitStateRecord indicates an expected call of EnsureUnitStateRecord. +func (mr *MockStateMockRecorder) EnsureUnitStateRecord(arg0, arg1 any) *MockStateEnsureUnitStateRecordCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnsureUnitStateRecord", reflect.TypeOf((*MockState)(nil).EnsureUnitStateRecord), arg0, arg1) + return &MockStateEnsureUnitStateRecordCall{Call: call} +} + +// MockStateEnsureUnitStateRecordCall wrap *gomock.Call +type MockStateEnsureUnitStateRecordCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockStateEnsureUnitStateRecordCall) Return(arg0 error) *MockStateEnsureUnitStateRecordCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockStateEnsureUnitStateRecordCall) Do(f func(domain.AtomicContext, string) error) *MockStateEnsureUnitStateRecordCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockStateEnsureUnitStateRecordCall) DoAndReturn(f func(domain.AtomicContext, string) error) *MockStateEnsureUnitStateRecordCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetUnitUUIDForName mocks base method. +func (m *MockState) GetUnitUUIDForName(arg0 domain.AtomicContext, arg1 string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUnitUUIDForName", arg0, arg1) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUnitUUIDForName indicates an expected call of GetUnitUUIDForName. +func (mr *MockStateMockRecorder) GetUnitUUIDForName(arg0, arg1 any) *MockStateGetUnitUUIDForNameCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUnitUUIDForName", reflect.TypeOf((*MockState)(nil).GetUnitUUIDForName), arg0, arg1) + return &MockStateGetUnitUUIDForNameCall{Call: call} +} + +// MockStateGetUnitUUIDForNameCall wrap *gomock.Call +type MockStateGetUnitUUIDForNameCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockStateGetUnitUUIDForNameCall) Return(arg0 string, arg1 error) *MockStateGetUnitUUIDForNameCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockStateGetUnitUUIDForNameCall) Do(f func(domain.AtomicContext, string) (string, error)) *MockStateGetUnitUUIDForNameCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockStateGetUnitUUIDForNameCall) DoAndReturn(f func(domain.AtomicContext, string) (string, error)) *MockStateGetUnitUUIDForNameCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// RunAtomic mocks base method. +func (m *MockState) RunAtomic(arg0 context.Context, arg1 func(domain.AtomicContext) error) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RunAtomic", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// RunAtomic indicates an expected call of RunAtomic. +func (mr *MockStateMockRecorder) RunAtomic(arg0, arg1 any) *MockStateRunAtomicCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunAtomic", reflect.TypeOf((*MockState)(nil).RunAtomic), arg0, arg1) + return &MockStateRunAtomicCall{Call: call} +} + +// MockStateRunAtomicCall wrap *gomock.Call +type MockStateRunAtomicCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockStateRunAtomicCall) Return(arg0 error) *MockStateRunAtomicCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockStateRunAtomicCall) Do(f func(context.Context, func(domain.AtomicContext) error) error) *MockStateRunAtomicCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockStateRunAtomicCall) DoAndReturn(f func(context.Context, func(domain.AtomicContext) error) error) *MockStateRunAtomicCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// UpdateUnitStateCharm mocks base method. +func (m *MockState) UpdateUnitStateCharm(arg0 domain.AtomicContext, arg1 string, arg2 map[string]string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateUnitStateCharm", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateUnitStateCharm indicates an expected call of UpdateUnitStateCharm. +func (mr *MockStateMockRecorder) UpdateUnitStateCharm(arg0, arg1, arg2 any) *MockStateUpdateUnitStateCharmCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateUnitStateCharm", reflect.TypeOf((*MockState)(nil).UpdateUnitStateCharm), arg0, arg1, arg2) + return &MockStateUpdateUnitStateCharmCall{Call: call} +} + +// MockStateUpdateUnitStateCharmCall wrap *gomock.Call +type MockStateUpdateUnitStateCharmCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockStateUpdateUnitStateCharmCall) Return(arg0 error) *MockStateUpdateUnitStateCharmCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockStateUpdateUnitStateCharmCall) Do(f func(domain.AtomicContext, string, map[string]string) error) *MockStateUpdateUnitStateCharmCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockStateUpdateUnitStateCharmCall) DoAndReturn(f func(domain.AtomicContext, string, map[string]string) error) *MockStateUpdateUnitStateCharmCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// UpdateUnitStateRelation mocks base method. +func (m *MockState) UpdateUnitStateRelation(arg0 domain.AtomicContext, arg1 string, arg2 map[int]string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateUnitStateRelation", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateUnitStateRelation indicates an expected call of UpdateUnitStateRelation. +func (mr *MockStateMockRecorder) UpdateUnitStateRelation(arg0, arg1, arg2 any) *MockStateUpdateUnitStateRelationCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateUnitStateRelation", reflect.TypeOf((*MockState)(nil).UpdateUnitStateRelation), arg0, arg1, arg2) + return &MockStateUpdateUnitStateRelationCall{Call: call} +} + +// MockStateUpdateUnitStateRelationCall wrap *gomock.Call +type MockStateUpdateUnitStateRelationCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockStateUpdateUnitStateRelationCall) Return(arg0 error) *MockStateUpdateUnitStateRelationCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockStateUpdateUnitStateRelationCall) Do(f func(domain.AtomicContext, string, map[int]string) error) *MockStateUpdateUnitStateRelationCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockStateUpdateUnitStateRelationCall) DoAndReturn(f func(domain.AtomicContext, string, map[int]string) error) *MockStateUpdateUnitStateRelationCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// UpdateUnitStateSecret mocks base method. +func (m *MockState) UpdateUnitStateSecret(arg0 domain.AtomicContext, arg1, arg2 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateUnitStateSecret", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateUnitStateSecret indicates an expected call of UpdateUnitStateSecret. +func (mr *MockStateMockRecorder) UpdateUnitStateSecret(arg0, arg1, arg2 any) *MockStateUpdateUnitStateSecretCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateUnitStateSecret", reflect.TypeOf((*MockState)(nil).UpdateUnitStateSecret), arg0, arg1, arg2) + return &MockStateUpdateUnitStateSecretCall{Call: call} +} + +// MockStateUpdateUnitStateSecretCall wrap *gomock.Call +type MockStateUpdateUnitStateSecretCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockStateUpdateUnitStateSecretCall) Return(arg0 error) *MockStateUpdateUnitStateSecretCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockStateUpdateUnitStateSecretCall) Do(f func(domain.AtomicContext, string, string) error) *MockStateUpdateUnitStateSecretCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockStateUpdateUnitStateSecretCall) DoAndReturn(f func(domain.AtomicContext, string, string) error) *MockStateUpdateUnitStateSecretCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// UpdateUnitStateStorage mocks base method. +func (m *MockState) UpdateUnitStateStorage(arg0 domain.AtomicContext, arg1, arg2 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateUnitStateStorage", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateUnitStateStorage indicates an expected call of UpdateUnitStateStorage. +func (mr *MockStateMockRecorder) UpdateUnitStateStorage(arg0, arg1, arg2 any) *MockStateUpdateUnitStateStorageCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateUnitStateStorage", reflect.TypeOf((*MockState)(nil).UpdateUnitStateStorage), arg0, arg1, arg2) + return &MockStateUpdateUnitStateStorageCall{Call: call} +} + +// MockStateUpdateUnitStateStorageCall wrap *gomock.Call +type MockStateUpdateUnitStateStorageCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockStateUpdateUnitStateStorageCall) Return(arg0 error) *MockStateUpdateUnitStateStorageCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockStateUpdateUnitStateStorageCall) Do(f func(domain.AtomicContext, string, string) error) *MockStateUpdateUnitStateStorageCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockStateUpdateUnitStateStorageCall) DoAndReturn(f func(domain.AtomicContext, string, string) error) *MockStateUpdateUnitStateStorageCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// UpdateUnitStateUniter mocks base method. +func (m *MockState) UpdateUnitStateUniter(arg0 domain.AtomicContext, arg1, arg2 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateUnitStateUniter", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateUnitStateUniter indicates an expected call of UpdateUnitStateUniter. +func (mr *MockStateMockRecorder) UpdateUnitStateUniter(arg0, arg1, arg2 any) *MockStateUpdateUnitStateUniterCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateUnitStateUniter", reflect.TypeOf((*MockState)(nil).UpdateUnitStateUniter), arg0, arg1, arg2) + return &MockStateUpdateUnitStateUniterCall{Call: call} +} + +// MockStateUpdateUnitStateUniterCall wrap *gomock.Call +type MockStateUpdateUnitStateUniterCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockStateUpdateUnitStateUniterCall) Return(arg0 error) *MockStateUpdateUnitStateUniterCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockStateUpdateUnitStateUniterCall) Do(f func(domain.AtomicContext, string, string) error) *MockStateUpdateUnitStateUniterCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockStateUpdateUnitStateUniterCall) DoAndReturn(f func(domain.AtomicContext, string, string) error) *MockStateUpdateUnitStateUniterCall { + c.Call = c.Call.DoAndReturn(f) + return c +}