mirror of
https://github.com/ultravioletrs/cocos.git
synced 2026-06-23 04:10:25 +00:00
8eb1fac9ad
* Refactor and update dependencies in the project - Updated go.sum to replace `github.com/absmach/magistrala` with `github.com/absmach/supermq` across various modules. - Removed VSock configuration from environment variables and QEMU arguments. - Updated QEMU configuration and related tests to remove references to guest CID and VSock. - Added new HTTP transport layer for API endpoints in the manager. - Introduced Prometheus monitoring configuration with alert rules and Alertmanager setup. - Updated service and VM interfaces to remove unused methods and references. - Refactored tests to align with the new structure and dependencies. Signed-off-by: Sammy Oina <sammyoina@gmail.com> * Add MaxVMs configuration and enforce limit on VM creation Signed-off-by: Sammy Oina <sammyoina@gmail.com> * Add comprehensive tests for HTTP transport handlers and endpoints Signed-off-by: Sammy Oina <sammyoina@gmail.com> * Add test case for exceeding maximum number of VMs in TestRun Signed-off-by: Sammy Oina <sammyoina@gmail.com> * Improve error handling in TestHandlerWithCustomRouter to ensure response writing is checked Signed-off-by: Sammy Oina <sammyoina@gmail.com> * Update dependencies to latest versions - Upgrade cel.dev/expr from v0.23.0 to v0.24.0 - Upgrade github.com/absmach/supermq from v0.16.0 to v0.17.0 - Upgrade github.com/cenkalti/backoff from v4.3.0 to v5.0.2 - Upgrade github.com/cncf/xds/go to v0.0.0-20250501225837-2ac532fd4443 - Upgrade github.com/go-chi/chi/v5 from v5.2.1 to v5.2.2 - Upgrade github.com/go-jose/go-jose/v3 from v3.0.3 to v3.0.4 - Upgrade github.com/gofrs/uuid/v5 from v5.3.0 to v5.3.2 - Upgrade github.com/prometheus/client_golang from v1.22.0 to v1.23.0 - Upgrade github.com/prometheus/client_model from v0.6.1 to v0.6.2 - Upgrade github.com/prometheus/common from v0.62.0 to v0.65.0 - Upgrade github.com/prometheus/procfs from v0.15.1 to v0.16.1 - Upgrade go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp from v0.60.0 to v0.62.0 - Upgrade go.opentelemetry.io/otel/exporters/otlp/otlptrace from v1.36.0 to v1.37.0 - Upgrade golang.org/x/crypto from v0.39.0 to v0.40.0 - Upgrade golang.org/x/sys from v0.33.0 to v0.34.0 - Upgrade golang.org/x/text from v0.26.0 to v0.27.0 - Upgrade golang.org/x/time from v0.11.0 to v0.12.0 - Upgrade google.golang.org/grpc from v1.73.0 to v1.74.2 Signed-off-by: Sammy Oina <sammyoina@gmail.com> --------- Signed-off-by: Sammy Oina <sammyoina@gmail.com>
358 lines
7.8 KiB
Go
358 lines
7.8 KiB
Go
// Copyright (c) Ultraviolet
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// Code generated by mockery v2.53.3. DO NOT EDIT.
|
|
|
|
package mocks
|
|
|
|
import (
|
|
mock "github.com/stretchr/testify/mock"
|
|
manager "github.com/ultravioletrs/cocos/pkg/manager"
|
|
)
|
|
|
|
// VM is an autogenerated mock type for the VM type
|
|
type VM struct {
|
|
mock.Mock
|
|
}
|
|
|
|
type VM_Expecter struct {
|
|
mock *mock.Mock
|
|
}
|
|
|
|
func (_m *VM) EXPECT() *VM_Expecter {
|
|
return &VM_Expecter{mock: &_m.Mock}
|
|
}
|
|
|
|
// GetConfig provides a mock function with no fields
|
|
func (_m *VM) GetConfig() interface{} {
|
|
ret := _m.Called()
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for GetConfig")
|
|
}
|
|
|
|
var r0 interface{}
|
|
if rf, ok := ret.Get(0).(func() interface{}); ok {
|
|
r0 = rf()
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(interface{})
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// VM_GetConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetConfig'
|
|
type VM_GetConfig_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// GetConfig is a helper method to define mock.On call
|
|
func (_e *VM_Expecter) GetConfig() *VM_GetConfig_Call {
|
|
return &VM_GetConfig_Call{Call: _e.mock.On("GetConfig")}
|
|
}
|
|
|
|
func (_c *VM_GetConfig_Call) Run(run func()) *VM_GetConfig_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run()
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_GetConfig_Call) Return(_a0 interface{}) *VM_GetConfig_Call {
|
|
_c.Call.Return(_a0)
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_GetConfig_Call) RunAndReturn(run func() interface{}) *VM_GetConfig_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// GetProcess provides a mock function with no fields
|
|
func (_m *VM) GetProcess() int {
|
|
ret := _m.Called()
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for GetProcess")
|
|
}
|
|
|
|
var r0 int
|
|
if rf, ok := ret.Get(0).(func() int); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Get(0).(int)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// VM_GetProcess_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProcess'
|
|
type VM_GetProcess_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// GetProcess is a helper method to define mock.On call
|
|
func (_e *VM_Expecter) GetProcess() *VM_GetProcess_Call {
|
|
return &VM_GetProcess_Call{Call: _e.mock.On("GetProcess")}
|
|
}
|
|
|
|
func (_c *VM_GetProcess_Call) Run(run func()) *VM_GetProcess_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run()
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_GetProcess_Call) Return(_a0 int) *VM_GetProcess_Call {
|
|
_c.Call.Return(_a0)
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_GetProcess_Call) RunAndReturn(run func() int) *VM_GetProcess_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// SetProcess provides a mock function with given fields: pid
|
|
func (_m *VM) SetProcess(pid int) error {
|
|
ret := _m.Called(pid)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for SetProcess")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(int) error); ok {
|
|
r0 = rf(pid)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// VM_SetProcess_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetProcess'
|
|
type VM_SetProcess_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// SetProcess is a helper method to define mock.On call
|
|
// - pid int
|
|
func (_e *VM_Expecter) SetProcess(pid interface{}) *VM_SetProcess_Call {
|
|
return &VM_SetProcess_Call{Call: _e.mock.On("SetProcess", pid)}
|
|
}
|
|
|
|
func (_c *VM_SetProcess_Call) Run(run func(pid int)) *VM_SetProcess_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run(args[0].(int))
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_SetProcess_Call) Return(_a0 error) *VM_SetProcess_Call {
|
|
_c.Call.Return(_a0)
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_SetProcess_Call) RunAndReturn(run func(int) error) *VM_SetProcess_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// Start provides a mock function with no fields
|
|
func (_m *VM) Start() error {
|
|
ret := _m.Called()
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Start")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func() error); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// VM_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start'
|
|
type VM_Start_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// Start is a helper method to define mock.On call
|
|
func (_e *VM_Expecter) Start() *VM_Start_Call {
|
|
return &VM_Start_Call{Call: _e.mock.On("Start")}
|
|
}
|
|
|
|
func (_c *VM_Start_Call) Run(run func()) *VM_Start_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run()
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_Start_Call) Return(_a0 error) *VM_Start_Call {
|
|
_c.Call.Return(_a0)
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_Start_Call) RunAndReturn(run func() error) *VM_Start_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// State provides a mock function with no fields
|
|
func (_m *VM) State() string {
|
|
ret := _m.Called()
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for State")
|
|
}
|
|
|
|
var r0 string
|
|
if rf, ok := ret.Get(0).(func() string); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Get(0).(string)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// VM_State_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'State'
|
|
type VM_State_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// State is a helper method to define mock.On call
|
|
func (_e *VM_Expecter) State() *VM_State_Call {
|
|
return &VM_State_Call{Call: _e.mock.On("State")}
|
|
}
|
|
|
|
func (_c *VM_State_Call) Run(run func()) *VM_State_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run()
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_State_Call) Return(_a0 string) *VM_State_Call {
|
|
_c.Call.Return(_a0)
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_State_Call) RunAndReturn(run func() string) *VM_State_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// Stop provides a mock function with no fields
|
|
func (_m *VM) Stop() error {
|
|
ret := _m.Called()
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Stop")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func() error); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// VM_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop'
|
|
type VM_Stop_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// Stop is a helper method to define mock.On call
|
|
func (_e *VM_Expecter) Stop() *VM_Stop_Call {
|
|
return &VM_Stop_Call{Call: _e.mock.On("Stop")}
|
|
}
|
|
|
|
func (_c *VM_Stop_Call) Run(run func()) *VM_Stop_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run()
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_Stop_Call) Return(_a0 error) *VM_Stop_Call {
|
|
_c.Call.Return(_a0)
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_Stop_Call) RunAndReturn(run func() error) *VM_Stop_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// Transition provides a mock function with given fields: newState
|
|
func (_m *VM) Transition(newState manager.ManagerState) error {
|
|
ret := _m.Called(newState)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Transition")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(manager.ManagerState) error); ok {
|
|
r0 = rf(newState)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// VM_Transition_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Transition'
|
|
type VM_Transition_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// Transition is a helper method to define mock.On call
|
|
// - newState manager.ManagerState
|
|
func (_e *VM_Expecter) Transition(newState interface{}) *VM_Transition_Call {
|
|
return &VM_Transition_Call{Call: _e.mock.On("Transition", newState)}
|
|
}
|
|
|
|
func (_c *VM_Transition_Call) Run(run func(newState manager.ManagerState)) *VM_Transition_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run(args[0].(manager.ManagerState))
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_Transition_Call) Return(_a0 error) *VM_Transition_Call {
|
|
_c.Call.Return(_a0)
|
|
return _c
|
|
}
|
|
|
|
func (_c *VM_Transition_Call) RunAndReturn(run func(manager.ManagerState) error) *VM_Transition_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// NewVM creates a new instance of VM. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
|
// The first argument is typically a *testing.T value.
|
|
func NewVM(t interface {
|
|
mock.TestingT
|
|
Cleanup(func())
|
|
}) *VM {
|
|
mock := &VM{}
|
|
mock.Mock.Test(t)
|
|
|
|
t.Cleanup(func() { mock.AssertExpectations(t) })
|
|
|
|
return mock
|
|
}
|