mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
chore: cache: generate mocks for act/artifactcache/caches.go
This commit is contained in:
parent
c28a98082b
commit
c48accfb51
4 changed files with 234 additions and 3 deletions
4
Makefile
4
Makefile
|
@ -62,7 +62,7 @@ else
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
GO_PACKAGES_TO_VET ?= $(filter-out code.forgejo.org/forgejo/runner/v11/internal/pkg/client/mocks,$(shell $(GO) list ./...))
|
GO_PACKAGES_TO_VET ?= $(filter-out code.forgejo.org/forgejo/runner/v11/internal/pkg/client/mocks code.forgejo.org/forgejo/runner/v11/act/artifactcache/mock_caches.go,$(shell $(GO) list ./...))
|
||||||
|
|
||||||
TAGS ?=
|
TAGS ?=
|
||||||
LDFLAGS ?= -X "code.forgejo.org/forgejo/runner/v11/internal/pkg/ver.version=v$(RELEASE_VERSION)"
|
LDFLAGS ?= -X "code.forgejo.org/forgejo/runner/v11/internal/pkg/ver.version=v$(RELEASE_VERSION)"
|
||||||
|
@ -120,7 +120,7 @@ vet:
|
||||||
|
|
||||||
.PHONY: generate
|
.PHONY: generate
|
||||||
generate:
|
generate:
|
||||||
$(GO) generate ./internal/...
|
$(GO) generate ./...
|
||||||
|
|
||||||
install: $(GOFILES)
|
install: $(GOFILES)
|
||||||
$(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
|
$(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate mockery --inpackage --name caches
|
||||||
type caches interface {
|
type caches interface {
|
||||||
openDB() (*bolthold.Store, error)
|
openDB() (*bolthold.Store, error)
|
||||||
validateMac(rundata RunData) (string, error)
|
validateMac(rundata RunData) (string, error)
|
||||||
|
|
230
act/artifactcache/mock_caches.go
Normal file
230
act/artifactcache/mock_caches.go
Normal file
|
@ -0,0 +1,230 @@
|
||||||
|
// Code generated by mockery v2.53.5. DO NOT EDIT.
|
||||||
|
|
||||||
|
package artifactcache
|
||||||
|
|
||||||
|
import (
|
||||||
|
http "net/http"
|
||||||
|
|
||||||
|
bolthold "github.com/timshannon/bolthold"
|
||||||
|
|
||||||
|
io "io"
|
||||||
|
|
||||||
|
mock "github.com/stretchr/testify/mock"
|
||||||
|
|
||||||
|
time "time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// mockCaches is an autogenerated mock type for the caches type
|
||||||
|
type mockCaches struct {
|
||||||
|
mock.Mock
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit provides a mock function with given fields: id, size
|
||||||
|
func (_m *mockCaches) commit(id uint64, size int64) (int64, error) {
|
||||||
|
ret := _m.Called(id, size)
|
||||||
|
|
||||||
|
if len(ret) == 0 {
|
||||||
|
panic("no return value specified for commit")
|
||||||
|
}
|
||||||
|
|
||||||
|
var r0 int64
|
||||||
|
var r1 error
|
||||||
|
if rf, ok := ret.Get(0).(func(uint64, int64) (int64, error)); ok {
|
||||||
|
return rf(id, size)
|
||||||
|
}
|
||||||
|
if rf, ok := ret.Get(0).(func(uint64, int64) int64); ok {
|
||||||
|
r0 = rf(id, size)
|
||||||
|
} else {
|
||||||
|
r0 = ret.Get(0).(int64)
|
||||||
|
}
|
||||||
|
|
||||||
|
if rf, ok := ret.Get(1).(func(uint64, int64) error); ok {
|
||||||
|
r1 = rf(id, size)
|
||||||
|
} else {
|
||||||
|
r1 = ret.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
|
}
|
||||||
|
|
||||||
|
// exist provides a mock function with given fields: id
|
||||||
|
func (_m *mockCaches) exist(id uint64) (bool, error) {
|
||||||
|
ret := _m.Called(id)
|
||||||
|
|
||||||
|
if len(ret) == 0 {
|
||||||
|
panic("no return value specified for exist")
|
||||||
|
}
|
||||||
|
|
||||||
|
var r0 bool
|
||||||
|
var r1 error
|
||||||
|
if rf, ok := ret.Get(0).(func(uint64) (bool, error)); ok {
|
||||||
|
return rf(id)
|
||||||
|
}
|
||||||
|
if rf, ok := ret.Get(0).(func(uint64) bool); ok {
|
||||||
|
r0 = rf(id)
|
||||||
|
} else {
|
||||||
|
r0 = ret.Get(0).(bool)
|
||||||
|
}
|
||||||
|
|
||||||
|
if rf, ok := ret.Get(1).(func(uint64) error); ok {
|
||||||
|
r1 = rf(id)
|
||||||
|
} else {
|
||||||
|
r1 = ret.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
|
}
|
||||||
|
|
||||||
|
// gcCache provides a mock function with no fields
|
||||||
|
func (_m *mockCaches) gcCache() {
|
||||||
|
_m.Called()
|
||||||
|
}
|
||||||
|
|
||||||
|
// openDB provides a mock function with no fields
|
||||||
|
func (_m *mockCaches) openDB() (*bolthold.Store, error) {
|
||||||
|
ret := _m.Called()
|
||||||
|
|
||||||
|
if len(ret) == 0 {
|
||||||
|
panic("no return value specified for openDB")
|
||||||
|
}
|
||||||
|
|
||||||
|
var r0 *bolthold.Store
|
||||||
|
var r1 error
|
||||||
|
if rf, ok := ret.Get(0).(func() (*bolthold.Store, error)); ok {
|
||||||
|
return rf()
|
||||||
|
}
|
||||||
|
if rf, ok := ret.Get(0).(func() *bolthold.Store); ok {
|
||||||
|
r0 = rf()
|
||||||
|
} else {
|
||||||
|
if ret.Get(0) != nil {
|
||||||
|
r0 = ret.Get(0).(*bolthold.Store)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if rf, ok := ret.Get(1).(func() error); ok {
|
||||||
|
r1 = rf()
|
||||||
|
} else {
|
||||||
|
r1 = ret.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
|
}
|
||||||
|
|
||||||
|
// readCache provides a mock function with given fields: id, repo
|
||||||
|
func (_m *mockCaches) readCache(id uint64, repo string) (*Cache, error) {
|
||||||
|
ret := _m.Called(id, repo)
|
||||||
|
|
||||||
|
if len(ret) == 0 {
|
||||||
|
panic("no return value specified for readCache")
|
||||||
|
}
|
||||||
|
|
||||||
|
var r0 *Cache
|
||||||
|
var r1 error
|
||||||
|
if rf, ok := ret.Get(0).(func(uint64, string) (*Cache, error)); ok {
|
||||||
|
return rf(id, repo)
|
||||||
|
}
|
||||||
|
if rf, ok := ret.Get(0).(func(uint64, string) *Cache); ok {
|
||||||
|
r0 = rf(id, repo)
|
||||||
|
} else {
|
||||||
|
if ret.Get(0) != nil {
|
||||||
|
r0 = ret.Get(0).(*Cache)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if rf, ok := ret.Get(1).(func(uint64, string) error); ok {
|
||||||
|
r1 = rf(id, repo)
|
||||||
|
} else {
|
||||||
|
r1 = ret.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
|
}
|
||||||
|
|
||||||
|
// serve provides a mock function with given fields: w, r, id
|
||||||
|
func (_m *mockCaches) serve(w http.ResponseWriter, r *http.Request, id uint64) {
|
||||||
|
_m.Called(w, r, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// setgcAt provides a mock function with given fields: at
|
||||||
|
func (_m *mockCaches) setgcAt(at time.Time) {
|
||||||
|
_m.Called(at)
|
||||||
|
}
|
||||||
|
|
||||||
|
// useCache provides a mock function with given fields: id
|
||||||
|
func (_m *mockCaches) useCache(id uint64) error {
|
||||||
|
ret := _m.Called(id)
|
||||||
|
|
||||||
|
if len(ret) == 0 {
|
||||||
|
panic("no return value specified for useCache")
|
||||||
|
}
|
||||||
|
|
||||||
|
var r0 error
|
||||||
|
if rf, ok := ret.Get(0).(func(uint64) error); ok {
|
||||||
|
r0 = rf(id)
|
||||||
|
} else {
|
||||||
|
r0 = ret.Error(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0
|
||||||
|
}
|
||||||
|
|
||||||
|
// validateMac provides a mock function with given fields: rundata
|
||||||
|
func (_m *mockCaches) validateMac(rundata RunData) (string, error) {
|
||||||
|
ret := _m.Called(rundata)
|
||||||
|
|
||||||
|
if len(ret) == 0 {
|
||||||
|
panic("no return value specified for validateMac")
|
||||||
|
}
|
||||||
|
|
||||||
|
var r0 string
|
||||||
|
var r1 error
|
||||||
|
if rf, ok := ret.Get(0).(func(RunData) (string, error)); ok {
|
||||||
|
return rf(rundata)
|
||||||
|
}
|
||||||
|
if rf, ok := ret.Get(0).(func(RunData) string); ok {
|
||||||
|
r0 = rf(rundata)
|
||||||
|
} else {
|
||||||
|
r0 = ret.Get(0).(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if rf, ok := ret.Get(1).(func(RunData) error); ok {
|
||||||
|
r1 = rf(rundata)
|
||||||
|
} else {
|
||||||
|
r1 = ret.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
|
}
|
||||||
|
|
||||||
|
// write provides a mock function with given fields: id, offset, reader
|
||||||
|
func (_m *mockCaches) write(id uint64, offset uint64, reader io.Reader) error {
|
||||||
|
ret := _m.Called(id, offset, reader)
|
||||||
|
|
||||||
|
if len(ret) == 0 {
|
||||||
|
panic("no return value specified for write")
|
||||||
|
}
|
||||||
|
|
||||||
|
var r0 error
|
||||||
|
if rf, ok := ret.Get(0).(func(uint64, uint64, io.Reader) error); ok {
|
||||||
|
r0 = rf(id, offset, reader)
|
||||||
|
} else {
|
||||||
|
r0 = ret.Error(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0
|
||||||
|
}
|
||||||
|
|
||||||
|
// newMockCaches creates a new instance of mockCaches. 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 newMockCaches(t interface {
|
||||||
|
mock.TestingT
|
||||||
|
Cleanup(func())
|
||||||
|
},
|
||||||
|
) *mockCaches {
|
||||||
|
mock := &mockCaches{}
|
||||||
|
mock.Mock.Test(t)
|
||||||
|
|
||||||
|
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||||
|
|
||||||
|
return mock
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by mockery v2.53.4. DO NOT EDIT.
|
// Code generated by mockery v2.53.5. DO NOT EDIT.
|
||||||
|
|
||||||
package mocks
|
package mocks
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue