From ce2bf16548a91da74d73168258e2093cf8e59d55 Mon Sep 17 00:00:00 2001 From: Javad Date: Sat, 8 Apr 2023 14:30:42 +0430 Subject: [PATCH] add: zapper mocks --- mocks/Caller.go | 186 +++++++++++++++++++++++++++++ mocks/Core.go | 42 +++++++ mocks/Option.go | 33 ++++++ mocks/Zapper.go | 273 +++++++++++++++++++++++++++++++++++++++++++ mocks/encoderFunc.go | 44 +++++++ mocks/logFunc.go | 36 ++++++ mocks/logKvFunc.go | 36 ++++++ mocks/logfFunc.go | 36 ++++++ 8 files changed, 686 insertions(+) create mode 100644 mocks/Caller.go create mode 100644 mocks/Core.go create mode 100644 mocks/Option.go create mode 100644 mocks/Zapper.go create mode 100644 mocks/encoderFunc.go create mode 100644 mocks/logFunc.go create mode 100644 mocks/logKvFunc.go create mode 100644 mocks/logfFunc.go diff --git a/mocks/Caller.go b/mocks/Caller.go new file mode 100644 index 0000000..575255f --- /dev/null +++ b/mocks/Caller.go @@ -0,0 +1,186 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// Caller is an autogenerated mock type for the Caller type +type Caller struct { + mock.Mock +} + +// DPanic provides a mock function with given fields: _a0 +func (_m *Caller) DPanic(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// DPanicF provides a mock function with given fields: _a0, _a1 +func (_m *Caller) DPanicF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// DPanicW provides a mock function with given fields: _a0, _a1 +func (_m *Caller) DPanicW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// Debug provides a mock function with given fields: _a0 +func (_m *Caller) Debug(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// DebugF provides a mock function with given fields: _a0, _a1 +func (_m *Caller) DebugF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// DebugW provides a mock function with given fields: _a0, _a1 +func (_m *Caller) DebugW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// Error provides a mock function with given fields: _a0 +func (_m *Caller) Error(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// ErrorF provides a mock function with given fields: _a0, _a1 +func (_m *Caller) ErrorF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// ErrorW provides a mock function with given fields: _a0, _a1 +func (_m *Caller) ErrorW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// Fatal provides a mock function with given fields: _a0 +func (_m *Caller) Fatal(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// FatalF provides a mock function with given fields: _a0, _a1 +func (_m *Caller) FatalF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// FatalW provides a mock function with given fields: _a0, _a1 +func (_m *Caller) FatalW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// Info provides a mock function with given fields: _a0 +func (_m *Caller) Info(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// InfoF provides a mock function with given fields: _a0, _a1 +func (_m *Caller) InfoF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// InfoW provides a mock function with given fields: _a0, _a1 +func (_m *Caller) InfoW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// Panic provides a mock function with given fields: _a0 +func (_m *Caller) Panic(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// PanicF provides a mock function with given fields: _a0, _a1 +func (_m *Caller) PanicF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// PanicW provides a mock function with given fields: _a0, _a1 +func (_m *Caller) PanicW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// Warn provides a mock function with given fields: _a0 +func (_m *Caller) Warn(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// WarnF provides a mock function with given fields: _a0, _a1 +func (_m *Caller) WarnF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// WarnW provides a mock function with given fields: _a0, _a1 +func (_m *Caller) WarnW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +type mockConstructorTestingTNewCaller interface { + mock.TestingT + Cleanup(func()) +} + +// NewCaller creates a new instance of Caller. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewCaller(t mockConstructorTestingTNewCaller) *Caller { + mock := &Caller{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/Core.go b/mocks/Core.go new file mode 100644 index 0000000..7ded712 --- /dev/null +++ b/mocks/Core.go @@ -0,0 +1,42 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import ( + zapper "github.com/GoFarsi/zapper" + mock "github.com/stretchr/testify/mock" +) + +// Core is an autogenerated mock type for the Core type +type Core struct { + mock.Mock +} + +// init provides a mock function with given fields: _a0 +func (_m *Core) init(_a0 *zapper.Zap) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(*zapper.Zap) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +type mockConstructorTestingTNewCore interface { + mock.TestingT + Cleanup(func()) +} + +// NewCore creates a new instance of Core. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewCore(t mockConstructorTestingTNewCore) *Core { + mock := &Core{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/Option.go b/mocks/Option.go new file mode 100644 index 0000000..e0caaea --- /dev/null +++ b/mocks/Option.go @@ -0,0 +1,33 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import ( + zapper "github.com/GoFarsi/zapper" + mock "github.com/stretchr/testify/mock" +) + +// Option is an autogenerated mock type for the Option type +type Option struct { + mock.Mock +} + +// Execute provides a mock function with given fields: _a0 +func (_m *Option) Execute(_a0 *zapper.Zap) { + _m.Called(_a0) +} + +type mockConstructorTestingTNewOption interface { + mock.TestingT + Cleanup(func()) +} + +// NewOption creates a new instance of Option. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewOption(t mockConstructorTestingTNewOption) *Option { + mock := &Option{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/Zapper.go b/mocks/Zapper.go new file mode 100644 index 0000000..2b43797 --- /dev/null +++ b/mocks/Zapper.go @@ -0,0 +1,273 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import ( + sentry "github.com/getsentry/sentry-go" + mock "github.com/stretchr/testify/mock" + + zap "go.uber.org/zap" + + zapper "github.com/GoFarsi/zapper" +) + +// Zapper is an autogenerated mock type for the Zapper type +type Zapper struct { + mock.Mock +} + +// DPanic provides a mock function with given fields: _a0 +func (_m *Zapper) DPanic(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// DPanicF provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) DPanicF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// DPanicW provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) DPanicW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// Debug provides a mock function with given fields: _a0 +func (_m *Zapper) Debug(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// DebugF provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) DebugF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// DebugW provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) DebugW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// Error provides a mock function with given fields: _a0 +func (_m *Zapper) Error(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// ErrorF provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) ErrorF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// ErrorW provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) ErrorW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// Fatal provides a mock function with given fields: _a0 +func (_m *Zapper) Fatal(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// FatalF provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) FatalF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// FatalW provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) FatalW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// GetSentryClient provides a mock function with given fields: +func (_m *Zapper) GetSentryClient() *sentry.Client { + ret := _m.Called() + + var r0 *sentry.Client + if rf, ok := ret.Get(0).(func() *sentry.Client); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sentry.Client) + } + } + + return r0 +} + +// GetServiceCode provides a mock function with given fields: +func (_m *Zapper) GetServiceCode() uint { + ret := _m.Called() + + var r0 uint + if rf, ok := ret.Get(0).(func() uint); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint) + } + + return r0 +} + +// GetServiceName provides a mock function with given fields: +func (_m *Zapper) GetServiceName() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// GetZap provides a mock function with given fields: +func (_m *Zapper) GetZap() *zap.Logger { + ret := _m.Called() + + var r0 *zap.Logger + if rf, ok := ret.Get(0).(func() *zap.Logger); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*zap.Logger) + } + } + + return r0 +} + +// Info provides a mock function with given fields: _a0 +func (_m *Zapper) Info(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// InfoF provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) InfoF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// InfoW provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) InfoW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// NewCore provides a mock function with given fields: _a0 +func (_m *Zapper) NewCore(_a0 ...zapper.Core) error { + _va := make([]interface{}, len(_a0)) + for _i := range _a0 { + _va[_i] = _a0[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 error + if rf, ok := ret.Get(0).(func(...zapper.Core) error); ok { + r0 = rf(_a0...) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Panic provides a mock function with given fields: _a0 +func (_m *Zapper) Panic(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// PanicF provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) PanicF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// PanicW provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) PanicW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// Warn provides a mock function with given fields: _a0 +func (_m *Zapper) Warn(_a0 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0...) + _m.Called(_ca...) +} + +// WarnF provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) WarnF(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +// WarnW provides a mock function with given fields: _a0, _a1 +func (_m *Zapper) WarnW(_a0 string, _a1 ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _a1...) + _m.Called(_ca...) +} + +type mockConstructorTestingTNewZapper interface { + mock.TestingT + Cleanup(func()) +} + +// NewZapper creates a new instance of Zapper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewZapper(t mockConstructorTestingTNewZapper) *Zapper { + mock := &Zapper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/encoderFunc.go b/mocks/encoderFunc.go new file mode 100644 index 0000000..0479378 --- /dev/null +++ b/mocks/encoderFunc.go @@ -0,0 +1,44 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + zapcore "go.uber.org/zap/zapcore" +) + +// encoderFunc is an autogenerated mock type for the encoderFunc type +type encoderFunc struct { + mock.Mock +} + +// Execute provides a mock function with given fields: _a0 +func (_m *encoderFunc) Execute(_a0 zapcore.EncoderConfig) zapcore.Encoder { + ret := _m.Called(_a0) + + var r0 zapcore.Encoder + if rf, ok := ret.Get(0).(func(zapcore.EncoderConfig) zapcore.Encoder); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(zapcore.Encoder) + } + } + + return r0 +} + +type mockConstructorTestingTnewEncoderFunc interface { + mock.TestingT + Cleanup(func()) +} + +// newEncoderFunc creates a new instance of encoderFunc. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func newEncoderFunc(t mockConstructorTestingTnewEncoderFunc) *encoderFunc { + mock := &encoderFunc{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/logFunc.go b/mocks/logFunc.go new file mode 100644 index 0000000..442d5a4 --- /dev/null +++ b/mocks/logFunc.go @@ -0,0 +1,36 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + zap "go.uber.org/zap" +) + +// logFunc is an autogenerated mock type for the logFunc type +type logFunc struct { + mock.Mock +} + +// Execute provides a mock function with given fields: _a0, args +func (_m *logFunc) Execute(_a0 *zap.SugaredLogger, args ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, args...) + _m.Called(_ca...) +} + +type mockConstructorTestingTnewLogFunc interface { + mock.TestingT + Cleanup(func()) +} + +// newLogFunc creates a new instance of logFunc. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func newLogFunc(t mockConstructorTestingTnewLogFunc) *logFunc { + mock := &logFunc{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/logKvFunc.go b/mocks/logKvFunc.go new file mode 100644 index 0000000..8242e3d --- /dev/null +++ b/mocks/logKvFunc.go @@ -0,0 +1,36 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + zap "go.uber.org/zap" +) + +// logKvFunc is an autogenerated mock type for the logKvFunc type +type logKvFunc struct { + mock.Mock +} + +// Execute provides a mock function with given fields: _a0, msg, keyAndValues +func (_m *logKvFunc) Execute(_a0 *zap.SugaredLogger, msg string, keyAndValues ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0, msg) + _ca = append(_ca, keyAndValues...) + _m.Called(_ca...) +} + +type mockConstructorTestingTnewLogKvFunc interface { + mock.TestingT + Cleanup(func()) +} + +// newLogKvFunc creates a new instance of logKvFunc. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func newLogKvFunc(t mockConstructorTestingTnewLogKvFunc) *logKvFunc { + mock := &logKvFunc{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/logfFunc.go b/mocks/logfFunc.go new file mode 100644 index 0000000..e0805cf --- /dev/null +++ b/mocks/logfFunc.go @@ -0,0 +1,36 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + zap "go.uber.org/zap" +) + +// logfFunc is an autogenerated mock type for the logfFunc type +type logfFunc struct { + mock.Mock +} + +// Execute provides a mock function with given fields: _a0, msg, args +func (_m *logfFunc) Execute(_a0 *zap.SugaredLogger, msg string, args ...interface{}) { + var _ca []interface{} + _ca = append(_ca, _a0, msg) + _ca = append(_ca, args...) + _m.Called(_ca...) +} + +type mockConstructorTestingTnewLogfFunc interface { + mock.TestingT + Cleanup(func()) +} + +// newLogfFunc creates a new instance of logfFunc. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func newLogfFunc(t mockConstructorTestingTnewLogfFunc) *logfFunc { + mock := &logfFunc{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}