From fe7cce62013a996cba71ee6cadefbc26f00962e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Mon, 14 Sep 2026 23:32:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=AF=B9=E9=BD=90=20libtnb/chi-ske?= =?UTF-8?q?leton=20=E6=9C=80=E6=96=B0=E8=84=9A=E6=89=8B=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 依赖注入换到 libtnb/wire v0.3.0,各层包导出 Module 并逐类型 Export, wire.Struct 改用 Struct[T](),cleanup 签名改为 func() error - 测试断言换到 libtnb/assert 的 must/check,20 个 testify suite 拆成标准测试函数 - mock 改用 matryer 模板输出到 internal/mocks,wire 走 go.mod tool 指令, mockery 用 go run 调用,避免它的依赖树污染 go.mod - 引入 .golangci.yml 并修完全部告警,darwin 与 linux 双平台 0 issues - 工作流改用 go-version-file、govulncheck 官方 action, wire 校验移入 test.yml,mockery 由自动提交改为 PR 校验 顺带修复:pkg/db 四处漏查 rows.Err()(DatabaseExists 查询出错会被当成库不存在)、 websitestat 负值转 uint64 污染流量统计、pty 终端尺寸超 uint16 截断、 文件权限位超 32 位静默截断、面板与 ACME challenge 服务器缺 ReadHeaderTimeout、 GetDefault 丢失操作人、三处对结构体值恒成立的假断言、两处带空格而失效的 nolint Co-Authored-By: Claude Opus 5 --- .github/workflows/build.yml | 2 +- .github/workflows/goreleaser.yml | 2 +- .github/workflows/l10n.yml | 2 +- .github/workflows/lint.yml | 22 +- .github/workflows/mockery.yml | 27 +- .github/workflows/test.yml | 9 +- .golangci.yml | 87 + .mockery.yaml | 4 +- AGENTS.md | 11 +- cmd/ace/main.go | 6 +- cmd/ace/wire.go | 18 +- cmd/ace/wire_gen.go | 898 ++++++--- cmd/cli/main.go | 6 +- cmd/cli/wire.go | 16 +- cmd/cli/wire_gen.go | 257 ++- go.mod | 15 +- go.sum | 22 +- internal/apps/confval/confval_test.go | 160 +- internal/apps/confval/toml_test.go | 70 +- internal/apps/memcached/app.go | 3 +- internal/apps/mysql/app.go | 4 + internal/apps/nginx/app.go | 1 - internal/apps/opensearch/app.go | 1 - internal/apps/pgadmin/app.go | 7 +- internal/apps/prometheus/app.go | 1 - internal/apps/pureftpd/app.go | 1 - internal/apps/rocketmq/app.go | 1 - internal/apps/rsync/app.go | 1 - internal/apps/s3fs/app.go | 1 - internal/apps/{apps.go => wire.go} | 84 +- internal/biz/alert.go | 2 +- internal/biz/backup.go | 4 +- internal/biz/backup_storage.go | 2 + internal/biz/biz.go | 18 - internal/biz/cert.go | 14 +- internal/biz/cert_account.go | 4 +- internal/biz/database.go | 17 +- internal/biz/database_server.go | 5 +- internal/biz/database_user.go | 2 +- internal/biz/file_share.go | 1 + internal/biz/notify.go | 2 + internal/biz/project.go | 2 +- internal/biz/setting.go | 4 +- internal/biz/tamper.go | 5 +- internal/biz/toolbox_migration_import.go | 8 +- internal/biz/website.go | 4 +- internal/biz/wire.go | 86 + internal/bootstrap/bootstrap.go | 29 - internal/bootstrap/cli.go | 1 - internal/bootstrap/db.go | 1 - internal/bootstrap/http.go | 10 +- internal/bootstrap/logger.go | 5 +- internal/bootstrap/t.go | 1 - internal/bootstrap/wire.go | 60 + internal/command/app.go | 1 - internal/command/backup.go | 1 - internal/command/cert.go | 1 - internal/command/command.go | 3 - internal/command/cron.go | 1 - internal/command/cutoff.go | 1 - internal/command/database.go | 1 - internal/command/entrance.go | 4 - internal/command/firewall.go | 1 - internal/command/https.go | 1 - internal/command/panel.go | 8 - internal/command/restore.go | 1 - internal/command/service.go | 4 - internal/command/setting.go | 1 - internal/command/user.go | 1 - internal/command/website.go | 1 - internal/command/wire.go | 13 + internal/data/app.go | 1 - internal/data/backup.go | 46 +- internal/data/cert_account.go | 10 +- internal/data/container.go | 6 +- internal/data/container_image.go | 2 +- internal/data/data.go | 20 - internal/data/database.go | 6 +- internal/data/database_server.go | 2 +- internal/data/database_user.go | 1 + internal/data/notify.go | 9 +- internal/data/project.go | 6 +- internal/data/scan_event.go | 2 +- internal/data/tamper.go | 1 - internal/data/toolbox_migration.go | 2 +- internal/data/toolbox_migration_archive.go | 2 +- internal/data/toolbox_migration_baota.go | 12 +- internal/data/toolbox_migration_onepanel.go | 4 +- internal/data/toolbox_migration_remote.go | 2 +- internal/data/webhook.go | 4 +- internal/data/website.go | 9 +- internal/data/website_stat.go | 8 +- internal/data/wire.go | 94 + internal/job/cert_renew.go | 10 +- internal/job/firewall_scan.go | 6 +- internal/job/job.go | 3 - internal/job/monitoring.go | 4 +- internal/job/panel_task.go | 10 +- internal/job/wire.go | 11 + internal/middleware/must_login.go | 4 +- internal/middleware/recoverer.go | 3 +- internal/mocks/biz/AlertRepo.go | 657 +++++++ internal/mocks/biz/AppRepo.go | 677 +++++++ internal/mocks/biz/BackupAccountRepo.go | 259 +++ internal/mocks/biz/BackupRepo.go | 707 +++++++ internal/mocks/biz/CacheRepo.go | 282 +++ internal/mocks/biz/CertAccountRepo.go | 453 +++++ internal/mocks/biz/CertDNSRepo.go | 260 +++ internal/mocks/biz/CertRepo.go | 900 +++++++++ internal/mocks/biz/ContainerComposeRepo.go | 365 ++++ internal/mocks/biz/ContainerImageRepo.go | 273 +++ internal/mocks/biz/ContainerNetworkRepo.go | 223 +++ internal/mocks/biz/ContainerRepo.go | 685 +++++++ internal/mocks/biz/ContainerVolumeRepo.go | 223 +++ internal/mocks/biz/CronRepo.go | 623 ++++++ .../mocks/biz/DatabaseElasticsearchRepo.go | 386 ++++ internal/mocks/biz/DatabaseRedisRepo.go | 436 +++++ internal/mocks/biz/DatabaseRepo.go | 229 +++ internal/mocks/biz/DatabaseServerRepo.go | 743 +++++++ internal/mocks/biz/DatabaseUserRepo.go | 517 +++++ internal/mocks/biz/EnvironmentRepo.go | 239 +++ internal/mocks/biz/FileShareRepo.go | 302 +++ internal/mocks/biz/LogRepo.go | 133 ++ internal/mocks/biz/MigrationArchiveRepo.go | 283 +++ internal/mocks/biz/MigrationRemoteRepo.go | 228 +++ internal/mocks/biz/MigrationSourceRepo.go | 378 ++++ internal/mocks/biz/MonitorRepo.go | 246 +++ internal/mocks/biz/NotifyChannelRepo.go | 340 ++++ internal/mocks/biz/ProjectRepo.go | 542 ++++++ internal/mocks/biz/SSHRepo.go | 435 +++++ internal/mocks/biz/SafeRepo.go | 151 ++ internal/mocks/biz/ScanEventRepo.go | 487 +++++ internal/mocks/biz/SettingRepo.go | 415 ++++ internal/mocks/biz/TamperRepo.go | 503 +++++ internal/mocks/biz/TaskRepo.go | 396 ++++ internal/mocks/biz/TemplateRepo.go | 172 ++ internal/mocks/biz/UserPasskeyRepo.go | 434 +++++ internal/mocks/biz/UserRepo.go | 609 ++++++ internal/mocks/biz/UserTokenRepo.go | 335 ++++ internal/mocks/biz/WebHookRepo.go | 404 ++++ internal/mocks/biz/WebsiteRepo.go | 887 +++++++++ internal/mocks/biz/WebsiteStatRepo.go | 1380 +++++++++++++ internal/route/route.go | 3 - internal/route/wire.go | 11 + internal/service/cert.go | 6 +- internal/service/cli.go | 10 +- internal/service/container_volume.go | 1 - internal/service/file.go | 13 +- internal/service/firewall.go | 2 + internal/service/service.go | 24 - internal/service/setting.go | 3 +- internal/service/tamper.go | 6 +- internal/service/toolbox_benchmark.go | 14 +- internal/service/toolbox_log.go | 22 +- internal/service/toolbox_migration.go | 7 +- internal/service/toolbox_system.go | 2 +- internal/service/user_passkey.go | 6 +- internal/service/wire.go | 122 ++ internal/service/ws.go | 55 +- internal/taskqueue/runner.go | 6 +- mocks/biz/AlertRepo.go | 887 --------- mocks/biz/AppRepo.go | 868 --------- mocks/biz/BackupAccountRepo.go | 335 ---- mocks/biz/BackupRepo.go | 837 -------- mocks/biz/CacheRepo.go | 399 ---- mocks/biz/CertAccountRepo.go | 601 ------ mocks/biz/CertDNSRepo.go | 347 ---- mocks/biz/CertRepo.go | 1162 ----------- mocks/biz/ContainerComposeRepo.go | 454 ----- mocks/biz/ContainerImageRepo.go | 340 ---- mocks/biz/ContainerNetworkRepo.go | 283 --- mocks/biz/ContainerRepo.go | 828 -------- mocks/biz/ContainerVolumeRepo.go | 283 --- mocks/biz/CronRepo.go | 779 -------- mocks/biz/DatabaseElasticsearchRepo.go | 487 ----- mocks/biz/DatabaseRedisRepo.go | 542 ------ mocks/biz/DatabaseRepo.go | 315 --- mocks/biz/DatabaseServerRepo.go | 932 --------- mocks/biz/DatabaseUserRepo.go | 660 ------- mocks/biz/EnvironmentRepo.go | 279 --- mocks/biz/FileShareRepo.go | 411 ---- mocks/biz/LogRepo.go | 182 -- mocks/biz/MigrationArchiveRepo.go | 349 ---- mocks/biz/MigrationRemoteRepo.go | 273 --- mocks/biz/MigrationSourceRepo.go | 475 ----- mocks/biz/MonitorRepo.go | 306 --- mocks/biz/NotifyChannelRepo.go | 452 ----- mocks/biz/ProjectRepo.go | 689 ------- mocks/biz/SSHRepo.go | 544 ------ mocks/biz/SafeRepo.go | 202 -- mocks/biz/ScanEventRepo.go | 624 ------ mocks/biz/SettingRepo.go | 569 ------ mocks/biz/TamperRepo.go | 644 ------ mocks/biz/TaskRepo.go | 493 ----- mocks/biz/TemplateRepo.go | 216 --- mocks/biz/UserPasskeyRepo.go | 558 ------ mocks/biz/UserRepo.go | 807 -------- mocks/biz/UserTokenRepo.go | 450 ----- mocks/biz/WebHookRepo.go | 521 ----- mocks/biz/WebsiteRepo.go | 1154 ----------- mocks/biz/WebsiteStatRepo.go | 1721 ----------------- pkg/acme/acme.go | 16 +- pkg/acme/client_test.go | 23 +- pkg/acme/solvers.go | 7 +- pkg/api/api_test.go | 73 +- pkg/apploader/apploader.go | 14 +- pkg/cert/cert.go | 12 +- pkg/cert/cert_test.go | 47 +- pkg/chattr/chattr.go | 2 +- pkg/db/clickhouse.go | 2 +- pkg/db/mysql.go | 16 +- pkg/db/postgres.go | 12 +- pkg/db/redis.go | 22 +- pkg/db/sqlite.go | 9 +- pkg/fastcgi/fastcgi.go | 19 +- pkg/firewall/firewall_test.go | 903 ++++----- pkg/firewall/firewalld.go | 6 +- pkg/firewall/scan/scanner_linux.go | 6 +- pkg/firewall/scan/scanner_linux_test.go | 4 +- pkg/firewall/ufw.go | 10 +- pkg/geoip/geoip_test.go | 81 +- pkg/io/compress.go | 3 +- pkg/io/io_test.go | 269 +-- pkg/io/path.go | 6 +- pkg/io/path_test.go | 60 +- pkg/io/search_test.go | 66 +- pkg/ipdb/reader.go | 2 +- pkg/ipdb/reader_test.go | 137 +- pkg/network/network_test.go | 24 +- pkg/notify/smtp.go | 2 +- pkg/ntp/ntp.go | 4 +- pkg/ntp/ntp_test.go | 46 +- pkg/ntp/system.go | 1 + pkg/os/os.go | 11 +- pkg/os/os_test.go | 18 +- pkg/rsacrypto/rsacrypto.go | 8 +- pkg/rsacrypto/rsacrypto_test.go | 38 +- pkg/shell/exec.go | 1 + pkg/shell/pty.go | 3 +- pkg/ssh/ssh.go | 2 +- pkg/ssh/turn.go | 6 +- pkg/storage/local.go | 4 +- pkg/storage/s3sdk/list.go | 5 +- pkg/storage/s3sdk/object.go | 14 +- pkg/storage/s3sdk/sign.go | 2 +- pkg/storage/s3sdk/upload.go | 30 +- pkg/storage/sftp.go | 2 +- pkg/systemctl/service.go | 4 +- pkg/tamper/detect_linux.go | 26 +- pkg/tamper/ebpf_linux.go | 9 +- pkg/tamper/manager_linux.go | 10 +- pkg/tamper/tamper_linux_test.go | 3 +- pkg/tamper/tamper_other.go | 3 +- pkg/tools/tools.go | 26 +- pkg/tools/tools_test.go | 77 +- pkg/webserver/apache/parser_test.go | 191 +- pkg/webserver/apache/robustness_test.go | 116 +- pkg/webserver/apache/vhost_test.go | 719 ++++--- pkg/webserver/caddy/parser.go | 3 +- pkg/webserver/caddy/parser_test.go | 135 +- pkg/webserver/caddy/validate_test.go | 176 +- pkg/webserver/caddy/vhost_test.go | 646 +++---- pkg/webserver/conf/conf_test.go | 52 +- pkg/webserver/nginx/export.go | 5 +- pkg/webserver/nginx/parser.go | 8 +- pkg/webserver/nginx/parser_test.go | 39 +- pkg/webserver/nginx/proxy.go | 4 +- pkg/webserver/nginx/redirect.go | 4 +- pkg/webserver/nginx/upstream.go | 4 +- pkg/webserver/nginx/vhost.go | 12 +- pkg/webserver/nginx/vhost_test.go | 678 ++++--- pkg/webserver/openlitespeed/dialect.go | 7 +- pkg/webserver/openlitespeed/parser.go | 3 +- pkg/webserver/openlitespeed/parser_test.go | 57 +- pkg/webserver/openlitespeed/redirect.go | 1 + pkg/webserver/openlitespeed/vhost.go | 3 +- pkg/webserver/openlitespeed/vhost_test.go | 460 +++-- pkg/websitestat/parser.go | 17 +- pkg/websitestat/parser_test.go | 46 +- 279 files changed, 22627 insertions(+), 27103 deletions(-) create mode 100644 .golangci.yml rename internal/apps/{apps.go => wire.go} (50%) delete mode 100644 internal/biz/biz.go create mode 100644 internal/biz/wire.go delete mode 100644 internal/bootstrap/bootstrap.go create mode 100644 internal/bootstrap/wire.go create mode 100644 internal/command/wire.go delete mode 100644 internal/data/data.go create mode 100644 internal/data/wire.go create mode 100644 internal/job/wire.go create mode 100644 internal/mocks/biz/AlertRepo.go create mode 100644 internal/mocks/biz/AppRepo.go create mode 100644 internal/mocks/biz/BackupAccountRepo.go create mode 100644 internal/mocks/biz/BackupRepo.go create mode 100644 internal/mocks/biz/CacheRepo.go create mode 100644 internal/mocks/biz/CertAccountRepo.go create mode 100644 internal/mocks/biz/CertDNSRepo.go create mode 100644 internal/mocks/biz/CertRepo.go create mode 100644 internal/mocks/biz/ContainerComposeRepo.go create mode 100644 internal/mocks/biz/ContainerImageRepo.go create mode 100644 internal/mocks/biz/ContainerNetworkRepo.go create mode 100644 internal/mocks/biz/ContainerRepo.go create mode 100644 internal/mocks/biz/ContainerVolumeRepo.go create mode 100644 internal/mocks/biz/CronRepo.go create mode 100644 internal/mocks/biz/DatabaseElasticsearchRepo.go create mode 100644 internal/mocks/biz/DatabaseRedisRepo.go create mode 100644 internal/mocks/biz/DatabaseRepo.go create mode 100644 internal/mocks/biz/DatabaseServerRepo.go create mode 100644 internal/mocks/biz/DatabaseUserRepo.go create mode 100644 internal/mocks/biz/EnvironmentRepo.go create mode 100644 internal/mocks/biz/FileShareRepo.go create mode 100644 internal/mocks/biz/LogRepo.go create mode 100644 internal/mocks/biz/MigrationArchiveRepo.go create mode 100644 internal/mocks/biz/MigrationRemoteRepo.go create mode 100644 internal/mocks/biz/MigrationSourceRepo.go create mode 100644 internal/mocks/biz/MonitorRepo.go create mode 100644 internal/mocks/biz/NotifyChannelRepo.go create mode 100644 internal/mocks/biz/ProjectRepo.go create mode 100644 internal/mocks/biz/SSHRepo.go create mode 100644 internal/mocks/biz/SafeRepo.go create mode 100644 internal/mocks/biz/ScanEventRepo.go create mode 100644 internal/mocks/biz/SettingRepo.go create mode 100644 internal/mocks/biz/TamperRepo.go create mode 100644 internal/mocks/biz/TaskRepo.go create mode 100644 internal/mocks/biz/TemplateRepo.go create mode 100644 internal/mocks/biz/UserPasskeyRepo.go create mode 100644 internal/mocks/biz/UserRepo.go create mode 100644 internal/mocks/biz/UserTokenRepo.go create mode 100644 internal/mocks/biz/WebHookRepo.go create mode 100644 internal/mocks/biz/WebsiteRepo.go create mode 100644 internal/mocks/biz/WebsiteStatRepo.go create mode 100644 internal/route/wire.go delete mode 100644 internal/service/service.go create mode 100644 internal/service/wire.go delete mode 100644 mocks/biz/AlertRepo.go delete mode 100644 mocks/biz/AppRepo.go delete mode 100644 mocks/biz/BackupAccountRepo.go delete mode 100644 mocks/biz/BackupRepo.go delete mode 100644 mocks/biz/CacheRepo.go delete mode 100644 mocks/biz/CertAccountRepo.go delete mode 100644 mocks/biz/CertDNSRepo.go delete mode 100644 mocks/biz/CertRepo.go delete mode 100644 mocks/biz/ContainerComposeRepo.go delete mode 100644 mocks/biz/ContainerImageRepo.go delete mode 100644 mocks/biz/ContainerNetworkRepo.go delete mode 100644 mocks/biz/ContainerRepo.go delete mode 100644 mocks/biz/ContainerVolumeRepo.go delete mode 100644 mocks/biz/CronRepo.go delete mode 100644 mocks/biz/DatabaseElasticsearchRepo.go delete mode 100644 mocks/biz/DatabaseRedisRepo.go delete mode 100644 mocks/biz/DatabaseRepo.go delete mode 100644 mocks/biz/DatabaseServerRepo.go delete mode 100644 mocks/biz/DatabaseUserRepo.go delete mode 100644 mocks/biz/EnvironmentRepo.go delete mode 100644 mocks/biz/FileShareRepo.go delete mode 100644 mocks/biz/LogRepo.go delete mode 100644 mocks/biz/MigrationArchiveRepo.go delete mode 100644 mocks/biz/MigrationRemoteRepo.go delete mode 100644 mocks/biz/MigrationSourceRepo.go delete mode 100644 mocks/biz/MonitorRepo.go delete mode 100644 mocks/biz/NotifyChannelRepo.go delete mode 100644 mocks/biz/ProjectRepo.go delete mode 100644 mocks/biz/SSHRepo.go delete mode 100644 mocks/biz/SafeRepo.go delete mode 100644 mocks/biz/ScanEventRepo.go delete mode 100644 mocks/biz/SettingRepo.go delete mode 100644 mocks/biz/TamperRepo.go delete mode 100644 mocks/biz/TaskRepo.go delete mode 100644 mocks/biz/TemplateRepo.go delete mode 100644 mocks/biz/UserPasskeyRepo.go delete mode 100644 mocks/biz/UserRepo.go delete mode 100644 mocks/biz/UserTokenRepo.go delete mode 100644 mocks/biz/WebHookRepo.go delete mode 100644 mocks/biz/WebsiteRepo.go delete mode 100644 mocks/biz/WebsiteStatRepo.go diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 978fb7070..d74a30746 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,7 @@ jobs: uses: actions/setup-go@v7 with: cache: true - go-version: 'stable' + go-version-file: go.mod - name: Install dependencies run: go mod tidy - name: Download frontend diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 8d265f644..daf15374f 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -17,7 +17,7 @@ jobs: uses: actions/setup-go@v7 with: cache: true - go-version: 'stable' + go-version-file: go.mod - name: Setup pnpm uses: pnpm/action-setup@v6 with: diff --git a/.github/workflows/l10n.yml b/.github/workflows/l10n.yml index 0b2ea6255..a8507eedc 100644 --- a/.github/workflows/l10n.yml +++ b/.github/workflows/l10n.yml @@ -29,7 +29,7 @@ jobs: uses: actions/setup-go@v7 with: cache: true - go-version: 'stable' + go-version-file: go.mod - name: Install gettext run: | sudo apt-get install -y gettext diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 83e0a7912..4728ea9da 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,7 +8,7 @@ permissions: contents: read jobs: golangci: - name: golanci-lint + name: golangci-lint runs-on: ubuntu-latest steps: - name: Checkout @@ -17,31 +17,19 @@ jobs: uses: actions/setup-go@v7 with: cache: true - go-version: 'stable' - - name: Check Wire generated code - run: | - go generate ./cmd/ace ./cmd/cli - git diff --exit-code -- cmd/ace/wire_gen.go cmd/cli/wire_gen.go + go-version-file: go.mod - name: Run golangci-lint uses: golangci/golangci-lint-action@v9 with: - skip-cache: true version: latest args: --timeout=30m ./... govulncheck: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v7 - - name: Setup Go - uses: actions/setup-go@v7 - with: - cache: true - go-version: 'stable' - - name: Install Govulncheck - run: go install golang.org/x/vuln/cmd/govulncheck@latest - name: Run Govulncheck - run: govulncheck ./... + uses: golang/govulncheck-action@v1 + with: + go-version-file: go.mod frontend: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/mockery.yml b/.github/workflows/mockery.yml index 5c4d29f57..b22bbda7e 100644 --- a/.github/workflows/mockery.yml +++ b/.github/workflows/mockery.yml @@ -3,11 +3,9 @@ on: push: branches: - main -concurrency: - group: codegen - cancel-in-progress: false + pull_request: permissions: - contents: write + contents: read jobs: mockery: runs-on: ubuntu-latest @@ -18,19 +16,10 @@ jobs: uses: actions/setup-go@v7 with: cache: true - go-version: 'stable' - - name: Install Mockery + go-version-file: go.mod + - name: Generate Mocks + run: go run github.com/vektra/mockery/v3@v3.8.0 + - name: Verify mocks are up to date run: | - go install github.com/vektra/mockery/v3@latest - - name: Generate mocks and commit - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - ~/go/bin/mockery - if [ -z "$(git status --porcelain)" ]; then - echo "mock 无变更,跳过提交" - exit 0 - fi - git add -A - git commit -m "chore: update mocks" - git push origin HEAD:main + git add -N . + git diff --exit-code diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5be925b9a..8d6aa57e3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,17 +16,16 @@ jobs: uses: actions/setup-go@v7 with: cache: true - go-version: 'stable' + go-version-file: go.mod - name: Install dependencies run: sudo apt-get install -y curl jq - # https://github.com/golang/go/issues/75031 - - name: Set toolchain version - run: go env -w GOTOOLCHAIN=go1.25.1+auto - name: Set up environment run: | cp config.example.yml config.yml + - name: Verify dependency injection + run: go tool wire check ./... - name: Run tests - run: sudo go test -v -coverprofile="coverage.out" ./... + run: sudo go test -v -race -coverprofile="coverage.out" ./... - name: Upload coverage report to Codecov uses: codecov/codecov-action@v7 with: diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 000000000..1ede282b0 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,87 @@ +version: "2" + +# 大量代码带 linux 构建约束,golangci-lint 只分析当前 GOOS,本地需 GOOS=linux 才能复现 CI 结果 + +linters: + # 标准集之外只开能抓真实缺陷的低噪声 linter,纯风格偏好类不开 + default: standard + enable: + # bugs and correctness + - asasalint + - bidichk + - bodyclose + - contextcheck + - copyloopvar + - durationcheck + - errchkjson + - errorlint + - exhaustive + - fatcontext + - forcetypeassert + - gocheckcompilerdirectives + - gosec + - loggercheck + - makezero + - nilerr + - nilnesserr + - noctx + - reassign + - recvcheck + - rowserrcheck + - sqlclosecheck + - unparam + # simplification and consistency + - dupword + - exptostd + - goconst + - gocritic + - intrange + - mirror + - misspell + - nakedret + - nolintlint + - nosprintfhostport + - perfsprint + - predeclared + - sloglint + - unconvert + - usestdlibvars + - usetesting + - whitespace + # tests + - thelper + - tparallel + settings: + exhaustive: + default-signifies-exhaustive: true + goconst: + # 只报重复的数字;字符串在测试和提示语里天然重复 + ignore-string-values: + - '.+' + gosec: + # 面板以 root 代管整机,执行外部命令与任意路径读写是本职工作,这几类整类不适用(见 AGENTS.md) + excludes: + - G204 # 执行外部命令 + - G301 # 创建目录的权限 + - G302 # 打开文件的权限 + - G304 # 用变量拼路径读文件 + - G306 # 写文件的权限 + - G702 # 命令注入的污点分析 + - G703 # 路径遍历 + # proxy_pass、token 目录这类领域词撞上凭据名正则,误报远多于命中 + - G101 # 硬编码凭据 + exclusions: + generated: lax + paths: + # mockery 输出目录 + - internal/mocks + rules: + # 处理器测试里 httptest.NewRequest 不带 context 是惯例 + - path: _test\.go + linters: + - noctx + +issues: + # 默认同类截断 3 条、单 linter 截断 50 条,会让人以为修完可见的就干净了 + max-same-issues: 0 + max-issues-per-linter: 0 diff --git a/.mockery.yaml b/.mockery.yaml index 8f05b3e2d..f85cdc5c2 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -1,5 +1,5 @@ -template: testify -dir: mocks/biz +template: matryer +dir: internal/mocks/{{.InterfaceDirRelative | trimPrefix "internal/"}} structname: "{{.InterfaceName}}" pkgname: "{{.SrcPackageName}}" filename: "{{.InterfaceName}}.go" diff --git a/AGENTS.md b/AGENTS.md index c5dd353ad..cbf8b2461 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -88,13 +88,16 @@ pnpm build - 封装数据库、缓存等操作 - 处理数据持久化逻辑 -- **`internal/http/`**: HTTP 相关 - - `middleware/`: 自定义中间件 - - `request/`: 请求结构体定义 - - `rule/`: 自定义验证规则 +- **`internal/middleware/`**: 自定义中间件 + +- **`internal/request/`**: 请求结构体定义 + +- **`internal/rule/`**: 自定义验证规则 - **`internal/apps/`**: 面板子应用实现 +- **`internal/mocks/`**: mockery 生成的 biz 接口 mock,改接口后跑 `go run github.com/vektra/mockery/v3@v3.8.0` 重新生成 + - **`internal/bootstrap/`**: 各模块启动引导 - **`internal/migration/`**: 数据库迁移 diff --git a/cmd/ace/main.go b/cmd/ace/main.go index 8ad09dc4e..c06f4675e 100644 --- a/cmd/ace/main.go +++ b/cmd/ace/main.go @@ -1,3 +1,5 @@ +//go:generate go tool wire generate . + package main import ( @@ -26,9 +28,7 @@ func run() error { if err != nil { return err } - if cleanup != nil { - defer cleanup() - } + defer func() { _ = cleanup() }() return ace.Run() } diff --git a/cmd/ace/wire.go b/cmd/ace/wire.go index dc07a51e1..060a1eda5 100644 --- a/cmd/ace/wire.go +++ b/cmd/ace/wire.go @@ -3,7 +3,7 @@ package main import ( - "github.com/google/wire" + "github.com/libtnb/wire" "github.com/acepanel/panel/v3/internal/app" "github.com/acepanel/panel/v3/internal/apps" @@ -15,15 +15,7 @@ import ( "github.com/acepanel/panel/v3/internal/service" ) -func initAce() (*app.Ace, func(), error) { - panic(wire.Build( - bootstrap.ProviderSet, - apps.ProviderSet, - biz.ProviderSet, - data.ProviderSet, - service.ProviderSet, - route.ProviderSet, - job.ProviderSet, - app.NewAce, - )) -} +var initAce = wire.New(). + Include(bootstrap.Module, apps.Module, biz.Module, data.Module, service.Module, route.Module, job.Module). + Provide(app.NewAce). + Injector[func() (*app.Ace, func() error, error)]() diff --git a/cmd/ace/wire_gen.go b/cmd/ace/wire_gen.go index 185926acd..7cc1c9363 100644 --- a/cmd/ace/wire_gen.go +++ b/cmd/ace/wire_gen.go @@ -1,12 +1,12 @@ -// Code generated by Wire. DO NOT EDIT. - -//go:generate go run -mod=mod github.com/google/wire/cmd/wire +// Code generated by wire. DO NOT EDIT. //go:build !wireinject -// +build !wireinject package main import ( + "errors" + "sync" + "github.com/acepanel/panel/v3/internal/app" "github.com/acepanel/panel/v3/internal/apps/apache" "github.com/acepanel/panel/v3/internal/apps/caddy" @@ -51,330 +51,602 @@ import ( "github.com/acepanel/panel/v3/pkg/websitestat" ) -import ( - _ "time/tzdata" -) +func initAce() (*app.Ace, func() error, error) { + var wireZero0 *app.Ace -// Injectors from wire.go: + wireCleanup := &wireLifecycle{} + wireCommitted := false + defer wireRollbackOnPanic(&wireCommitted, wireCleanup.close) -func initAce() (*app.Ace, func(), error) { - config, err := bootstrap.NewConf() - if err != nil { - return nil, nil, err + wireValue0_0, wireErr0 := bootstrap.NewConf() + if wireErr0 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr0, cleanupErr) } - locale := bootstrap.NewT(config) - apacheApp := apache.NewApp(locale) - caddyApp := caddy.NewApp(locale) - db, err := bootstrap.NewDB(config) - if err != nil { - return nil, nil, err + + wireValue1_0 := bootstrap.NewT(wireValue0_0) + + wireValue17_0 := apache.NewApp(wireValue1_0) + + wireValue18_0 := caddy.NewApp(wireValue1_0) + + wireValue4_0, wireErr4 := bootstrap.NewDB(wireValue0_0) + if wireErr4 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr4, cleanupErr) } - databaseServerRepo := data.NewDatabaseServerRepo(db) - settingRepo := data.NewSettingRepo(config, db) - clickhouseApp := clickhouse.NewApp(locale, databaseServerRepo, settingRepo) - codeserverApp := codeserver.NewApp() - dockerApp := docker.NewApp() - elasticsearchApp := elasticsearch.NewApp(locale) - websiteRepo := data.NewWebsiteRepo(db, locale, settingRepo) - fail2banApp := fail2ban.NewApp(locale, websiteRepo) - frpApp := frp.NewApp(locale) - giteaApp := gitea.NewApp() - grafanaApp := grafana.NewApp(locale) - kafkaApp := kafka.NewApp(locale) - logger, cleanup, err := bootstrap.NewLogger(config) - if err != nil { - return nil, nil, err + + wireValue106_0 := data.NewDatabaseServerRepo(wireValue4_0) + + wireValue116_0 := data.NewSettingRepo(wireValue0_0, wireValue4_0) + + wireValue19_0 := clickhouse.NewApp(wireValue1_0, wireValue106_0, wireValue116_0) + + wireValue20_0 := codeserver.NewApp() + + wireValue21_0 := docker.NewApp() + + wireValue22_0 := elasticsearch.NewApp(wireValue1_0) + + wireValue125_0 := data.NewWebsiteRepo(wireValue4_0, wireValue1_0, wireValue116_0) + + wireValue23_0 := fail2ban.NewApp(wireValue1_0, wireValue125_0) + + wireValue24_0 := frp.NewApp(wireValue1_0) + + wireValue25_0 := gitea.NewApp() + + wireValue26_0 := grafana.NewApp(wireValue1_0) + + wireValue27_0 := kafka.NewApp(wireValue1_0) + + wireValue2_0, wireResourceCleanup2, wireErr2 := bootstrap.NewLogger(wireValue0_0) + if wireErr2 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr2, cleanupErr) } - slogLogger := bootstrap.NewSlog(logger) - notifyChannelRepo := data.NewNotifyChannelRepo(db) - notifyUsecase := biz.NewNotifyUsecase(locale, slogLogger, notifyChannelRepo, settingRepo) - taskRunner := bootstrap.NewRunner(notifyUsecase, db, locale, slogLogger) - taskRepo := data.NewTaskRepo(db, locale, slogLogger, taskRunner) - mysqlApp := mysql.NewApp(locale, databaseServerRepo, settingRepo, taskRepo) - mariadbApp := mariadb.NewApp(mysqlApp) - memcachedApp := memcached.NewApp(locale) - minioApp := minio.NewApp() - mongodbApp := mongodb.NewApp(locale, databaseServerRepo, settingRepo) - nginxApp := nginx.NewApp(locale) - openlitespeedApp := openlitespeed.NewApp(locale) - openrestyApp := openresty.NewApp(nginxApp) - opensearchApp := opensearch.NewApp(locale) - perconaApp := percona.NewApp(mysqlApp) - pgadminApp := pgadmin.NewApp(config, locale, databaseServerRepo) - phpmyadminApp := phpmyadmin.NewApp(config, locale, databaseServerRepo, settingRepo) - podmanApp := podman.NewApp() - postgresqlApp := postgresql.NewApp(locale, config, databaseServerRepo, settingRepo, taskRepo) - prometheusApp := prometheus.NewApp(config, locale, taskRepo) - pureftpdApp := pureftpd.NewApp(locale) - redisApp := redis.NewApp(locale, databaseServerRepo, taskRepo) - rocketmqApp := rocketmq.NewApp(locale) - rsyncApp := rsync.NewApp(locale) - s3fsApp := s3fs.NewApp(locale) - supervisorApp := supervisor.NewApp(locale) - valkeyApp := valkey.NewApp(locale, databaseServerRepo, taskRepo) - loader := bootstrap.NewLoader(apacheApp, caddyApp, clickhouseApp, codeserverApp, dockerApp, elasticsearchApp, fail2banApp, frpApp, giteaApp, grafanaApp, kafkaApp, mariadbApp, memcachedApp, minioApp, mongodbApp, mysqlApp, nginxApp, openlitespeedApp, openrestyApp, opensearchApp, perconaApp, pgadminApp, phpmyadminApp, podmanApp, postgresqlApp, prometheusApp, pureftpdApp, redisApp, rocketmqApp, rsyncApp, s3fsApp, supervisorApp, valkeyApp) - manager, err := bootstrap.NewSession(config, db, slogLogger) - if err != nil { - cleanup() - return nil, nil, err + wireCleanup.arm(wireResourceCleanup2) + + wireValue3_0 := bootstrap.NewSlog(wireValue2_0) + + wireValue112_0 := data.NewNotifyChannelRepo(wireValue4_0) + + wireValue73_0 := biz.NewNotifyUsecase(wireValue1_0, wireValue3_0, wireValue112_0, wireValue116_0) + + wireValue7_0 := bootstrap.NewRunner(wireValue73_0, wireValue4_0, wireValue1_0, wireValue3_0) + + wireValue119_0 := data.NewTaskRepo(wireValue4_0, wireValue1_0, wireValue3_0, wireValue7_0) + + wireValue32_0 := mysql.NewApp(wireValue1_0, wireValue106_0, wireValue116_0, wireValue119_0) + + wireValue28_0 := mariadb.NewApp(wireValue32_0) + + wireValue29_0 := memcached.NewApp(wireValue1_0) + + wireValue30_0 := minio.NewApp() + + wireValue31_0 := mongodb.NewApp(wireValue1_0, wireValue106_0, wireValue116_0) + + wireValue33_0 := nginx.NewApp(wireValue1_0) + + wireValue34_0 := openlitespeed.NewApp(wireValue1_0) + + wireValue35_0 := openresty.NewApp(wireValue33_0) + + wireValue36_0 := opensearch.NewApp(wireValue1_0) + + wireValue37_0 := percona.NewApp(wireValue32_0) + + wireValue38_0 := pgadmin.NewApp(wireValue0_0, wireValue1_0, wireValue106_0) + + wireValue39_0 := phpmyadmin.NewApp(wireValue0_0, wireValue1_0, wireValue106_0, wireValue116_0) + + wireValue40_0 := podman.NewApp() + + wireValue41_0 := postgresql.NewApp(wireValue1_0, wireValue0_0, wireValue106_0, wireValue116_0, wireValue119_0) + + wireValue42_0 := prometheus.NewApp(wireValue0_0, wireValue1_0, wireValue119_0) + + wireValue43_0 := pureftpd.NewApp(wireValue1_0) + + wireValue44_0 := redis.NewApp(wireValue1_0, wireValue106_0, wireValue119_0) + + wireValue45_0 := rocketmq.NewApp(wireValue1_0) + + wireValue46_0 := rsync.NewApp(wireValue1_0) + + wireValue47_0 := s3fs.NewApp(wireValue1_0) + + wireValue48_0 := supervisor.NewApp(wireValue1_0) + + wireValue49_0 := valkey.NewApp(wireValue1_0, wireValue106_0, wireValue119_0) + + wireValue10_0 := bootstrap.NewLoader(wireValue17_0, wireValue18_0, wireValue19_0, wireValue20_0, wireValue21_0, wireValue22_0, wireValue23_0, wireValue24_0, wireValue25_0, wireValue26_0, wireValue27_0, wireValue28_0, wireValue29_0, wireValue30_0, wireValue31_0, wireValue32_0, wireValue33_0, wireValue34_0, wireValue35_0, wireValue36_0, wireValue37_0, wireValue38_0, wireValue39_0, wireValue40_0, wireValue41_0, wireValue42_0, wireValue43_0, wireValue44_0, wireValue45_0, wireValue46_0, wireValue47_0, wireValue48_0, wireValue49_0) + + wireValue6_0, wireErr6 := bootstrap.NewSession(wireValue0_0, wireValue4_0, wireValue3_0) + if wireErr6 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr6, cleanupErr) } - appRepo := data.NewAppRepo(config, db, locale, slogLogger) - userTokenRepo := data.NewUserTokenRepo(config, db, locale) - middlewares, err := middleware.NewMiddlewares(config, locale, manager, appRepo, userTokenRepo) - if err != nil { - cleanup() - return nil, nil, err + + wireValue90_0 := data.NewAppRepo(wireValue0_0, wireValue4_0, wireValue1_0, wireValue3_0) + + wireValue123_0 := data.NewUserTokenRepo(wireValue0_0, wireValue4_0, wireValue1_0) + + wireValue9_0, wireErr9 := middleware.NewMiddlewares(wireValue0_0, wireValue1_0, wireValue6_0, wireValue90_0, wireValue123_0) + if wireErr9 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr9, cleanupErr) } - validator := bootstrap.NewValidator(config, db, locale) - alertRepo, err := data.NewAlertRepo(db) - if err != nil { - cleanup() - return nil, nil, err + + wireValue8_0 := bootstrap.NewValidator(wireValue0_0, wireValue4_0, wireValue1_0) + + wireValue89_0, wireErr89 := data.NewAlertRepo(wireValue4_0) + if wireErr89 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr89, cleanupErr) } - containerRepo := data.NewContainerRepo() - alertUsecase := biz.NewAlertUsecase(notifyUsecase, loader, locale, slogLogger, alertRepo, appRepo, containerRepo, databaseServerRepo, settingRepo) - alertService := service.NewAlertService(alertUsecase) - cacheRepo := data.NewCacheRepo(db) - appUsecase := biz.NewAppUsecase(locale, appRepo, cacheRepo, taskRepo) - cacheUsecase := biz.NewCacheUsecase(cacheRepo) - settingUsecase := biz.NewSettingUsecase(locale, slogLogger, settingRepo, taskRepo) - appService := service.NewAppService(loader, appUsecase, cacheUsecase, settingUsecase, locale) - backupRepo := data.NewBackupRepo(config, db, locale, slogLogger, settingRepo, websiteRepo) - backupUsecase := biz.NewBackupUsecase(notifyUsecase, locale, slogLogger, backupRepo) - taskUsecase := biz.NewTaskUsecase(taskRepo) - backupService := service.NewBackupService(backupUsecase, taskUsecase, locale) - backupAccountRepo := data.NewBackupAccountRepo(db) - backupAccountUsecase := biz.NewBackupAccountUsecase(locale, slogLogger, backupAccountRepo, settingRepo) - backupStorageService := service.NewBackupStorageService(backupAccountUsecase, locale) - certRepo := data.NewCertRepo(db, locale, slogLogger) - certUsecase := biz.NewCertUsecase(locale, slogLogger, certRepo, settingRepo) - certService := service.NewCertService(certUsecase, locale) - certAccountRepo := data.NewCertAccountRepo(db, locale, slogLogger) - userRepo := data.NewUserRepo(db, locale) - certAccountUsecase := biz.NewCertAccountUsecase(locale, slogLogger, certAccountRepo, userRepo) - certAccountService := service.NewCertAccountService(certAccountUsecase) - certDNSRepo := data.NewCertDNSRepo(db) - certDNSUsecase := biz.NewCertDNSUsecase(certDNSRepo, slogLogger) - certDNSService := service.NewCertDNSService(certDNSUsecase) - containerUsecase := biz.NewContainerUsecase(locale, containerRepo, settingRepo, taskRepo) - containerService := service.NewContainerService(containerUsecase) - containerComposeRepo := data.NewContainerComposeRepo() - containerComposeUsecase := biz.NewContainerComposeUsecase(containerComposeRepo) - containerComposeService := service.NewContainerComposeService(containerComposeUsecase) - containerImageRepo := data.NewContainerImageRepo() - containerImageUsecase := biz.NewContainerImageUsecase(locale, containerImageRepo, settingRepo, taskRepo) - containerImageService := service.NewContainerImageService(containerImageUsecase) - containerNetworkRepo := data.NewContainerNetworkRepo() - containerNetworkUsecase := biz.NewContainerNetworkUsecase(containerNetworkRepo, settingRepo) - containerNetworkService := service.NewContainerNetworkService(containerNetworkUsecase) - containerVolumeRepo := data.NewContainerVolumeRepo() - containerVolumeUsecase := biz.NewContainerVolumeUsecase(containerVolumeRepo, settingRepo) - containerVolumeService := service.NewContainerVolumeService(containerVolumeUsecase) - cronRepo := data.NewCronRepo(db, locale) - cronUsecase := biz.NewCronUsecase(cronRepo, slogLogger) - cronService := service.NewCronService(cronUsecase) - databaseUserRepo := data.NewDatabaseUserRepo(db) - databaseUserUsecase := biz.NewDatabaseUserUsecase(slogLogger, databaseServerRepo, databaseUserRepo) - databaseRepo := data.NewDatabaseRepo(db) - databaseUsecase := biz.NewDatabaseUsecase(databaseUserUsecase, locale, slogLogger, databaseRepo, databaseServerRepo) - databaseService := service.NewDatabaseService(databaseUsecase) - databaseElasticsearchRepo := data.NewDatabaseElasticsearchRepo(db, locale, slogLogger) - databaseElasticsearchUsecase := biz.NewDatabaseElasticsearchUsecase(databaseElasticsearchRepo) - databaseElasticsearchService := service.NewDatabaseElasticsearchService(databaseElasticsearchUsecase) - databaseRedisRepo := data.NewDatabaseRedisRepo(db, locale, slogLogger) - databaseRedisUsecase := biz.NewDatabaseRedisUsecase(databaseRedisRepo) - databaseRedisService := service.NewDatabaseRedisService(databaseRedisUsecase) - databaseServerUsecase := biz.NewDatabaseServerUsecase(locale, slogLogger, databaseServerRepo) - databaseServerService := service.NewDatabaseServerService(databaseServerUsecase) - databaseUserService := service.NewDatabaseUserService(databaseUserUsecase) - environmentRepo := data.NewEnvironmentRepo(config, locale) - environmentUsecase := biz.NewEnvironmentUsecase(locale, cacheRepo, environmentRepo, taskRepo) - environmentService := service.NewEnvironmentService(environmentUsecase, taskUsecase, locale) - environmentDotnetService := service.NewEnvironmentDotnetService(environmentUsecase, locale) - environmentGoService := service.NewEnvironmentGoService(environmentUsecase, locale) - environmentJavaService := service.NewEnvironmentJavaService(environmentUsecase, locale) - environmentNodejsService := service.NewEnvironmentNodejsService(environmentUsecase, locale) - environmentPHPService := service.NewEnvironmentPHPService(environmentUsecase, taskUsecase, config, locale) - environmentPythonService := service.NewEnvironmentPythonService(environmentUsecase, locale) - tamperRepo, err := data.NewTamperRepo(db) - if err != nil { - cleanup() - return nil, nil, err + + wireValue97_0 := data.NewContainerRepo() + + wireValue50_0 := biz.NewAlertUsecase(wireValue73_0, wireValue10_0, wireValue1_0, wireValue3_0, wireValue89_0, wireValue90_0, wireValue97_0, wireValue106_0, wireValue116_0) + + wireValue130_0 := service.NewAlertService(wireValue50_0) + + wireValue93_0 := data.NewCacheRepo(wireValue4_0) + + wireValue51_0 := biz.NewAppUsecase(wireValue1_0, wireValue90_0, wireValue93_0, wireValue119_0) + + wireValue54_0 := biz.NewCacheUsecase(wireValue93_0) + + wireValue77_0 := biz.NewSettingUsecase(wireValue1_0, wireValue3_0, wireValue116_0, wireValue119_0) + + wireValue131_0 := service.NewAppService(wireValue10_0, wireValue51_0, wireValue54_0, wireValue77_0, wireValue1_0) + + wireValue91_0 := data.NewBackupRepo(wireValue0_0, wireValue4_0, wireValue1_0, wireValue3_0, wireValue116_0, wireValue125_0) + + wireValue52_0 := biz.NewBackupUsecase(wireValue73_0, wireValue1_0, wireValue3_0, wireValue91_0) + + wireValue80_0 := biz.NewTaskUsecase(wireValue119_0) + + wireValue132_0 := service.NewBackupService(wireValue52_0, wireValue80_0, wireValue1_0) + + wireValue92_0 := data.NewBackupAccountRepo(wireValue4_0) + + wireValue53_0 := biz.NewBackupAccountUsecase(wireValue1_0, wireValue3_0, wireValue92_0, wireValue116_0) + + wireValue133_0 := service.NewBackupStorageService(wireValue53_0, wireValue1_0) + + wireValue94_0 := data.NewCertRepo(wireValue4_0, wireValue1_0, wireValue3_0) + + wireValue55_0 := biz.NewCertUsecase(wireValue1_0, wireValue3_0, wireValue94_0, wireValue116_0) + + wireValue134_0 := service.NewCertService(wireValue55_0, wireValue1_0) + + wireValue95_0 := data.NewCertAccountRepo(wireValue4_0, wireValue1_0, wireValue3_0) + + wireValue121_0 := data.NewUserRepo(wireValue4_0, wireValue1_0) + + wireValue56_0 := biz.NewCertAccountUsecase(wireValue1_0, wireValue3_0, wireValue95_0, wireValue121_0) + + wireValue135_0 := service.NewCertAccountService(wireValue56_0) + + wireValue96_0 := data.NewCertDNSRepo(wireValue4_0) + + wireValue57_0 := biz.NewCertDNSUsecase(wireValue96_0, wireValue3_0) + + wireValue136_0 := service.NewCertDNSService(wireValue57_0) + + wireValue58_0 := biz.NewContainerUsecase(wireValue1_0, wireValue97_0, wireValue116_0, wireValue119_0) + + wireValue138_0 := service.NewContainerService(wireValue58_0) + + wireValue98_0 := data.NewContainerComposeRepo() + + wireValue59_0 := biz.NewContainerComposeUsecase(wireValue98_0) + + wireValue139_0 := service.NewContainerComposeService(wireValue59_0) + + wireValue99_0 := data.NewContainerImageRepo() + + wireValue60_0 := biz.NewContainerImageUsecase(wireValue1_0, wireValue99_0, wireValue116_0, wireValue119_0) + + wireValue140_0 := service.NewContainerImageService(wireValue60_0) + + wireValue100_0 := data.NewContainerNetworkRepo() + + wireValue61_0 := biz.NewContainerNetworkUsecase(wireValue100_0, wireValue116_0) + + wireValue141_0 := service.NewContainerNetworkService(wireValue61_0) + + wireValue101_0 := data.NewContainerVolumeRepo() + + wireValue62_0 := biz.NewContainerVolumeUsecase(wireValue101_0, wireValue116_0) + + wireValue142_0 := service.NewContainerVolumeService(wireValue62_0) + + wireValue102_0 := data.NewCronRepo(wireValue4_0, wireValue1_0) + + wireValue63_0 := biz.NewCronUsecase(wireValue102_0, wireValue3_0) + + wireValue143_0 := service.NewCronService(wireValue63_0) + + wireValue107_0 := data.NewDatabaseUserRepo(wireValue4_0) + + wireValue68_0 := biz.NewDatabaseUserUsecase(wireValue3_0, wireValue106_0, wireValue107_0) + + wireValue103_0 := data.NewDatabaseRepo(wireValue4_0) + + wireValue64_0 := biz.NewDatabaseUsecase(wireValue68_0, wireValue1_0, wireValue3_0, wireValue103_0, wireValue106_0) + + wireValue144_0 := service.NewDatabaseService(wireValue64_0) + + wireValue105_0 := data.NewDatabaseElasticsearchRepo(wireValue4_0, wireValue1_0, wireValue3_0) + + wireValue66_0 := biz.NewDatabaseElasticsearchUsecase(wireValue105_0) + + wireValue146_0 := service.NewDatabaseElasticsearchService(wireValue66_0) + + wireValue104_0 := data.NewDatabaseRedisRepo(wireValue4_0, wireValue1_0, wireValue3_0) + + wireValue65_0 := biz.NewDatabaseRedisUsecase(wireValue104_0) + + wireValue145_0 := service.NewDatabaseRedisService(wireValue65_0) + + wireValue67_0 := biz.NewDatabaseServerUsecase(wireValue1_0, wireValue3_0, wireValue106_0) + + wireValue147_0 := service.NewDatabaseServerService(wireValue67_0) + + wireValue148_0 := service.NewDatabaseUserService(wireValue68_0) + + wireValue108_0 := data.NewEnvironmentRepo(wireValue0_0, wireValue1_0) + + wireValue69_0 := biz.NewEnvironmentUsecase(wireValue1_0, wireValue93_0, wireValue108_0, wireValue119_0) + + wireValue149_0 := service.NewEnvironmentService(wireValue69_0, wireValue80_0, wireValue1_0) + + wireValue155_0 := service.NewEnvironmentDotnetService(wireValue69_0, wireValue1_0) + + wireValue150_0 := service.NewEnvironmentGoService(wireValue69_0, wireValue1_0) + + wireValue151_0 := service.NewEnvironmentJavaService(wireValue69_0, wireValue1_0) + + wireValue152_0 := service.NewEnvironmentNodejsService(wireValue69_0, wireValue1_0) + + wireValue153_0 := service.NewEnvironmentPHPService(wireValue69_0, wireValue80_0, wireValue0_0, wireValue1_0) + + wireValue154_0 := service.NewEnvironmentPythonService(wireValue69_0, wireValue1_0) + + wireValue118_0, wireErr118 := data.NewTamperRepo(wireValue4_0) + if wireErr118 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr118, cleanupErr) } - tamperUsecase := biz.NewTamperUsecase(notifyUsecase, settingUsecase, locale, slogLogger, tamperRepo) - fileService := service.NewFileService(containerUsecase, tamperUsecase, taskUsecase, locale) - fileShareRepo := data.NewFileShareRepo(db, locale) - fileShareUsecase := biz.NewFileShareUsecase(slogLogger, fileShareRepo) - fileShareService := service.NewFileShareService(fileShareUsecase, locale) - firewallService := service.NewFirewallService(locale) - scanEventRepo, err := data.NewScanEventRepo() - if err != nil { - cleanup() - return nil, nil, err + + wireValue79_0 := biz.NewTamperUsecase(wireValue73_0, wireValue77_0, wireValue1_0, wireValue3_0, wireValue118_0) + + wireValue156_0 := service.NewFileService(wireValue58_0, wireValue79_0, wireValue80_0, wireValue1_0) + + wireValue109_0 := data.NewFileShareRepo(wireValue4_0, wireValue1_0) + + wireValue70_0 := biz.NewFileShareUsecase(wireValue3_0, wireValue109_0) + + wireValue157_0 := service.NewFileShareService(wireValue70_0, wireValue1_0) + + wireValue158_0 := service.NewFirewallService(wireValue1_0) + + wireValue115_0, wireErr115 := data.NewScanEventRepo() + if wireErr115 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr115, cleanupErr) } - scanEventUsecase := biz.NewScanEventUsecase(scanEventRepo, settingRepo) - firewallScanService := service.NewFirewallScanService(scanEventUsecase) - projectRepo := data.NewProjectRepo(db, locale) - projectUsecase := biz.NewProjectUsecase(locale, slogLogger, projectRepo) - websiteStatRepo, err := data.NewWebsiteStatRepo() - if err != nil { - cleanup() - return nil, nil, err + + wireValue76_0 := biz.NewScanEventUsecase(wireValue115_0, wireValue116_0) + + wireValue159_0 := service.NewFirewallScanService(wireValue76_0) + + wireValue113_0 := data.NewProjectRepo(wireValue4_0, wireValue1_0) + + wireValue74_0 := biz.NewProjectUsecase(wireValue1_0, wireValue3_0, wireValue113_0) + + wireValue126_0, wireErr126 := data.NewWebsiteStatRepo() + if wireErr126 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr126, cleanupErr) } - websiteStatUsecase := biz.NewWebsiteStatUsecase(websiteStatRepo) - websiteUsecase := biz.NewWebsiteUsecase(certAccountUsecase, certUsecase, databaseUsecase, databaseUserUsecase, tamperUsecase, websiteStatUsecase, locale, slogLogger, databaseServerRepo, websiteRepo) - homeService := service.NewHomeService(appUsecase, backupUsecase, containerUsecase, cronUsecase, databaseServerUsecase, environmentUsecase, projectUsecase, settingUsecase, taskUsecase, websiteUsecase, config, locale) - logRepo := data.NewLogRepo(db) - logUsecase := biz.NewLogUsecase(logRepo) - logService := service.NewLogService(logUsecase, locale) - monitorRepo, err := data.NewMonitorRepo() - if err != nil { - cleanup() - return nil, nil, err + + wireValue87_0 := biz.NewWebsiteStatUsecase(wireValue126_0) + + wireValue86_0 := biz.NewWebsiteUsecase(wireValue56_0, wireValue55_0, wireValue64_0, wireValue68_0, wireValue79_0, wireValue87_0, wireValue1_0, wireValue3_0, wireValue106_0, wireValue125_0) + + wireValue160_0 := service.NewHomeService(wireValue51_0, wireValue52_0, wireValue58_0, wireValue63_0, wireValue67_0, wireValue69_0, wireValue74_0, wireValue77_0, wireValue80_0, wireValue86_0, wireValue0_0, wireValue1_0) + + wireValue110_0 := data.NewLogRepo(wireValue4_0) + + wireValue71_0 := biz.NewLogUsecase(wireValue110_0) + + wireValue161_0 := service.NewLogService(wireValue71_0, wireValue1_0) + + wireValue111_0, wireErr111 := data.NewMonitorRepo() + if wireErr111 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr111, cleanupErr) } - monitorUsecase := biz.NewMonitorUsecase(monitorRepo, settingRepo) - monitorService := service.NewMonitorService(monitorUsecase, settingUsecase) - notifyService := service.NewNotifyService(notifyUsecase) - processService := service.NewProcessService() - projectService := service.NewProjectService(projectUsecase, settingUsecase) - safeRepo := data.NewSafeRepo() - safeUsecase := biz.NewSafeUsecase(safeRepo, slogLogger) - safeService := service.NewSafeService(safeUsecase) - settingService := service.NewSettingService(certAccountUsecase, certUsecase, settingUsecase, db, locale) - sshRepo := data.NewSSHRepo(db, locale) - sshUsecase := biz.NewSSHUsecase(sshRepo, slogLogger) - sshService := service.NewSSHService(sshUsecase) - systemctlService := service.NewSystemctlService(locale) - tamperService := service.NewTamperService(tamperUsecase, locale) - taskService := service.NewTaskService(taskUsecase) - templateRepo := data.NewTemplateRepo(slogLogger) - templateUsecase := biz.NewTemplateUsecase(locale, cacheRepo, templateRepo) - templateService := service.NewTemplateService(settingUsecase, templateUsecase, locale) - toolboxBenchmarkService := service.NewToolboxBenchmarkService(locale) - toolboxDiskService := service.NewToolboxDiskService(locale) - toolboxLogService := service.NewToolboxLogService(containerImageUsecase, settingUsecase, db, locale) - migrationSourceRepo := data.NewMigrationSourceRepo(locale) - migrationRemoteRepo := data.NewMigrationRemoteRepo(locale) - migrationArchiveRepo := data.NewMigrationArchiveRepo() - toolboxMigrationUsecase := biz.NewToolboxMigrationUsecase(locale, slogLogger, migrationSourceRepo, migrationRemoteRepo, migrationArchiveRepo, settingUsecase, websiteUsecase, databaseUsecase, databaseServerUsecase, databaseUserUsecase, backupUsecase, projectUsecase, appUsecase, environmentUsecase) - toolboxMigrationService := service.NewToolboxMigrationService(toolboxMigrationUsecase, config, locale, slogLogger) - toolboxNetworkService := service.NewToolboxNetworkService(locale) - toolboxSSHService := service.NewToolboxSSHService(locale) - toolboxSystemService := service.NewToolboxSystemService(locale) - userUsecase := biz.NewUserUsecase(locale, slogLogger, userRepo) - userService := service.NewUserService(notifyUsecase, userUsecase, config, locale, manager) - userPasskeyRepo := data.NewUserPasskeyRepo(db) - userPasskeyUsecase := biz.NewUserPasskeyUsecase(userPasskeyRepo) - userPasskeyService := service.NewUserPasskeyService(notifyUsecase, userPasskeyUsecase, userUsecase, config, locale, manager) - userTokenUsecase := biz.NewUserTokenUsecase(userTokenRepo) - userTokenService := service.NewUserTokenService(userTokenUsecase, locale) - webHookRepo := data.NewWebHookRepo(db, locale) - webHookUsecase := biz.NewWebHookUsecase(locale, slogLogger, webHookRepo) - webHookService := service.NewWebHookService(webHookUsecase) - websiteService := service.NewWebsiteService(settingUsecase, websiteUsecase, locale) - aggregator := websitestat.NewAggregator() - websiteStatService := service.NewWebsiteStatService(settingUsecase, websiteStatUsecase, websiteUsecase, aggregator) - wsService := service.NewWsService(backupUsecase, certUsecase, sshUsecase, settingUsecase, taskUsecase, config, locale, slogLogger) - services := &route.Services{ - Alert: alertService, - App: appService, - Backup: backupService, - BackupStorage: backupStorageService, - Cert: certService, - CertAccount: certAccountService, - CertDNS: certDNSService, - Container: containerService, - ContainerCompose: containerComposeService, - ContainerImage: containerImageService, - ContainerNetwork: containerNetworkService, - ContainerVolume: containerVolumeService, - Cron: cronService, - Database: databaseService, - DatabaseElasticsearch: databaseElasticsearchService, - DatabaseRedis: databaseRedisService, - DatabaseServer: databaseServerService, - DatabaseUser: databaseUserService, - Environment: environmentService, - EnvironmentDotnet: environmentDotnetService, - EnvironmentGo: environmentGoService, - EnvironmentJava: environmentJavaService, - EnvironmentNodejs: environmentNodejsService, - EnvironmentPHP: environmentPHPService, - EnvironmentPython: environmentPythonService, - File: fileService, - FileShare: fileShareService, - Firewall: firewallService, - FirewallScan: firewallScanService, - Home: homeService, - Log: logService, - Monitor: monitorService, - Notify: notifyService, - Process: processService, - Project: projectService, - Safe: safeService, - Setting: settingService, - SSH: sshService, - Systemctl: systemctlService, - Tamper: tamperService, - Task: taskService, - Template: templateService, - ToolboxBenchmark: toolboxBenchmarkService, - ToolboxDisk: toolboxDiskService, - ToolboxLog: toolboxLogService, - ToolboxMigration: toolboxMigrationService, - ToolboxNetwork: toolboxNetworkService, - ToolboxSSH: toolboxSSHService, - ToolboxSystem: toolboxSystemService, - User: userService, - UserPasskey: userPasskeyService, - UserToken: userTokenService, - WebHook: webHookService, - Website: websiteService, - WebsiteStat: websiteStatService, - Ws: wsService, + + wireValue72_0 := biz.NewMonitorUsecase(wireValue111_0, wireValue116_0) + + wireValue162_0 := service.NewMonitorService(wireValue72_0, wireValue77_0) + + wireValue163_0 := service.NewNotifyService(wireValue73_0) + + wireValue164_0 := service.NewProcessService() + + wireValue165_0 := service.NewProjectService(wireValue74_0, wireValue77_0) + + wireValue114_0 := data.NewSafeRepo() + + wireValue75_0 := biz.NewSafeUsecase(wireValue114_0, wireValue3_0) + + wireValue166_0 := service.NewSafeService(wireValue75_0) + + wireValue167_0 := service.NewSettingService(wireValue56_0, wireValue55_0, wireValue77_0, wireValue4_0, wireValue1_0) + + wireValue117_0 := data.NewSSHRepo(wireValue4_0, wireValue1_0) + + wireValue78_0 := biz.NewSSHUsecase(wireValue117_0, wireValue3_0) + + wireValue168_0 := service.NewSSHService(wireValue78_0) + + wireValue169_0 := service.NewSystemctlService(wireValue1_0) + + wireValue170_0 := service.NewTamperService(wireValue79_0, wireValue1_0) + + wireValue171_0 := service.NewTaskService(wireValue80_0) + + wireValue120_0 := data.NewTemplateRepo(wireValue3_0) + + wireValue81_0 := biz.NewTemplateUsecase(wireValue1_0, wireValue93_0, wireValue120_0) + + wireValue172_0 := service.NewTemplateService(wireValue77_0, wireValue81_0, wireValue1_0) + + wireValue181_0 := service.NewToolboxBenchmarkService(wireValue1_0) + + wireValue183_0 := service.NewToolboxDiskService(wireValue1_0) + + wireValue184_0 := service.NewToolboxLogService(wireValue60_0, wireValue77_0, wireValue4_0, wireValue1_0) + + wireValue127_0 := data.NewMigrationSourceRepo(wireValue1_0) + + wireValue128_0 := data.NewMigrationRemoteRepo(wireValue1_0) + + wireValue129_0 := data.NewMigrationArchiveRepo() + + wireValue88_0 := biz.NewToolboxMigrationUsecase(wireValue1_0, wireValue3_0, wireValue127_0, wireValue128_0, wireValue129_0, wireValue77_0, wireValue86_0, wireValue64_0, wireValue67_0, wireValue68_0, wireValue52_0, wireValue74_0, wireValue51_0, wireValue69_0) + + wireValue185_0 := service.NewToolboxMigrationService(wireValue88_0, wireValue0_0, wireValue1_0, wireValue3_0) + + wireValue179_0 := service.NewToolboxNetworkService(wireValue1_0) + + wireValue182_0 := service.NewToolboxSSHService(wireValue1_0) + + wireValue180_0 := service.NewToolboxSystemService(wireValue1_0) + + wireValue82_0 := biz.NewUserUsecase(wireValue1_0, wireValue3_0, wireValue121_0) + + wireValue173_0 := service.NewUserService(wireValue73_0, wireValue82_0, wireValue0_0, wireValue1_0, wireValue6_0) + + wireValue122_0 := data.NewUserPasskeyRepo(wireValue4_0) + + wireValue83_0 := biz.NewUserPasskeyUsecase(wireValue122_0) + + wireValue174_0 := service.NewUserPasskeyService(wireValue73_0, wireValue83_0, wireValue82_0, wireValue0_0, wireValue1_0, wireValue6_0) + + wireValue84_0 := biz.NewUserTokenUsecase(wireValue123_0) + + wireValue175_0 := service.NewUserTokenService(wireValue84_0, wireValue1_0) + + wireValue124_0 := data.NewWebHookRepo(wireValue4_0, wireValue1_0) + + wireValue85_0 := biz.NewWebHookUsecase(wireValue1_0, wireValue3_0, wireValue124_0) + + wireValue176_0 := service.NewWebHookService(wireValue85_0) + + wireValue177_0 := service.NewWebsiteService(wireValue77_0, wireValue86_0, wireValue1_0) + + wireValue16_0 := websitestat.NewAggregator() + + wireValue178_0 := service.NewWebsiteStatService(wireValue77_0, wireValue87_0, wireValue86_0, wireValue16_0) + + wireValue186_0 := service.NewWsService(wireValue52_0, wireValue55_0, wireValue78_0, wireValue77_0, wireValue80_0, wireValue0_0, wireValue1_0, wireValue3_0) + + wireValue187_1 := &route.Services{ + Alert: wireValue130_0, + App: wireValue131_0, + Backup: wireValue132_0, + BackupStorage: wireValue133_0, + Cert: wireValue134_0, + CertAccount: wireValue135_0, + CertDNS: wireValue136_0, + Container: wireValue138_0, + ContainerCompose: wireValue139_0, + ContainerImage: wireValue140_0, + ContainerNetwork: wireValue141_0, + ContainerVolume: wireValue142_0, + Cron: wireValue143_0, + Database: wireValue144_0, + DatabaseElasticsearch: wireValue146_0, + DatabaseRedis: wireValue145_0, + DatabaseServer: wireValue147_0, + DatabaseUser: wireValue148_0, + Environment: wireValue149_0, + EnvironmentDotnet: wireValue155_0, + EnvironmentGo: wireValue150_0, + EnvironmentJava: wireValue151_0, + EnvironmentNodejs: wireValue152_0, + EnvironmentPHP: wireValue153_0, + EnvironmentPython: wireValue154_0, + File: wireValue156_0, + FileShare: wireValue157_0, + Firewall: wireValue158_0, + FirewallScan: wireValue159_0, + Home: wireValue160_0, + Log: wireValue161_0, + Monitor: wireValue162_0, + Notify: wireValue163_0, + Process: wireValue164_0, + Project: wireValue165_0, + Safe: wireValue166_0, + Setting: wireValue167_0, + SSH: wireValue168_0, + Systemctl: wireValue169_0, + Tamper: wireValue170_0, + Task: wireValue171_0, + Template: wireValue172_0, + ToolboxBenchmark: wireValue181_0, + ToolboxDisk: wireValue183_0, + ToolboxLog: wireValue184_0, + ToolboxMigration: wireValue185_0, + ToolboxNetwork: wireValue179_0, + ToolboxSSH: wireValue182_0, + ToolboxSystem: wireValue180_0, + User: wireValue173_0, + UserPasskey: wireValue174_0, + UserToken: wireValue175_0, + WebHook: wireValue176_0, + Website: wireValue177_0, + WebsiteStat: wireValue178_0, + Ws: wireValue186_0, } - v := route.NewEndpoints(services) - mux, err := bootstrap.NewRouter(loader, config, locale, middlewares, validator, v) - if err != nil { - cleanup() - return nil, nil, err + + wireValue188_0 := route.NewEndpoints(wireValue187_1) + + wireValue11_0, wireErr11 := bootstrap.NewRouter(wireValue10_0, wireValue0_0, wireValue1_0, wireValue9_0, wireValue8_0, wireValue188_0) + if wireErr11 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr11, cleanupErr) } - dependencies := &job.Dependencies{ - Alert: alertUsecase, - Backup: backupUsecase, - Cache: cacheUsecase, - Cert: certUsecase, - CertAccount: certAccountUsecase, - FileShare: fileShareUsecase, - Monitor: monitorUsecase, - Notify: notifyUsecase, - ScanEvent: scanEventUsecase, - Setting: settingUsecase, - Tamper: tamperUsecase, - Task: taskUsecase, - Website: websiteUsecase, - WebsiteStat: websiteStatUsecase, - Conf: config, - DB: db, - T: locale, - Log: slogLogger, - Aggregator: aggregator, + + wireValue189_1 := &job.Dependencies{ + Alert: wireValue50_0, + Backup: wireValue52_0, + Cache: wireValue54_0, + Cert: wireValue55_0, + CertAccount: wireValue56_0, + FileShare: wireValue70_0, + Monitor: wireValue72_0, + Notify: wireValue73_0, + ScanEvent: wireValue76_0, + Setting: wireValue77_0, + Tamper: wireValue79_0, + Task: wireValue80_0, + Website: wireValue86_0, + WebsiteStat: wireValue87_0, + Conf: wireValue0_0, + DB: wireValue4_0, + T: wireValue1_0, + Log: wireValue3_0, + Aggregator: wireValue16_0, } - v2 := job.NewJobs(dependencies) - cron, err := bootstrap.NewCron(slogLogger, v2) - if err != nil { - cleanup() - return nil, nil, err + + wireValue190_0 := job.NewJobs(wireValue189_1) + + wireValue14_0, wireErr14 := bootstrap.NewCron(wireValue3_0, wireValue190_0) + if wireErr14 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr14, cleanupErr) } - gormigrate := bootstrap.NewMigrate(db) - reloader, err := bootstrap.NewTLSReloader(config) - if err != nil { - cleanup() - return nil, nil, err + + wireValue5_0 := bootstrap.NewMigrate(wireValue4_0) + + wireValue12_0, wireErr12 := bootstrap.NewTLSReloader(wireValue0_0) + if wireErr12 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr12, cleanupErr) } - server := bootstrap.NewHttp(mux, config, reloader) - ace := app.NewAce(mux, config, cron, gormigrate, server, reloader, taskRunner) - return ace, func() { - cleanup() - }, nil + + wireValue13_0 := bootstrap.NewHttp(wireValue11_0, wireValue0_0, wireValue12_0) + + wireValue191_0 := app.NewAce(wireValue11_0, wireValue0_0, wireValue14_0, wireValue5_0, wireValue13_0, wireValue12_0, wireValue7_0) + + wireCommitted = true + + return wireValue191_0, wireCleanup.close, nil +} + +func wireRunCleanup(cleanup func() error) (err error, panicValue any) { + defer func() { panicValue = recover() }() + err = cleanup() + return err, nil +} + +func wireRollbackOnPanic(finalized *bool, rollback func() error) { + if *finalized { + return + } + panicValue := recover() + func() { + defer func() { _ = recover() }() + _ = rollback() + }() + if panicValue != nil { + panic(panicValue) + } +} + +type wireLifecycle struct { + cancel func() + children func() error + cleanups []func() error + once sync.Once + err error + panicValue any +} + +func (l *wireLifecycle) arm(cleanup func() error) { + if cleanup != nil { + l.cleanups = append(l.cleanups, cleanup) + } +} + +func (l *wireLifecycle) close() error { + l.once.Do(func() { + var errs []error + if l.cancel != nil { + l.cancel() + } + if l.children != nil { + err, panicValue := wireRunCleanup(l.children) + if err != nil { + errs = append(errs, err) + } + l.panicValue = panicValue + } + for index := len(l.cleanups) - 1; index >= 0; index-- { + err, panicValue := wireRunCleanup(l.cleanups[index]) + if err != nil { + errs = append(errs, err) + } + if panicValue != nil && l.panicValue == nil { + l.panicValue = panicValue + } + } + l.err = errors.Join(errs...) + }) + if l.panicValue != nil { + panic(l.panicValue) + } + return l.err } diff --git a/cmd/cli/main.go b/cmd/cli/main.go index b30b72424..1c35317ca 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -1,3 +1,5 @@ +//go:generate go tool wire generate . + package main import ( @@ -24,9 +26,7 @@ func run() error { if err != nil { return err } - if cleanup != nil { - defer cleanup() - } + defer func() { _ = cleanup() }() return cli.Run() } diff --git a/cmd/cli/wire.go b/cmd/cli/wire.go index 41ddada6a..3033e6e05 100644 --- a/cmd/cli/wire.go +++ b/cmd/cli/wire.go @@ -3,7 +3,7 @@ package main import ( - "github.com/google/wire" + "github.com/libtnb/wire" "github.com/acepanel/panel/v3/internal/app" "github.com/acepanel/panel/v3/internal/biz" @@ -13,13 +13,7 @@ import ( "github.com/acepanel/panel/v3/internal/service" ) -func initCli() (*app.Cli, func(), error) { - panic(wire.Build( - bootstrap.ProviderSet, - biz.ProviderSet, - data.ProviderSet, - service.ProviderSet, - command.ProviderSet, - app.NewCli, - )) -} +var initCli = wire.New(). + Include(bootstrap.Module, biz.Module, data.Module, service.Module, command.Module). + Provide(app.NewCli). + Injector[func() (*app.Cli, func() error, error)]() diff --git a/cmd/cli/wire_gen.go b/cmd/cli/wire_gen.go index 1766d4f32..b3dfb5386 100644 --- a/cmd/cli/wire_gen.go +++ b/cmd/cli/wire_gen.go @@ -1,12 +1,12 @@ -// Code generated by Wire. DO NOT EDIT. - -//go:generate go run -mod=mod github.com/google/wire/cmd/wire +// Code generated by wire. DO NOT EDIT. //go:build !wireinject -// +build !wireinject package main import ( + "errors" + "sync" + "github.com/acepanel/panel/v3/internal/app" "github.com/acepanel/panel/v3/internal/biz" "github.com/acepanel/panel/v3/internal/bootstrap" @@ -15,76 +15,195 @@ import ( "github.com/acepanel/panel/v3/internal/service" ) -import ( - _ "time/tzdata" -) +func initCli() (*app.Cli, func() error, error) { + var wireZero0 *app.Cli -// Injectors from wire.go: + wireCleanup := &wireLifecycle{} + wireCommitted := false + defer wireRollbackOnPanic(&wireCommitted, wireCleanup.close) -func initCli() (*app.Cli, func(), error) { - config, err := bootstrap.NewConf() - if err != nil { - return nil, nil, err + wireValue0_0, wireErr0 := bootstrap.NewConf() + if wireErr0 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr0, cleanupErr) } - locale := bootstrap.NewT(config) - db, err := bootstrap.NewDB(config) - if err != nil { - return nil, nil, err + + wireValue1_0 := bootstrap.NewT(wireValue0_0) + + wireValue4_0, wireErr4 := bootstrap.NewDB(wireValue0_0) + if wireErr4 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr4, cleanupErr) } - logger, cleanup, err := bootstrap.NewLogger(config) - if err != nil { - return nil, nil, err + + wireValue2_0, wireResourceCleanup2, wireErr2 := bootstrap.NewLogger(wireValue0_0) + if wireErr2 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr2, cleanupErr) } - slogLogger := bootstrap.NewSlog(logger) - appRepo := data.NewAppRepo(config, db, locale, slogLogger) - cacheRepo := data.NewCacheRepo(db) - notifyChannelRepo := data.NewNotifyChannelRepo(db) - settingRepo := data.NewSettingRepo(config, db) - notifyUsecase := biz.NewNotifyUsecase(locale, slogLogger, notifyChannelRepo, settingRepo) - taskRunner := bootstrap.NewRunner(notifyUsecase, db, locale, slogLogger) - taskRepo := data.NewTaskRepo(db, locale, slogLogger, taskRunner) - appUsecase := biz.NewAppUsecase(locale, appRepo, cacheRepo, taskRepo) - websiteRepo := data.NewWebsiteRepo(db, locale, settingRepo) - backupRepo := data.NewBackupRepo(config, db, locale, slogLogger, settingRepo, websiteRepo) - backupUsecase := biz.NewBackupUsecase(notifyUsecase, locale, slogLogger, backupRepo) - cacheUsecase := biz.NewCacheUsecase(cacheRepo) - certAccountRepo := data.NewCertAccountRepo(db, locale, slogLogger) - userRepo := data.NewUserRepo(db, locale) - certAccountUsecase := biz.NewCertAccountUsecase(locale, slogLogger, certAccountRepo, userRepo) - certRepo := data.NewCertRepo(db, locale, slogLogger) - certUsecase := biz.NewCertUsecase(locale, slogLogger, certRepo, settingRepo) - cronRepo := data.NewCronRepo(db, locale) - cronUsecase := biz.NewCronUsecase(cronRepo, slogLogger) - databaseServerRepo := data.NewDatabaseServerRepo(db) - databaseServerUsecase := biz.NewDatabaseServerUsecase(locale, slogLogger, databaseServerRepo) - settingUsecase := biz.NewSettingUsecase(locale, slogLogger, settingRepo, taskRepo) - userPasskeyRepo := data.NewUserPasskeyRepo(db) - userPasskeyUsecase := biz.NewUserPasskeyUsecase(userPasskeyRepo) - userUsecase := biz.NewUserUsecase(locale, slogLogger, userRepo) - databaseUserRepo := data.NewDatabaseUserRepo(db) - databaseUserUsecase := biz.NewDatabaseUserUsecase(slogLogger, databaseServerRepo, databaseUserRepo) - databaseRepo := data.NewDatabaseRepo(db) - databaseUsecase := biz.NewDatabaseUsecase(databaseUserUsecase, locale, slogLogger, databaseRepo, databaseServerRepo) - tamperRepo, err := data.NewTamperRepo(db) - if err != nil { - cleanup() - return nil, nil, err + wireCleanup.arm(wireResourceCleanup2) + + wireValue3_0 := bootstrap.NewSlog(wireValue2_0) + + wireValue57_0 := data.NewAppRepo(wireValue0_0, wireValue4_0, wireValue1_0, wireValue3_0) + + wireValue60_0 := data.NewCacheRepo(wireValue4_0) + + wireValue79_0 := data.NewNotifyChannelRepo(wireValue4_0) + + wireValue83_0 := data.NewSettingRepo(wireValue0_0, wireValue4_0) + + wireValue40_0 := biz.NewNotifyUsecase(wireValue1_0, wireValue3_0, wireValue79_0, wireValue83_0) + + wireValue7_0 := bootstrap.NewRunner(wireValue40_0, wireValue4_0, wireValue1_0, wireValue3_0) + + wireValue86_0 := data.NewTaskRepo(wireValue4_0, wireValue1_0, wireValue3_0, wireValue7_0) + + wireValue18_0 := biz.NewAppUsecase(wireValue1_0, wireValue57_0, wireValue60_0, wireValue86_0) + + wireValue92_0 := data.NewWebsiteRepo(wireValue4_0, wireValue1_0, wireValue83_0) + + wireValue58_0 := data.NewBackupRepo(wireValue0_0, wireValue4_0, wireValue1_0, wireValue3_0, wireValue83_0, wireValue92_0) + + wireValue19_0 := biz.NewBackupUsecase(wireValue40_0, wireValue1_0, wireValue3_0, wireValue58_0) + + wireValue21_0 := biz.NewCacheUsecase(wireValue60_0) + + wireValue62_0 := data.NewCertAccountRepo(wireValue4_0, wireValue1_0, wireValue3_0) + + wireValue88_0 := data.NewUserRepo(wireValue4_0, wireValue1_0) + + wireValue23_0 := biz.NewCertAccountUsecase(wireValue1_0, wireValue3_0, wireValue62_0, wireValue88_0) + + wireValue61_0 := data.NewCertRepo(wireValue4_0, wireValue1_0, wireValue3_0) + + wireValue22_0 := biz.NewCertUsecase(wireValue1_0, wireValue3_0, wireValue61_0, wireValue83_0) + + wireValue69_0 := data.NewCronRepo(wireValue4_0, wireValue1_0) + + wireValue30_0 := biz.NewCronUsecase(wireValue69_0, wireValue3_0) + + wireValue73_0 := data.NewDatabaseServerRepo(wireValue4_0) + + wireValue34_0 := biz.NewDatabaseServerUsecase(wireValue1_0, wireValue3_0, wireValue73_0) + + wireValue44_0 := biz.NewSettingUsecase(wireValue1_0, wireValue3_0, wireValue83_0, wireValue86_0) + + wireValue89_0 := data.NewUserPasskeyRepo(wireValue4_0) + + wireValue50_0 := biz.NewUserPasskeyUsecase(wireValue89_0) + + wireValue49_0 := biz.NewUserUsecase(wireValue1_0, wireValue3_0, wireValue88_0) + + wireValue74_0 := data.NewDatabaseUserRepo(wireValue4_0) + + wireValue35_0 := biz.NewDatabaseUserUsecase(wireValue3_0, wireValue73_0, wireValue74_0) + + wireValue70_0 := data.NewDatabaseRepo(wireValue4_0) + + wireValue31_0 := biz.NewDatabaseUsecase(wireValue35_0, wireValue1_0, wireValue3_0, wireValue70_0, wireValue73_0) + + wireValue85_0, wireErr85 := data.NewTamperRepo(wireValue4_0) + if wireErr85 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr85, cleanupErr) } - tamperUsecase := biz.NewTamperUsecase(notifyUsecase, settingUsecase, locale, slogLogger, tamperRepo) - websiteStatRepo, err := data.NewWebsiteStatRepo() - if err != nil { - cleanup() - return nil, nil, err + + wireValue46_0 := biz.NewTamperUsecase(wireValue40_0, wireValue44_0, wireValue1_0, wireValue3_0, wireValue85_0) + + wireValue93_0, wireErr93 := data.NewWebsiteStatRepo() + if wireErr93 != nil { + wireCommitted = true + cleanupErr := wireCleanup.close() + return wireZero0, nil, errors.Join(wireErr93, cleanupErr) } - websiteStatUsecase := biz.NewWebsiteStatUsecase(websiteStatRepo) - websiteUsecase := biz.NewWebsiteUsecase(certAccountUsecase, certUsecase, databaseUsecase, databaseUserUsecase, tamperUsecase, websiteStatUsecase, locale, slogLogger, databaseServerRepo, websiteRepo) - validator := bootstrap.NewValidator(config, db, locale) - cliService := service.NewCliService(appUsecase, backupUsecase, cacheUsecase, certAccountUsecase, certUsecase, cronUsecase, databaseServerUsecase, notifyUsecase, settingUsecase, userPasskeyUsecase, userUsecase, websiteUsecase, config, db, locale, validator) - v := command.Commands(locale, cliService) - cliCommand := bootstrap.NewCli(locale, v) - gormigrate := bootstrap.NewMigrate(db) - cli := app.NewCli(cliCommand, gormigrate) - return cli, func() { - cleanup() - }, nil + + wireValue54_0 := biz.NewWebsiteStatUsecase(wireValue93_0) + + wireValue53_0 := biz.NewWebsiteUsecase(wireValue23_0, wireValue22_0, wireValue31_0, wireValue35_0, wireValue46_0, wireValue54_0, wireValue1_0, wireValue3_0, wireValue73_0, wireValue92_0) + + wireValue8_0 := bootstrap.NewValidator(wireValue0_0, wireValue4_0, wireValue1_0) + + wireValue104_0 := service.NewCliService(wireValue18_0, wireValue19_0, wireValue21_0, wireValue23_0, wireValue22_0, wireValue30_0, wireValue34_0, wireValue40_0, wireValue44_0, wireValue50_0, wireValue49_0, wireValue53_0, wireValue0_0, wireValue4_0, wireValue1_0, wireValue8_0) + + wireValue154_0 := command.Commands(wireValue1_0, wireValue104_0) + + wireValue15_0 := bootstrap.NewCli(wireValue1_0, wireValue154_0) + + wireValue5_0 := bootstrap.NewMigrate(wireValue4_0) + + wireValue155_0 := app.NewCli(wireValue15_0, wireValue5_0) + + wireCommitted = true + + return wireValue155_0, wireCleanup.close, nil +} + +func wireRunCleanup(cleanup func() error) (err error, panicValue any) { + defer func() { panicValue = recover() }() + err = cleanup() + return err, nil +} + +func wireRollbackOnPanic(finalized *bool, rollback func() error) { + if *finalized { + return + } + panicValue := recover() + func() { + defer func() { _ = recover() }() + _ = rollback() + }() + if panicValue != nil { + panic(panicValue) + } +} + +type wireLifecycle struct { + cancel func() + children func() error + cleanups []func() error + once sync.Once + err error + panicValue any +} + +func (l *wireLifecycle) arm(cleanup func() error) { + if cleanup != nil { + l.cleanups = append(l.cleanups, cleanup) + } +} + +func (l *wireLifecycle) close() error { + l.once.Do(func() { + var errs []error + if l.cancel != nil { + l.cancel() + } + if l.children != nil { + err, panicValue := wireRunCleanup(l.children) + if err != nil { + errs = append(errs, err) + } + l.panicValue = panicValue + } + for index := len(l.cleanups) - 1; index >= 0; index-- { + err, panicValue := wireRunCleanup(l.cleanups[index]) + if err != nil { + errs = append(errs, err) + } + if panicValue != nil && l.panicValue == nil { + l.panicValue = panicValue + } + } + l.err = errors.Join(errs...) + }) + if l.panicValue != nil { + panic(l.panicValue) + } + return l.err } diff --git a/go.mod b/go.mod index 108320bcb..35f1bf366 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/go-sql-driver/mysql v1.10.1 github.com/go-webauthn/webauthn v0.18.1 github.com/gomodule/redigo v1.9.3 - github.com/google/wire v0.7.0 + github.com/google/go-cmp v0.7.0 github.com/gookit/color v1.6.1 github.com/hashicorp/go-version v1.9.0 github.com/klauspost/compress v1.20.0 @@ -36,6 +36,7 @@ require ( github.com/libdns/porkbun v1.1.0 github.com/libdns/tencentcloud v1.4.3 github.com/libdns/westcn v1.0.2 + github.com/libtnb/assert v0.4.2 github.com/libtnb/chix/v2 v2.1.1 github.com/libtnb/cron v0.6.0 github.com/libtnb/gormstore v1.3.0 @@ -45,6 +46,7 @@ require ( github.com/libtnb/utils v1.2.2 github.com/libtnb/validator v0.5.0 github.com/libtnb/validator/contrib/openapi v0.3.0 + github.com/libtnb/wire v0.3.0 github.com/medama-io/go-useragent v1.2.4 github.com/mholt/acmez/v3 v3.1.6 github.com/moby/moby/api v1.56.0 @@ -58,7 +60,6 @@ require ( github.com/sethvargo/go-limiter v1.2.0 github.com/shirou/gopsutil/v4 v4.26.8 github.com/spf13/cast v1.10.0 - github.com/stretchr/testify v1.12.1 github.com/studio-b12/gowebdav v0.13.0 github.com/urfave/cli/v3 v3.11.0 github.com/valyala/fastjson v1.6.10 @@ -99,7 +100,6 @@ require ( github.com/gofiber/utils/v2 v2.2.0 // indirect github.com/golang-jwt/jwt/v5 v5.3.1 // indirect github.com/google/go-tpm v0.9.8 // indirect - github.com/google/subcommands v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/jaevor/go-nanoid v1.4.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect @@ -113,12 +113,10 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect github.com/philhofer/fwd v1.2.0 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/richardlehane/mscfb v1.0.7 // indirect github.com/richardlehane/msoleps v1.0.6 // indirect - github.com/stretchr/objx v0.5.3 // indirect github.com/tiendc/go-deepcopy v1.7.2 // indirect github.com/tinylib/msgp v1.6.4 // indirect github.com/tklauser/go-sysconf v0.3.16 // indirect @@ -142,9 +140,6 @@ require ( modernc.org/memory v1.12.1 // indirect ) -replace ( - github.com/mholt/acmez/v3 => github.com/libtnb/acmez/v3 v3.0.0-20260406165834-a264acd02292 - github.com/stretchr/testify => github.com/libtnb/testify v0.0.0-20260406170114-25da2dad39e7 -) +replace github.com/mholt/acmez/v3 => github.com/libtnb/acmez/v3 v3.0.0-20260406165834-a264acd02292 -tool github.com/google/wire/cmd/wire +tool github.com/libtnb/wire/cmd/wire diff --git a/go.sum b/go.sum index b3faaca9c..ffb3ca7c4 100644 --- a/go.sum +++ b/go.sum @@ -29,6 +29,7 @@ github.com/coreos/go-systemd/v22 v22.7.0 h1:LAEzFkke61DFROc7zNLX/WA2i5J8gYqe0rSj github.com/coreos/go-systemd/v22 v22.7.0/go.mod h1:xNUYtjHu2EDXbsxz1i41wouACIwT7Ybq9o0BQhMwD0w= github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/captcha v1.1.0 h1:2kt47EoYUUkaISobUdTbqwx55xvKOJxyScVfw25xzhQ= github.com/dchest/captcha v1.1.0/go.mod h1:7zoElIawLp7GUMLcj54K9kbw+jEyvz2K0FDdRRYhvWo= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= @@ -95,12 +96,8 @@ github.com/google/go-tpm-tools v0.3.13-0.20230620182252-4639ecce2aba h1:qJEJcuLz github.com/google/go-tpm-tools v0.3.13-0.20230620182252-4639ecce2aba/go.mod h1:EFYHy8/1y2KfgTAsx7Luu7NGhoxtuVHnNo8jE7FikKc= github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 h1:LMLX+LgTNWpfvCBdFebv6EsYotImrt/Ppc5cXIriCSo= github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk= -github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE= -github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/wire v0.7.0 h1:JxUKI6+CVBgCO2WToKy/nQk0sS+amI9z9EjVmdaocj4= -github.com/google/wire v0.7.0/go.mod h1:n6YbUQD9cPKTnHXEBN2DXlOp/mVADhVErcMFb0v3J18= github.com/gookit/assert v0.1.1 h1:lh3GcawXe/p+cU7ESTZ5Ui3Sm/x8JWpIis4/1aF0mY0= github.com/gookit/assert v0.1.1/go.mod h1:jS5bmIVQZTIwk42uXl4lyj4iaaxx32tqH16CFj0VX2E= github.com/gookit/color v1.6.1 h1:KoTnDxJPRgrL0SoX0f8rCFg2zI0t4E3GZZBMo2nN8LU= @@ -159,6 +156,8 @@ github.com/libdns/westcn v1.0.2 h1:PA2M3tME5/0T3klPMzSHvGk1EWnGNNkJiKxaJjFalnM= github.com/libdns/westcn v1.0.2/go.mod h1:iKpk8jjOU+793Yp8nHoihPTCR6N1KWtm4/r8BB9mVnk= github.com/libtnb/acmez/v3 v3.0.0-20260406165834-a264acd02292 h1:FF1ZlwFFjpwT6CtBodr/NV4OMJPMC7plTmfzqhXrlSk= github.com/libtnb/acmez/v3 v3.0.0-20260406165834-a264acd02292/go.mod h1:5nTPosTGosLxF3+LU4ygbgMRFDhbAVpqMI4+a4aHLBY= +github.com/libtnb/assert v0.4.2 h1:g3uKq896kFhOwV9pGHPCX69wdHXtGD5GH1mXvXi6+BQ= +github.com/libtnb/assert v0.4.2/go.mod h1:bUoeNvAxyTPnJNWmNQQcCADyqkh+8spsh+1aCPTke2g= github.com/libtnb/chix/v2 v2.1.1 h1:QQwHXUyPaUUp/KOwzXf2NB0IRKb9v2pqIdOIItzBPiE= github.com/libtnb/chix/v2 v2.1.1/go.mod h1:OEY9v0976U/IJzP6n8VdhgXH17VL2muo3EQWsIUyxm8= github.com/libtnb/cron v0.6.0 h1:li/YbLyfmC2S+xlVEniB9qLvURgYaLwAEEFREve6yXs= @@ -173,14 +172,14 @@ github.com/libtnb/sessions v1.5.0 h1:gvTRkSR8lpp1PB0Nms/kc+gh1BwJ411fxLjnZLYItLs github.com/libtnb/sessions v1.5.0/go.mod h1:/Q/+lO7DcnJJEU1nL59ScPV/V8ct34F8BjoEMwwxjRw= github.com/libtnb/sqlite v1.2.2 h1:Ku5hAPP5B3A4kQcDn4Z3qyNMafKzuAbnFZX4oD9wR4I= github.com/libtnb/sqlite v1.2.2/go.mod h1:JkAuxM7HHo0tc7dQENjIGpp/yIfrLX5nKr5ME9wuvmI= -github.com/libtnb/testify v0.0.0-20260406170114-25da2dad39e7 h1:ZzONsNhw69uC/wJQlMj66n1zfsRgKAElfJ//E9G380U= -github.com/libtnb/testify v0.0.0-20260406170114-25da2dad39e7/go.mod h1:HeQeTfKU6tj2Lx1z79UacwYeDioo6M4ZD7BDDI6+rrg= github.com/libtnb/utils v1.2.2 h1:HUqgAIb+TIrZPXRytYB5XqzkEXG2U4a4/ZGpprNtL5A= github.com/libtnb/utils v1.2.2/go.mod h1:KUCx2+Phw3cLXOwuQDy6XwFOliaYuU1rpAuJQuHf+lQ= github.com/libtnb/validator v0.5.0 h1:1jiUBwDskUxaSQCoS9k8Ua96wofU3aZ5vttKAmEfFUU= github.com/libtnb/validator v0.5.0/go.mod h1:yssIkchUNzAQc8EeP99rwIeYbFE2usrYbN1Ki5pamfQ= github.com/libtnb/validator/contrib/openapi v0.3.0 h1:3yqF52Naa3BanMHAnpXpLJ23ilGPuQcb27fw89zChi4= github.com/libtnb/validator/contrib/openapi v0.3.0/go.mod h1:NrRAZg/IvkdEPMn3WhtDdwVPgKmnVj7J0yogBKYTygo= +github.com/libtnb/wire v0.3.0 h1:AXNLM/J5z8DymfJNbJtet85bydN124orgQUL9jhXziQ= +github.com/libtnb/wire v0.3.0/go.mod h1:LiM46FF18IcKFV/a6mauzKSkBlm2Hp+r/1xKx4MqTww= github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 h1:PwQumkgq4/acIiZhtifTV5OUqqiP82UAl0h87xj/l9k= github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI= @@ -217,8 +216,7 @@ github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM= github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= github.com/pkg/sftp v1.13.11 h1:0N92SLTB8JqASJB14ZLHHzFnBV8mG9zw4K7jghEFWuE= github.com/pkg/sftp v1.13.11/go.mod h1:uNkH9roSXglNJqM+glJJi+TQXQUm0fXFWqCFmT8hsN0= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/pquerna/otp v1.5.0 h1:NMMR+WrmaqXU4EzdGJEE1aUUI0AMRzsp96fFFWNPwxs= @@ -241,8 +239,10 @@ github.com/shirou/gopsutil/v4 v4.26.8 h1:YQMTF/1J50B5+Y0vlo1eDRf5DoR7Gk69hY+8wjY github.com/shirou/gopsutil/v4 v4.26.8/go.mod h1:5O9FjBiXoTDFatIWjZZosqj4pV0DRtLx598xGbBehzM= github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= -github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= -github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= +github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= github.com/studio-b12/gowebdav v0.13.0 h1:OcwSg6IQHOFNdYHn3bPOHwSE8looG8N56Y5xTT1asqQ= github.com/studio-b12/gowebdav v0.13.0/go.mod h1:bHA7t77X/QFExdeAnDzK6vKM34kEZAcE1OX4MfiwjkE= github.com/tiendc/go-deepcopy v1.7.2 h1:Ut2yYR7W9tWjTQitganoIue4UGxZwCcJy3orjrrIj44= @@ -287,6 +287,8 @@ go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= +go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= +go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= go.yaml.in/yaml/v4 v4.0.0-rc.6 h1:1h7H1ohdUh93/FyE4YaDa1Zh64K6VVbjF4K6WUxMtH4= go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M= diff --git a/internal/apps/confval/confval_test.go b/internal/apps/confval/confval_test.go index a26cd6c84..0ef913b9c 100644 --- a/internal/apps/confval/confval_test.go +++ b/internal/apps/confval/confval_test.go @@ -3,177 +3,167 @@ package confval import ( "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" ) -type ConfValTestSuite struct { - suite.Suite -} - -func TestConfValTestSuite(t *testing.T) { - suite.Run(t, new(ConfValTestSuite)) -} - -func (s *ConfValTestSuite) TestDirectiveGet() { +func TestDirectiveGet(t *testing.T) { conf := "# comment\nbind 127.0.0.1 ::1\nport 6379\n\n# maxmemory 100mb\n" - s.Equal("127.0.0.1 ::1", Directive.Get(conf, "bind")) - s.Equal("6379", Directive.Get(conf, "port")) + check.Equal(t, Directive.Get(conf, "bind"), "127.0.0.1 ::1") + check.Equal(t, Directive.Get(conf, "port"), "6379") // 注释掉的项不应被读出 - s.Empty(Directive.Get(conf, "maxmemory")) - s.Empty(Directive.Get(conf, "absent")) + check.Empty(t, Directive.Get(conf, "maxmemory")) + check.Empty(t, Directive.Get(conf, "absent")) } -func (s *ConfValTestSuite) TestDirectiveSetReplaces() { - s.Equal("port 6380", Directive.Set("port 6379", "port", "6380")) +func TestDirectiveSetReplaces(t *testing.T) { + check.Equal(t, Directive.Set("port 6379", "port", "6380"), "port 6380") } -func (s *ConfValTestSuite) TestDirectiveSetAppendsWhenMissing() { - s.Equal("port 6379\ntimeout 30", Directive.Set("port 6379", "timeout", "30")) +func TestDirectiveSetAppendsWhenMissing(t *testing.T) { + check.Equal(t, Directive.Set("port 6379", "timeout", "30"), "port 6379\ntimeout 30") } -func (s *ConfValTestSuite) TestDirectiveSetCommentsOutEmptyValue() { - s.Equal("# port 6379", Directive.Set("port 6379", "port", "")) +func TestDirectiveSetCommentsOutEmptyValue(t *testing.T) { + check.Equal(t, Directive.Set("port 6379", "port", ""), "# port 6379") // 已注释的保持原样,不重复加注释符 - s.Equal("# port 6379", Directive.Set("# port 6379", "port", "")) + check.Equal(t, Directive.Set("# port 6379", "port", ""), "# port 6379") } -func (s *ConfValTestSuite) TestDirectiveSetReenablesCommented() { - s.Equal("maxmemory 200mb", Directive.Set("# maxmemory 100mb", "maxmemory", "200mb")) +func TestDirectiveSetReenablesCommented(t *testing.T) { + check.Equal(t, Directive.Set("# maxmemory 100mb", "maxmemory", "200mb"), "maxmemory 200mb") } -func (s *ConfValTestSuite) TestDirectiveSetOnlyKeepsFirstMatch() { - s.Equal("port 6380", Directive.Set("port 6379\nport 7000", "port", "6380")) +func TestDirectiveSetOnlyKeepsFirstMatch(t *testing.T) { + check.Equal(t, Directive.Set("port 6379\nport 7000", "port", "6380"), "port 6380") } -func (s *ConfValTestSuite) TestSetStripsNewlinesFromValue() { - s.Equal("port 63opq79", Directive.Set("port 1", "port", "63\nopq\r79")) +func TestSetStripsNewlinesFromValue(t *testing.T) { + check.Equal(t, Directive.Set("port 1", "port", "63\nopq\r79"), "port 63opq79") } -func (s *ConfValTestSuite) TestFTPRequiresValueToMatch() { +func TestFTPRequiresValueToMatch(t *testing.T) { // 裸键行不算配置项,避免把开关误判为键值对 - s.Empty(FTP.Get("NoAnonymous\n", "NoAnonymous")) - s.Equal("yes", FTP.Get("NoAnonymous yes\n", "NoAnonymous")) + check.Empty(t, FTP.Get("NoAnonymous\n", "NoAnonymous")) + check.Equal(t, FTP.Get("NoAnonymous yes\n", "NoAnonymous"), "yes") } -func (s *ConfValTestSuite) TestPropertiesRoundTrip() { +func TestPropertiesRoundTrip(t *testing.T) { conf := "# broker\nnum.network.threads=3\n" - s.Equal("3", Properties.Get(conf, "num.network.threads")) - s.Equal("# broker\nnum.network.threads=5\n", Properties.Set(conf, "num.network.threads", "5")) + check.Equal(t, Properties.Get(conf, "num.network.threads"), "3") + check.Equal(t, Properties.Set(conf, "num.network.threads", "5"), "# broker\nnum.network.threads=5\n") } -func (s *ConfValTestSuite) TestNginxTerminatorAndIndent() { +func TestNginxTerminatorAndIndent(t *testing.T) { conf := "http {\n keepalive_timeout 60;\n}" - s.Equal("60", Nginx.Get(conf, "keepalive_timeout")) + check.Equal(t, Nginx.Get(conf, "keepalive_timeout"), "60") // 缩进保留,行尾分号补回 - s.Equal("http {\n keepalive_timeout 75;\n}", Nginx.Set(conf, "keepalive_timeout", "75")) + check.Equal(t, Nginx.Set(conf, "keepalive_timeout", "75"), "http {\n keepalive_timeout 75;\n}") } -func (s *ConfValTestSuite) TestNginxIgnoresLinesWithoutTerminator() { - s.Empty(Nginx.Get("http {\n keepalive_timeout 60\n}", "keepalive_timeout")) +func TestNginxIgnoresLinesWithoutTerminator(t *testing.T) { + check.Empty(t, Nginx.Get("http {\n keepalive_timeout 60\n}", "keepalive_timeout")) } -func (s *ConfValTestSuite) TestNginxKeepsTrailingComment() { +func TestNginxKeepsTrailingComment(t *testing.T) { conf := "http {\n keepalive_timeout 60; # 保持连接\n}" // 注释在分号之后,读取时不能混进值里 - s.Equal("60", Nginx.Get(conf, "keepalive_timeout")) - s.Equal("http {\n keepalive_timeout 75; # 保持连接\n}", Nginx.Set(conf, "keepalive_timeout", "75")) + check.Equal(t, Nginx.Get(conf, "keepalive_timeout"), "60") + check.Equal(t, Nginx.Set(conf, "keepalive_timeout", "75"), "http {\n keepalive_timeout 75; # 保持连接\n}") } -func (s *ConfValTestSuite) TestCommentOutKeepsWholeLine() { +func TestCommentOutKeepsWholeLine(t *testing.T) { // 注释掉时整行保留,行尾注释不丢 - s.Equal("# max_connections = 100 # note", Postgres.Set("max_connections = 100 # note", "max_connections", "")) + check.Equal(t, Postgres.Set("max_connections = 100 # note", "max_connections", ""), "# max_connections = 100 # note") } -func (s *ConfValTestSuite) TestNginxAppendsWithIndent() { - s.Equal("a b;\n c d;", Nginx.Set("a b;", "c", "d")) +func TestNginxAppendsWithIndent(t *testing.T) { + check.Equal(t, Nginx.Set("a b;", "c", "d"), "a b;\n c d;") } -func (s *ConfValTestSuite) TestPostgresQuotesAndInlineComment() { +func TestPostgresQuotesAndInlineComment(t *testing.T) { conf := "max_connections = 100 # note\nlisten_addresses = '*'\n" - s.Equal("100", Postgres.Get(conf, "max_connections")) - s.Equal("*", Postgres.Get(conf, "listen_addresses")) + check.Equal(t, Postgres.Get(conf, "max_connections"), "100") + check.Equal(t, Postgres.Get(conf, "listen_addresses"), "*") // 只替换值,行尾注释保留 - s.Equal("max_connections = '200' # note\nlisten_addresses = '*'\n", Postgres.Set(conf, "max_connections", "200")) + check.Equal(t, Postgres.Set(conf, "max_connections", "200"), "max_connections = '200' # note\nlisten_addresses = '*'\n") } -func (s *ConfValTestSuite) TestInlineCommentNotAppliedWhereUnsupported() { +func TestInlineCommentNotAppliedWhereUnsupported(t *testing.T) { // redis.conf 不支持行尾注释,密码里的 # 是数据不能当注释切掉 - s.Equal("p@ss#word", Directive.Get("requirepass p@ss#word\n", "requirepass")) - s.Equal("requirepass a#b", Directive.Set("requirepass p@ss#word", "requirepass", "a#b")) + check.Equal(t, Directive.Get("requirepass p@ss#word\n", "requirepass"), "p@ss#word") + check.Equal(t, Directive.Set("requirepass p@ss#word", "requirepass", "a#b"), "requirepass a#b") // java properties 同理 - s.Equal("a#b", Properties.Get("pass=a#b\n", "pass")) + check.Equal(t, Properties.Get("pass=a#b\n", "pass"), "a#b") } -func (s *ConfValTestSuite) TestQuotedCommentCharIsData() { - s.Equal("a#b", Postgres.Get("password = 'a#b' # real note\n", "password")) - s.Equal("password = 'x#y' # real note", Postgres.Set("password = 'a#b' # real note", "password", "x#y")) +func TestQuotedCommentCharIsData(t *testing.T) { + check.Equal(t, Postgres.Get("password = 'a#b' # real note\n", "password"), "a#b") + check.Equal(t, Postgres.Set("password = 'a#b' # real note", "password", "x#y"), "password = 'x#y' # real note") } -func (s *ConfValTestSuite) TestINIIgnoresSectionHeaders() { +func TestINIIgnoresSectionHeaders(t *testing.T) { conf := "[mysqld]\nport = 3306\n; skip-name-resolve = 1\n" - s.Equal("3306", INI.Get(conf, "port")) - s.Empty(INI.Get(conf, "mysqld")) + check.Equal(t, INI.Get(conf, "port"), "3306") + check.Empty(t, INI.Get(conf, "mysqld")) // 分号注释同样能被重新启用 - s.Equal("[mysqld]\nport = 3306\nskip-name-resolve = 2\n", INI.Set(conf, "skip-name-resolve", "2")) + check.Equal(t, INI.Set(conf, "skip-name-resolve", "2"), "[mysqld]\nport = 3306\nskip-name-resolve = 2\n") } -func (s *ConfValTestSuite) TestSectionINIMatchesOnlyTargetSection() { +func TestSectionINIMatchesOnlyTargetSection(t *testing.T) { conf := "[server]\nhttp_port = 3000\n\n[database]\nhttp_port = 9999\n" - s.Equal("3000", SectionINI.GetIn(conf, "server", "http_port")) - s.Equal("9999", SectionINI.GetIn(conf, "database", "http_port")) - s.Empty(SectionINI.GetIn(conf, "absent", "http_port")) + check.Equal(t, SectionINI.GetIn(conf, "server", "http_port"), "3000") + check.Equal(t, SectionINI.GetIn(conf, "database", "http_port"), "9999") + check.Empty(t, SectionINI.GetIn(conf, "absent", "http_port")) got := SectionINI.SetIn(conf, "database", "http_port", "8888") - s.Equal("3000", SectionINI.GetIn(got, "server", "http_port")) - s.Equal("8888", SectionINI.GetIn(got, "database", "http_port")) + check.Equal(t, SectionINI.GetIn(got, "server", "http_port"), "3000") + check.Equal(t, SectionINI.GetIn(got, "database", "http_port"), "8888") } -func (s *ConfValTestSuite) TestSectionINIInsertsInsideSection() { +func TestSectionINIInsertsInsideSection(t *testing.T) { conf := "[server]\nhttp_port = 3000\n\n[database]\ntype = sqlite3\n" got := SectionINI.SetIn(conf, "server", "domain", "example.com") - s.Equal("example.com", SectionINI.GetIn(got, "server", "domain")) + check.Equal(t, SectionINI.GetIn(got, "server", "domain"), "example.com") // 新项必须落在 server 段内,不能漏进 database 段 - s.Empty(SectionINI.GetIn(got, "database", "domain")) + check.Empty(t, SectionINI.GetIn(got, "database", "domain")) } -func (s *ConfValTestSuite) TestSectionINICreatesMissingSection() { +func TestSectionINICreatesMissingSection(t *testing.T) { got := SectionINI.SetIn("[server]\nhttp_port = 3000\n", "smtp", "host", "localhost:25") - s.Equal("localhost:25", SectionINI.GetIn(got, "smtp", "host")) - s.Equal("3000", SectionINI.GetIn(got, "server", "http_port")) + check.Equal(t, SectionINI.GetIn(got, "smtp", "host"), "localhost:25") + check.Equal(t, SectionINI.GetIn(got, "server", "http_port"), "3000") } -func (s *ConfValTestSuite) TestPHPINICommentsWithSemicolon() { - s.Equal("; memory_limit = 128M", PHPINI.Set("memory_limit = 128M", "memory_limit", "")) +func TestPHPINICommentsWithSemicolon(t *testing.T) { + check.Equal(t, PHPINI.Set("memory_limit = 128M", "memory_limit", ""), "; memory_limit = 128M") } -func (s *ConfValTestSuite) TestGetYAMLFlatAndNested() { - s.Equal("single-node", GetYAML(map[string]any{"discovery.type": "single-node"}, "discovery.type")) - s.Equal("single-node", GetYAML(map[string]any{"discovery": map[string]any{"type": "single-node"}}, "discovery.type")) - s.Empty(GetYAML(map[string]any{}, "discovery.type")) +func TestGetYAMLFlatAndNested(t *testing.T) { + check.Equal(t, GetYAML(map[string]any{"discovery.type": "single-node"}, "discovery.type"), "single-node") + check.Equal(t, GetYAML(map[string]any{"discovery": map[string]any{"type": "single-node"}}, "discovery.type"), "single-node") + check.Empty(t, GetYAML(map[string]any{}, "discovery.type")) } -func (s *ConfValTestSuite) TestSetYAMLFlattensAndClearsNested() { +func TestSetYAMLFlattensAndClearsNested(t *testing.T) { cfg := map[string]any{"discovery": map[string]any{"type": "old"}} SetYAML(cfg, "discovery.type", "single-node") - s.Equal("single-node", cfg["discovery.type"]) - // 嵌套键清空后整个父键一并移除 - _, ok := cfg["discovery"] - s.False(ok) + // 扁平键写入,嵌套键清空后整个父键一并移除 + check.DeepEqual(t, cfg, map[string]any{"discovery.type": "single-node"}) } -func (s *ConfValTestSuite) TestSetYAMLIgnoresEmptyValue() { +func TestSetYAMLIgnoresEmptyValue(t *testing.T) { cfg := map[string]any{} SetYAML(cfg, "discovery.type", "") - s.Empty(cfg) + check.Empty(t, cfg) } diff --git a/internal/apps/confval/toml_test.go b/internal/apps/confval/toml_test.go index 694bbeb0e..ec8f2b54f 100644 --- a/internal/apps/confval/toml_test.go +++ b/internal/apps/confval/toml_test.go @@ -3,82 +3,74 @@ package confval import ( "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" ) -type TOMLTestSuite struct { - suite.Suite -} - -func TestTOMLTestSuite(t *testing.T) { - suite.Run(t, new(TOMLTestSuite)) -} - -func (s *TOMLTestSuite) TestGetDottedKey() { +func TestGetDottedKey(t *testing.T) { conf := "bindPort = 7000\nauth.token = \"12345678\"\n# maxPortsPerClient = 0\n" - s.Equal("7000", GetTOML(conf, "bindPort")) - s.Equal("12345678", GetTOML(conf, "auth.token")) + check.Equal(t, GetTOML(conf, "bindPort"), "7000") + check.Equal(t, GetTOML(conf, "auth.token"), "12345678") // 注释掉的项视为未设置 - s.Empty(GetTOML(conf, "maxPortsPerClient")) - s.Empty(GetTOML(conf, "absent")) + check.Empty(t, GetTOML(conf, "maxPortsPerClient")) + check.Empty(t, GetTOML(conf, "absent")) } -func (s *TOMLTestSuite) TestGetSectionKey() { +func TestGetSectionKey(t *testing.T) { conf := "bindPort = 7000\n\n[auth]\nmethod = \"token\"\ntoken = \"abc\"\n" - s.Equal("token", GetTOML(conf, "auth.method")) - s.Equal("abc", GetTOML(conf, "auth.token")) + check.Equal(t, GetTOML(conf, "auth.method"), "token") + check.Equal(t, GetTOML(conf, "auth.token"), "abc") } -func (s *TOMLTestSuite) TestGetIgnoresProxyBlock() { +func TestGetIgnoresProxyBlock(t *testing.T) { conf := "serverAddr = \"1.1.1.1\"\n\n[[proxies]]\nname = \"ssh\"\nserverAddr = \"2.2.2.2\"\n" - s.Equal("1.1.1.1", GetTOML(conf, "serverAddr")) + check.Equal(t, GetTOML(conf, "serverAddr"), "1.1.1.1") } -func (s *TOMLTestSuite) TestSetReplacesInPlace() { +func TestSetReplacesInPlace(t *testing.T) { conf := "# 监听端口\nbindPort = 7000 # 默认\nauth.token = \"old\"\n" - s.Equal("# 监听端口\nbindPort = 7001 # 默认\nauth.token = \"old\"\n", SetTOML(conf, "bindPort", 7001)) - s.Equal("# 监听端口\nbindPort = 7000 # 默认\nauth.token = \"new\"\n", SetTOML(conf, "auth.token", "new")) + check.Equal(t, SetTOML(conf, "bindPort", 7001), "# 监听端口\nbindPort = 7001 # 默认\nauth.token = \"old\"\n") + check.Equal(t, SetTOML(conf, "auth.token", "new"), "# 监听端口\nbindPort = 7000 # 默认\nauth.token = \"new\"\n") } -func (s *TOMLTestSuite) TestSetReplacesInSection() { +func TestSetReplacesInSection(t *testing.T) { conf := "bindPort = 7000\n\n[auth]\ntoken = \"old\"\n" - s.Equal("bindPort = 7000\n\n[auth]\ntoken = \"new\"\n", SetTOML(conf, "auth.token", "new")) + check.Equal(t, SetTOML(conf, "auth.token", "new"), "bindPort = 7000\n\n[auth]\ntoken = \"new\"\n") } -func (s *TOMLTestSuite) TestSetInsertsBeforeFirstTable() { +func TestSetInsertsBeforeFirstTable(t *testing.T) { conf := "bindPort = 7000\n\n[[proxies]]\nname = \"ssh\"\n" - s.Equal("bindPort = 7000\n\nauth.token = \"abc\"\n[[proxies]]\nname = \"ssh\"\n", SetTOML(conf, "auth.token", "abc")) + check.Equal(t, SetTOML(conf, "auth.token", "abc"), "bindPort = 7000\n\nauth.token = \"abc\"\n[[proxies]]\nname = \"ssh\"\n") } -func (s *TOMLTestSuite) TestSetAppendsWhenNoTable() { - s.Equal("bindPort = 7000\nauth.token = \"abc\"", SetTOML("bindPort = 7000", "auth.token", "abc")) +func TestSetAppendsWhenNoTable(t *testing.T) { + check.Equal(t, SetTOML("bindPort = 7000", "auth.token", "abc"), "bindPort = 7000\nauth.token = \"abc\"") } -func (s *TOMLTestSuite) TestSetCommentsOutEmptyValue() { - s.Equal("# bindPort = 7000", SetTOML("bindPort = 7000", "bindPort", "")) - s.Equal("# bindPort = 7000", SetTOML("# bindPort = 7000", "bindPort", "")) +func TestSetCommentsOutEmptyValue(t *testing.T) { + check.Equal(t, SetTOML("bindPort = 7000", "bindPort", ""), "# bindPort = 7000") + check.Equal(t, SetTOML("# bindPort = 7000", "bindPort", ""), "# bindPort = 7000") // 键不存在时不应插入空值 - s.Equal("bindPort = 7000", SetTOML("bindPort = 7000", "auth.token", "")) + check.Equal(t, SetTOML("bindPort = 7000", "auth.token", ""), "bindPort = 7000") } -func (s *TOMLTestSuite) TestSetReenablesCommented() { - s.Equal("maxPortsPerClient = 5", SetTOML("# maxPortsPerClient = 0", "maxPortsPerClient", 5)) +func TestSetReenablesCommented(t *testing.T) { + check.Equal(t, SetTOML("# maxPortsPerClient = 0", "maxPortsPerClient", 5), "maxPortsPerClient = 5") } -func (s *TOMLTestSuite) TestSetBool() { - s.Equal("bindPort = 7000\ntransport.tls.force = true", SetTOML("bindPort = 7000", "transport.tls.force", true)) +func TestSetBool(t *testing.T) { + check.Equal(t, SetTOML("bindPort = 7000", "transport.tls.force", true), "bindPort = 7000\ntransport.tls.force = true") } -func (s *TOMLTestSuite) TestSetDoesNotTouchProxyBlock() { +func TestSetDoesNotTouchProxyBlock(t *testing.T) { conf := "serverAddr = \"1.1.1.1\"\n\n[[proxies]]\n# 手写的隧道\nname = \"ssh\"\nserverPort = 22\n" - s.Equal("serverAddr = \"2.2.2.2\"\n\n[[proxies]]\n# 手写的隧道\nname = \"ssh\"\nserverPort = 22\n", SetTOML(conf, "serverAddr", "2.2.2.2")) + check.Equal(t, SetTOML(conf, "serverAddr", "2.2.2.2"), "serverAddr = \"2.2.2.2\"\n\n[[proxies]]\n# 手写的隧道\nname = \"ssh\"\nserverPort = 22\n") // serverPort 只存在于 proxies 表内,不应被改写,而是插到首个表头前 - s.Equal("serverAddr = \"1.1.1.1\"\n\nserverPort = 7000\n[[proxies]]\n# 手写的隧道\nname = \"ssh\"\nserverPort = 22\n", SetTOML(conf, "serverPort", 7000)) + check.Equal(t, SetTOML(conf, "serverPort", 7000), "serverAddr = \"1.1.1.1\"\n\nserverPort = 7000\n[[proxies]]\n# 手写的隧道\nname = \"ssh\"\nserverPort = 22\n") } diff --git a/internal/apps/memcached/app.go b/internal/apps/memcached/app.go index 1a9f4da0c..21a5b5696 100644 --- a/internal/apps/memcached/app.go +++ b/internal/apps/memcached/app.go @@ -51,7 +51,8 @@ func (s *App) Load(w http.ResponseWriter, r *http.Request) { return } - conn, err := net.Dial("tcp", "127.0.0.1:11211") + var dialer net.Dialer + conn, err := dialer.DialContext(r.Context(), "tcp", "127.0.0.1:11211") if err != nil { service.Success(w, []types.NV{}) return diff --git a/internal/apps/mysql/app.go b/internal/apps/mysql/app.go index c1c6a23aa..bf24e9dc9 100644 --- a/internal/apps/mysql/app.go +++ b/internal/apps/mysql/app.go @@ -471,6 +471,10 @@ func (s *App) TransactionList(w http.ResponseWriter, r *http.Request) { } result.LockWaits = append(result.LockWaits, item) } + if lockRows.Err() != nil { + // 锁等待表结构不兼容,丢弃不完整结果 + result.LockWaits = nil + } } service.Success(w, result) diff --git a/internal/apps/nginx/app.go b/internal/apps/nginx/app.go index 322a9ef20..158c7ab36 100644 --- a/internal/apps/nginx/app.go +++ b/internal/apps/nginx/app.go @@ -26,7 +26,6 @@ type App struct { } func NewApp(t *gotext.Locale) *App { - return &App{ t: t, } diff --git a/internal/apps/opensearch/app.go b/internal/apps/opensearch/app.go index 34307e7f3..aa9bf5adc 100644 --- a/internal/apps/opensearch/app.go +++ b/internal/apps/opensearch/app.go @@ -27,7 +27,6 @@ type App struct { } func NewApp(t *gotext.Locale) *App { - return &App{t: t} } diff --git a/internal/apps/pgadmin/app.go b/internal/apps/pgadmin/app.go index fa440241d..df7ced7a5 100644 --- a/internal/apps/pgadmin/app.go +++ b/internal/apps/pgadmin/app.go @@ -194,15 +194,14 @@ func escapePgpass(s string) string { } // existingServers 只读 pgAdmin 配置库查询 Servers 组内已注册的服务器 -// CLI 每次调用都要冷启动整个 pgAdmin 应用,直读库快数个量级 -func (s *App) existingServers(email string) (map[string]struct{}, error) { +func (s *App) existingServers(ctx context.Context, email string) (map[string]struct{}, error) { db, err := sql.Open("sqlite", fmt.Sprintf("file:%s/data/pgadmin.db?mode=ro", s.path())) if err != nil { return nil, err } defer func() { _ = db.Close() }() - rows, err := db.Query(`SELECT s.host, s.port, s.username FROM server s + rows, err := db.QueryContext(ctx, `SELECT s.host, s.port, s.username FROM server s JOIN servergroup g ON s.servergroup_id = g.id JOIN "user" u ON s.user_id = u.id WHERE u.email = ? AND g.name = 'Servers'`, email) @@ -295,7 +294,7 @@ func (s *App) syncServers(ctx context.Context, email string) error { } // 查询 pgAdmin 已有服务器用于查缺,直读配置库,异常时回退 CLI 导出 - existing, err := s.existingServers(email) + existing, err := s.existingServers(ctx, email) if err != nil { existing = s.dumpExistingServers(email) } diff --git a/internal/apps/prometheus/app.go b/internal/apps/prometheus/app.go index d0d855436..e658d9305 100644 --- a/internal/apps/prometheus/app.go +++ b/internal/apps/prometheus/app.go @@ -31,7 +31,6 @@ type App struct { } func NewApp(conf *config.Config, t *gotext.Locale, taskRepo biz.TaskRepo) *App { - return &App{t: t, conf: conf, taskRepo: taskRepo} } diff --git a/internal/apps/pureftpd/app.go b/internal/apps/pureftpd/app.go index c7a1c4489..77781a5e2 100644 --- a/internal/apps/pureftpd/app.go +++ b/internal/apps/pureftpd/app.go @@ -27,7 +27,6 @@ type App struct { } func NewApp(t *gotext.Locale) *App { - return &App{ t: t, } diff --git a/internal/apps/rocketmq/app.go b/internal/apps/rocketmq/app.go index 829b44e2d..e5cb32327 100644 --- a/internal/apps/rocketmq/app.go +++ b/internal/apps/rocketmq/app.go @@ -21,7 +21,6 @@ type App struct { } func NewApp(t *gotext.Locale) *App { - return &App{t: t} } diff --git a/internal/apps/rsync/app.go b/internal/apps/rsync/app.go index 73cbd36de..efa975c3e 100644 --- a/internal/apps/rsync/app.go +++ b/internal/apps/rsync/app.go @@ -19,7 +19,6 @@ type App struct { } func NewApp(t *gotext.Locale) *App { - return &App{ t: t, } diff --git a/internal/apps/s3fs/app.go b/internal/apps/s3fs/app.go index b688fc43f..a4272a0d9 100644 --- a/internal/apps/s3fs/app.go +++ b/internal/apps/s3fs/app.go @@ -24,7 +24,6 @@ type App struct { } func NewApp(t *gotext.Locale) *App { - return &App{ t: t, } diff --git a/internal/apps/apps.go b/internal/apps/wire.go similarity index 50% rename from internal/apps/apps.go rename to internal/apps/wire.go index 0f61187c2..6a2c28625 100644 --- a/internal/apps/apps.go +++ b/internal/apps/wire.go @@ -1,7 +1,9 @@ +//go:build wireinject + package apps import ( - "github.com/google/wire" + "github.com/libtnb/wire" "github.com/acepanel/panel/v3/internal/apps/apache" "github.com/acepanel/panel/v3/internal/apps/caddy" @@ -38,15 +40,71 @@ import ( "github.com/acepanel/panel/v3/internal/apps/valkey" ) -var ProviderSet = wire.NewSet( - apache.NewApp, caddy.NewApp, clickhouse.NewApp, codeserver.NewApp, - docker.NewApp, elasticsearch.NewApp, fail2ban.NewApp, - frp.NewApp, gitea.NewApp, grafana.NewApp, - kafka.NewApp, mariadb.NewApp, memcached.NewApp, - minio.NewApp, mongodb.NewApp, mysql.NewApp, - nginx.NewApp, openlitespeed.NewApp, openresty.NewApp, opensearch.NewApp, - percona.NewApp, pgadmin.NewApp, phpmyadmin.NewApp, podman.NewApp, - postgresql.NewApp, prometheus.NewApp, pureftpd.NewApp, - redis.NewApp, rocketmq.NewApp, rsync.NewApp, - s3fs.NewApp, supervisor.NewApp, valkey.NewApp, -) +// Module 装配全部子应用 +var Module = wire.New(). + Provide(apache.NewApp). + Provide(caddy.NewApp). + Provide(clickhouse.NewApp). + Provide(codeserver.NewApp). + Provide(docker.NewApp). + Provide(elasticsearch.NewApp). + Provide(fail2ban.NewApp). + Provide(frp.NewApp). + Provide(gitea.NewApp). + Provide(grafana.NewApp). + Provide(kafka.NewApp). + Provide(mariadb.NewApp). + Provide(memcached.NewApp). + Provide(minio.NewApp). + Provide(mongodb.NewApp). + Provide(mysql.NewApp). + Provide(nginx.NewApp). + Provide(openlitespeed.NewApp). + Provide(openresty.NewApp). + Provide(opensearch.NewApp). + Provide(percona.NewApp). + Provide(pgadmin.NewApp). + Provide(phpmyadmin.NewApp). + Provide(podman.NewApp). + Provide(postgresql.NewApp). + Provide(prometheus.NewApp). + Provide(pureftpd.NewApp). + Provide(redis.NewApp). + Provide(rocketmq.NewApp). + Provide(rsync.NewApp). + Provide(s3fs.NewApp). + Provide(supervisor.NewApp). + Provide(valkey.NewApp). + Export[*apache.App](). + Export[*caddy.App](). + Export[*clickhouse.App](). + Export[*codeserver.App](). + Export[*docker.App](). + Export[*elasticsearch.App](). + Export[*fail2ban.App](). + Export[*frp.App](). + Export[*gitea.App](). + Export[*grafana.App](). + Export[*kafka.App](). + Export[*mariadb.App](). + Export[*memcached.App](). + Export[*minio.App](). + Export[*mongodb.App](). + Export[*mysql.App](). + Export[*nginx.App](). + Export[*openlitespeed.App](). + Export[*openresty.App](). + Export[*opensearch.App](). + Export[*percona.App](). + Export[*pgadmin.App](). + Export[*phpmyadmin.App](). + Export[*podman.App](). + Export[*postgresql.App](). + Export[*prometheus.App](). + Export[*pureftpd.App](). + Export[*redis.App](). + Export[*rocketmq.App](). + Export[*rsync.App](). + Export[*s3fs.App](). + Export[*supervisor.App](). + Export[*valkey.App]() diff --git a/internal/biz/alert.go b/internal/biz/alert.go index 239ef1ece..fa44a4b0b 100644 --- a/internal/biz/alert.go +++ b/internal/biz/alert.go @@ -368,7 +368,7 @@ func (uc *AlertUsecase) evaluateMetric(ctx context.Context, rule *AlertRule, met uc.mu.Unlock() return } - silence := time.Duration(rule.Silence) * time.Minute + silence := time.Duration(rule.Silence) * time.Minute //nolint:gosec uc.silenced[key] = now.Add(silence) uc.mu.Unlock() diff --git a/internal/biz/backup.go b/internal/biz/backup.go index e321cdf55..9749a1178 100644 --- a/internal/biz/backup.go +++ b/internal/biz/backup.go @@ -29,7 +29,7 @@ type BackupRepo interface { Create(ctx context.Context, typ BackupType, target string, account uint) error CreatePanel() error Delete(typ BackupType, name string) error - Restore(typ BackupType, backup, target string) error + Restore(ctx context.Context, typ BackupType, backup, target string) error ClearExpired(path, prefix string, save uint) error ClearStorageExpired(account uint, dir, prefix string, save uint) error CutoffLog(path, target string) (string, error) @@ -94,7 +94,7 @@ func (uc *BackupUsecase) Delete(ctx context.Context, typ BackupType, name string } func (uc *BackupUsecase) Restore(ctx context.Context, typ BackupType, backup, target string) error { - if err := uc.repo.Restore(typ, backup, target); err != nil { + if err := uc.repo.Restore(ctx, typ, backup, target); err != nil { return err } diff --git a/internal/biz/backup_storage.go b/internal/biz/backup_storage.go index 0a29c01be..bd5f36e08 100644 --- a/internal/biz/backup_storage.go +++ b/internal/biz/backup_storage.go @@ -76,6 +76,7 @@ func (r *BackupStorage) BeforeSave(tx *gorm.DB) error { return err } return nil + default: } return nil @@ -125,6 +126,7 @@ func (r *BackupStorage) AfterFind(tx *gorm.DB) error { r.Info.Password = string(password) } return nil + default: } return nil diff --git a/internal/biz/biz.go b/internal/biz/biz.go deleted file mode 100644 index 635bb7eff..000000000 --- a/internal/biz/biz.go +++ /dev/null @@ -1,18 +0,0 @@ -package biz - -import "github.com/google/wire" - -var ProviderSet = wire.NewSet( - NewAlertUsecase, NewAppUsecase, NewBackupUsecase, NewBackupAccountUsecase, - NewCacheUsecase, NewCertUsecase, NewCertAccountUsecase, - NewCertDNSUsecase, NewContainerUsecase, NewContainerComposeUsecase, - NewContainerImageUsecase, NewContainerNetworkUsecase, NewContainerVolumeUsecase, - NewCronUsecase, NewDatabaseUsecase, NewDatabaseRedisUsecase, - NewDatabaseElasticsearchUsecase, NewDatabaseServerUsecase, NewDatabaseUserUsecase, - NewEnvironmentUsecase, NewFileShareUsecase, NewLogUsecase, NewMonitorUsecase, - NewNotifyUsecase, NewProjectUsecase, NewSafeUsecase, NewScanEventUsecase, - NewSettingUsecase, NewSSHUsecase, NewTamperUsecase, NewTaskUsecase, - NewTemplateUsecase, NewUserUsecase, NewUserPasskeyUsecase, - NewUserTokenUsecase, NewWebHookUsecase, NewWebsiteUsecase, - NewWebsiteStatUsecase, NewToolboxMigrationUsecase, -) diff --git a/internal/biz/cert.go b/internal/biz/cert.go index c77439222..6b5dc8e1b 100644 --- a/internal/biz/cert.go +++ b/internal/biz/cert.go @@ -175,10 +175,6 @@ func (uc *CertUsecase) Delete(ctx context.Context, id uint) error { return nil } -func (uc *CertUsecase) ObtainAuto(id uint) (*acme.Certificate, error) { - return uc.ObtainAutoWithProgressCallback(context.Background(), id, nil) -} - func (uc *CertUsecase) ObtainAutoWithProgressCallback(ctx context.Context, id uint, progressCallback func(string)) (*acme.Certificate, error) { report := func(msg string) { if progressCallback != nil { @@ -298,10 +294,6 @@ func (uc *CertUsecase) ObtainSelfSigned(id uint) error { return nil } -func (uc *CertUsecase) Renew(id uint) (*acme.Certificate, error) { - return uc.RenewWithProgressCallback(context.Background(), id, nil) -} - func (uc *CertUsecase) RenewWithProgressCallback(ctx context.Context, id uint, progressCallback func(string)) (*acme.Certificate, error) { report := func(msg string) { if progressCallback != nil { @@ -380,7 +372,7 @@ func (uc *CertUsecase) RenewWithProgressCallback(ctx context.Context, id uint, p return &ssl, nil } -func (uc *CertUsecase) RefreshRenewalInfo(id uint) (mholtacme.RenewalInfo, error) { +func (uc *CertUsecase) RefreshRenewalInfo(ctx context.Context, id uint) (mholtacme.RenewalInfo, error) { cert, err := uc.repo.Get(id) if err != nil { return mholtacme.RenewalInfo{}, err @@ -395,9 +387,9 @@ func (uc *CertUsecase) RefreshRenewalInfo(id uint) (mholtacme.RenewalInfo, error return mholtacme.RenewalInfo{}, err } - ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) + infoCtx, cancel := context.WithTimeout(ctx, 1*time.Minute) defer cancel() - renewInfo, err := client.GetRenewalInfo(ctx, crt) + renewInfo, err := client.GetRenewalInfo(infoCtx, crt) if err != nil { return mholtacme.RenewalInfo{}, err } diff --git a/internal/biz/cert_account.go b/internal/biz/cert_account.go index 94d54c16e..34b3919f3 100644 --- a/internal/biz/cert_account.go +++ b/internal/biz/cert_account.go @@ -59,7 +59,7 @@ func (uc *CertAccountUsecase) List(page, limit uint) ([]*CertAccount, int64, err return uc.repo.List(page, limit) } -func (uc *CertAccountUsecase) GetDefault(userID uint) (*CertAccount, error) { +func (uc *CertAccountUsecase) GetDefault(ctx context.Context, userID uint) (*CertAccount, error) { user, err := uc.userRepo.Get(userID) if err != nil { return nil, err @@ -76,7 +76,7 @@ func (uc *CertAccountUsecase) GetDefault(userID uint) (*CertAccount, error) { KeyType: string(acme.KeyEC256), } - return uc.Create(context.Background(), req) + return uc.Create(ctx, req) } func (uc *CertAccountUsecase) Get(id uint) (*CertAccount, error) { diff --git a/internal/biz/database.go b/internal/biz/database.go index c0e3a3420..abafbe5c8 100644 --- a/internal/biz/database.go +++ b/internal/biz/database.go @@ -93,7 +93,7 @@ func (uc *DatabaseUsecase) Create(ctx context.Context, req *request.DatabaseCrea return mongoErr } defer mongo.Close() - if mongoErr = mongo.DatabaseCreate(req.Name); mongoErr != nil { + if mongoErr = mongo.DatabaseCreate(req.Name); mongoErr != nil { //nolint:contextcheck return mongoErr } uc.log.Info("database created", slog.String("type", OperationTypeDatabase), slog.Uint64("operator_id", operatorID(ctx)), slog.String("name", req.Name), slog.Uint64("server_id", uint64(req.ServerID))) @@ -154,7 +154,11 @@ func (uc *DatabaseUsecase) Create(ctx context.Context, req *request.DatabaseCrea return err } } - if err = operator.(*db.Postgres).DatabaseComment(req.Name, req.Comment); err != nil { + pg, ok := operator.(*db.Postgres) + if !ok { + return errors.New(uc.t.Get("%s does not support database comment", server.Type)) + } + if err = pg.DatabaseComment(req.Name, req.Comment); err != nil { //nolint:contextcheck return err } case DatabaseTypeClickHouse: @@ -175,6 +179,7 @@ func (uc *DatabaseUsecase) Create(ctx context.Context, req *request.DatabaseCrea return err } } + default: } // 记录日志 @@ -214,7 +219,7 @@ func (uc *DatabaseUsecase) Delete(ctx context.Context, serverID uint, name strin return mongoErr } defer mongo.Close() - if mongoErr = mongo.DatabaseDrop(name); mongoErr != nil { + if mongoErr = mongo.DatabaseDrop(name); mongoErr != nil { //nolint:contextcheck return mongoErr } case DatabaseTypeSQLite: @@ -249,7 +254,11 @@ func (uc *DatabaseUsecase) Comment(ctx context.Context, req *request.DatabaseCom return opErr } defer operator.Close() - return operator.(*db.Postgres).DatabaseComment(req.Name, req.Comment) + pg, ok := operator.(*db.Postgres) + if !ok { + return errors.New(uc.t.Get("%s does not support database comment", server.Type)) + } + return pg.DatabaseComment(req.Name, req.Comment) //nolint:contextcheck default: return errors.New(uc.t.Get("%s does not support database comment", server.Type)) } diff --git a/internal/biz/database_server.go b/internal/biz/database_server.go index f1cd6b256..b1bc40b9e 100644 --- a/internal/biz/database_server.go +++ b/internal/biz/database_server.go @@ -50,7 +50,6 @@ func (r *DatabaseServer) BeforeSave(tx *gorm.DB) error { } return nil - } func (r *DatabaseServer) AfterFind(tx *gorm.DB) error { @@ -182,7 +181,8 @@ func (uc *DatabaseServerUsecase) Sync(ctx context.Context, id uint) error { // 非 Operator 类型不支持用户同步 switch server.Type { - case DatabaseTypeRedis, DatabaseTypeMongoDB, DatabaseTypeSQLite, DatabaseTypeElasticsearch: + case DatabaseTypeMysql, DatabaseTypePostgresql, DatabaseTypeClickHouse: + default: return fmt.Errorf("sync is not supported for %s", server.Type) } @@ -256,6 +256,7 @@ func (uc *DatabaseServerUsecase) Sync(ctx context.Context, id uint) error { } } } + default: } return nil diff --git a/internal/biz/database_user.go b/internal/biz/database_user.go index 4524372e6..700eec3db 100644 --- a/internal/biz/database_user.go +++ b/internal/biz/database_user.go @@ -48,7 +48,6 @@ func (r *DatabaseUser) BeforeSave(tx *gorm.DB) error { } return nil - } func (r *DatabaseUser) AfterFind(tx *gorm.DB) error { @@ -263,6 +262,7 @@ func (uc *DatabaseUserUsecase) DeleteByNames(ctx context.Context, serverID uint, for name := range slices.Values(names) { _ = operator.UserDrop(name) } + default: } return uc.repo.DeleteByServerNames(serverID, names) diff --git a/internal/biz/file_share.go b/internal/biz/file_share.go index 1fb22fb7d..e7444b358 100644 --- a/internal/biz/file_share.go +++ b/internal/biz/file_share.go @@ -46,6 +46,7 @@ func (uc *FileShareUsecase) List() ([]*FileShare, error) { // Create 创建分享,同一路径可重复分享为多条独立记录 func (uc *FileShareUsecase) Create(ctx context.Context, req *request.FileShareCreate) (*FileShare, error) { + //nolint:gosec share, err := uc.repo.Create(req.Path, req.MaxDownloads, time.Now().Add(time.Duration(req.ExpireHours)*time.Hour)) if err != nil { return nil, err diff --git a/internal/biz/notify.go b/internal/biz/notify.go index 3a8c15939..669763ccf 100644 --- a/internal/biz/notify.go +++ b/internal/biz/notify.go @@ -221,6 +221,8 @@ func (uc *NotifyUsecase) Send(ctx context.Context, channelIDs []uint, subject, b // SendEvent 发送系统事件通知,不阻塞业务流程 // 待发送数超过上限时丢弃并告知,避免慢渠道拖垮调用方 +// +//nolint:contextcheck,nolintlint func (uc *NotifyUsecase) SendEvent(event NotifyEvent, subject, body string) { select { case uc.pending <- struct{}{}: diff --git a/internal/biz/project.go b/internal/biz/project.go index f89784b98..e74eed439 100644 --- a/internal/biz/project.go +++ b/internal/biz/project.go @@ -33,7 +33,7 @@ type ProjectRepo interface { Create(project *Project, req *request.ProjectCreate) error Save(project *Project) error Delete(project *Project) error - RenameUnitFile(old, new string) error + RenameUnitFile(oldName, newName string) error RemoveUnitFile(name string) error UpdateUnitFile(name string, req *request.ProjectUpdate) error } diff --git a/internal/biz/setting.go b/internal/biz/setting.go index d81723f46..4d15becfb 100644 --- a/internal/biz/setting.go +++ b/internal/biz/setting.go @@ -218,7 +218,7 @@ func (uc *SettingUsecase) UpdatePanel(ctx context.Context, req *request.SettingP } } if needGen { - crt, key, err := cert.GenerateSelfSigned(tools.CollectLocalNames()) + crt, key, err := cert.GenerateSelfSigned(tools.CollectLocalNames()) //nolint:contextcheck if err != nil { return false, errors.New(uc.t.Get("failed to generate self-signed certificate: %v", err)) } @@ -258,7 +258,7 @@ func (uc *SettingUsecase) UpdatePanel(ctx context.Context, req *request.SettingP } if req.Port != conf.HTTP.Port { - if os.TCPPortInUse(req.Port) { + if os.TCPPortInUse(req.Port) { //nolint:contextcheck return false, errors.New(uc.t.Get("port is already in use")) } // 放行端口 diff --git a/internal/biz/tamper.go b/internal/biz/tamper.go index c1d764045..655bbb4c0 100644 --- a/internal/biz/tamper.go +++ b/internal/biz/tamper.go @@ -1,6 +1,7 @@ package biz import ( + "context" "errors" "fmt" "log/slog" @@ -99,8 +100,8 @@ func (uc *TamperUsecase) DetectEBPF() tamper.EBPFStatus { } // EnableBPFLSMGrub 修改 grub 激活 bpf LSM(需重启系统生效) -func (uc *TamperUsecase) EnableBPFLSMGrub() error { - return tamper.EnableBPFLSMGrub() +func (uc *TamperUsecase) EnableBPFLSMGrub(ctx context.Context) error { + return tamper.EnableBPFLSMGrub(ctx) } // GetSetting 读取全局设置 diff --git a/internal/biz/toolbox_migration_import.go b/internal/biz/toolbox_migration_import.go index 4bd82a99f..5aa40d429 100644 --- a/internal/biz/toolbox_migration_import.go +++ b/internal/biz/toolbox_migration_import.go @@ -355,6 +355,8 @@ func (uc *ToolboxMigrationUsecase) importProject(ctx context.Context, detail *ty )), nil case types.ProjectTypeGeneral: return append(warnings, uc.t.Get("the project was not started; start it manually")), nil + default: + // 其余类型依赖随文件一起迁移,可直接启动 } if project.Enabled { _, _ = shell.Exec("systemctl enable " + strconv.Quote(detail.Item.TargetName)) @@ -413,6 +415,8 @@ func (uc *ToolboxMigrationUsecase) rewriteExecStart(project *types.MigrationProj case "npm", "npx", "corepack": executable = filepath.Join(app.Root, "server", "nodejs", slug, "bin", base) } + default: + // 通用类型没有面板托管的运行时,不改写启动命令 } if executable == "" { return execStart @@ -490,9 +494,9 @@ func (uc *ToolboxMigrationUsecase) removeDependencies(root string, typ types.Pro } _ = filepath.WalkDir(root, func(path string, entry os.DirEntry, err error) error { if err != nil || !entry.IsDir() || path == root || !slices.Contains(names, entry.Name()) { - return nil + return nil //nolint:nilerr } - _ = os.RemoveAll(path) + _ = os.RemoveAll(path) //nolint:gosec return filepath.SkipDir }) } diff --git a/internal/biz/website.go b/internal/biz/website.go index d38d4d023..971299ca9 100644 --- a/internal/biz/website.go +++ b/internal/biz/website.go @@ -262,7 +262,7 @@ func (uc *WebsiteUsecase) ObtainCert(ctx context.Context, id uint, dnsID uint) e return errors.New(uc.t.Get("wildcard domains require DNS verification, please select a DNS provider")) } - account, err := uc.certAccount.GetDefault(cast.ToUint(ctx.Value("user_id"))) + account, err := uc.certAccount.GetDefault(ctx, cast.ToUint(ctx.Value("user_id"))) if err != nil { return err } @@ -291,7 +291,7 @@ func (uc *WebsiteUsecase) ObtainCert(ctx context.Context, id uint, dnsID uint) e return err } - _, err = uc.cert.ObtainAuto(newCert.ID) + _, err = uc.cert.ObtainAutoWithProgressCallback(ctx, newCert.ID, nil) if err != nil { return err } diff --git a/internal/biz/wire.go b/internal/biz/wire.go new file mode 100644 index 000000000..834b2d7c8 --- /dev/null +++ b/internal/biz/wire.go @@ -0,0 +1,86 @@ +//go:build wireinject + +package biz + +import "github.com/libtnb/wire" + +// Module 装配业务逻辑层 +var Module = wire.New(). + Provide(NewAlertUsecase). + Provide(NewAppUsecase). + Provide(NewBackupUsecase). + Provide(NewBackupAccountUsecase). + Provide(NewCacheUsecase). + Provide(NewCertUsecase). + Provide(NewCertAccountUsecase). + Provide(NewCertDNSUsecase). + Provide(NewContainerUsecase). + Provide(NewContainerComposeUsecase). + Provide(NewContainerImageUsecase). + Provide(NewContainerNetworkUsecase). + Provide(NewContainerVolumeUsecase). + Provide(NewCronUsecase). + Provide(NewDatabaseUsecase). + Provide(NewDatabaseRedisUsecase). + Provide(NewDatabaseElasticsearchUsecase). + Provide(NewDatabaseServerUsecase). + Provide(NewDatabaseUserUsecase). + Provide(NewEnvironmentUsecase). + Provide(NewFileShareUsecase). + Provide(NewLogUsecase). + Provide(NewMonitorUsecase). + Provide(NewNotifyUsecase). + Provide(NewProjectUsecase). + Provide(NewSafeUsecase). + Provide(NewScanEventUsecase). + Provide(NewSettingUsecase). + Provide(NewSSHUsecase). + Provide(NewTamperUsecase). + Provide(NewTaskUsecase). + Provide(NewTemplateUsecase). + Provide(NewUserUsecase). + Provide(NewUserPasskeyUsecase). + Provide(NewUserTokenUsecase). + Provide(NewWebHookUsecase). + Provide(NewWebsiteUsecase). + Provide(NewWebsiteStatUsecase). + Provide(NewToolboxMigrationUsecase). + Export[*AlertUsecase](). + Export[*AppUsecase](). + Export[*BackupUsecase](). + Export[*BackupAccountUsecase](). + Export[*CacheUsecase](). + Export[*CertUsecase](). + Export[*CertAccountUsecase](). + Export[*CertDNSUsecase](). + Export[*ContainerUsecase](). + Export[*ContainerComposeUsecase](). + Export[*ContainerImageUsecase](). + Export[*ContainerNetworkUsecase](). + Export[*ContainerVolumeUsecase](). + Export[*CronUsecase](). + Export[*DatabaseUsecase](). + Export[*DatabaseRedisUsecase](). + Export[*DatabaseElasticsearchUsecase](). + Export[*DatabaseServerUsecase](). + Export[*DatabaseUserUsecase](). + Export[*EnvironmentUsecase](). + Export[*FileShareUsecase](). + Export[*LogUsecase](). + Export[*MonitorUsecase](). + Export[*NotifyUsecase](). + Export[*ProjectUsecase](). + Export[*SafeUsecase](). + Export[*ScanEventUsecase](). + Export[*SettingUsecase](). + Export[*SSHUsecase](). + Export[*TamperUsecase](). + Export[*TaskUsecase](). + Export[*TemplateUsecase](). + Export[*UserUsecase](). + Export[*UserPasskeyUsecase](). + Export[*UserTokenUsecase](). + Export[*WebHookUsecase](). + Export[*WebsiteUsecase](). + Export[*WebsiteStatUsecase](). + Export[*ToolboxMigrationUsecase]() diff --git a/internal/bootstrap/bootstrap.go b/internal/bootstrap/bootstrap.go deleted file mode 100644 index 76e258e66..000000000 --- a/internal/bootstrap/bootstrap.go +++ /dev/null @@ -1,29 +0,0 @@ -package bootstrap - -import ( - "github.com/google/wire" - - "github.com/acepanel/panel/v3/internal/middleware" - "github.com/acepanel/panel/v3/pkg/websitestat" -) - -// ProviderSet 装配基础设施层 -var ProviderSet = wire.NewSet( - NewConf, - NewT, - NewLogger, - NewSlog, - NewDB, - NewMigrate, - NewSession, - NewRunner, - NewValidator, - middleware.NewMiddlewares, - NewLoader, - NewRouter, - NewTLSReloader, - NewHttp, - NewCron, - NewCli, - websitestat.NewAggregator, -) diff --git a/internal/bootstrap/cli.go b/internal/bootstrap/cli.go index f2d2dd42e..d46f70da6 100644 --- a/internal/bootstrap/cli.go +++ b/internal/bootstrap/cli.go @@ -10,7 +10,6 @@ import ( ) func NewCli(t *gotext.Locale, commands []*cli.Command) *cli.Command { - cli.RootCommandHelpTemplate = strings.ReplaceAll(cli.RootCommandHelpTemplate, "NAME", t.Get("NAME")) cli.RootCommandHelpTemplate = strings.ReplaceAll(cli.RootCommandHelpTemplate, "USAGE", t.Get("USAGE")) cli.RootCommandHelpTemplate = strings.ReplaceAll(cli.RootCommandHelpTemplate, "VERSION", t.Get("VERSION")) diff --git a/internal/bootstrap/db.go b/internal/bootstrap/db.go index ca0197c9c..8f5a858d0 100644 --- a/internal/bootstrap/db.go +++ b/internal/bootstrap/db.go @@ -17,7 +17,6 @@ import ( ) func NewDB(conf *config.Config) (*gorm.DB, error) { - // db 日志写入轮转文件 w, err := logrotate.New(filepath.Join(app.Root, "panel/storage/logs/db.log"), logrotate.WithMaxSize(10*logrotate.MB), diff --git a/internal/bootstrap/http.go b/internal/bootstrap/http.go index dacb8a0a5..20941f1a4 100644 --- a/internal/bootstrap/http.go +++ b/internal/bootstrap/http.go @@ -10,6 +10,7 @@ import ( "net/http" "path/filepath" "strings" + "time" "github.com/bddjr/hlfhr" "github.com/go-chi/chi/v5" @@ -80,7 +81,6 @@ func NewRouter(loader *apploader.Loader, conf *config.Config, t *gotext.Locale, } func NewTLSReloader(conf *config.Config) (*tlscert.Reloader, error) { - if !conf.HTTP.IsHTTPS() { return nil, nil } @@ -95,13 +95,13 @@ func NewTLSReloader(conf *config.Config) (*tlscert.Reloader, error) { } func NewHttp(router *chi.Mux, conf *config.Config, reloader *tlscert.Reloader) *hlfhr.Server { - mux := router srv := hlfhr.New(&http.Server{ - Addr: fmt.Sprintf(":%d", conf.HTTP.Port), - Handler: mux, - MaxHeaderBytes: 4 << 20, + Addr: fmt.Sprintf(":%d", conf.HTTP.Port), + Handler: mux, + MaxHeaderBytes: 4 << 20, + ReadHeaderTimeout: 30 * time.Second, }) srv.Listen80RedirectTo443 = true diff --git a/internal/bootstrap/logger.go b/internal/bootstrap/logger.go index ea7c7d351..f2ae23d03 100644 --- a/internal/bootstrap/logger.go +++ b/internal/bootstrap/logger.go @@ -16,7 +16,7 @@ type Logger struct { } // NewLogger 构建写入轮转文件的应用日志。 -func NewLogger(conf *config.Config) (*Logger, func(), error) { +func NewLogger(conf *config.Config) (*Logger, func() error, error) { w, err := logrotate.New(filepath.Join(app.Root, "panel/storage/logs/app.log"), logrotate.WithMaxSize(10*logrotate.MB), logrotate.WithMaxAge(30*logrotate.Day), @@ -38,8 +38,7 @@ func NewLogger(conf *config.Config) (*Logger, func(), error) { })) slog.SetDefault(log) - cleanup := func() { _ = w.Close() } - return &Logger{Logger: log}, cleanup, nil + return &Logger{Logger: log}, w.Close, nil } // NewSlog 解包出纯 *slog.Logger 供应用其余部分使用。 diff --git a/internal/bootstrap/t.go b/internal/bootstrap/t.go index 5f92797d7..5f2e29b03 100644 --- a/internal/bootstrap/t.go +++ b/internal/bootstrap/t.go @@ -8,7 +8,6 @@ import ( ) func NewT(conf *config.Config) *gotext.Locale { - l := gotext.NewLocaleFSWithPath(conf.App.Locale, embed.LocalesFS, "locales") l.AddDomain("backend") diff --git a/internal/bootstrap/wire.go b/internal/bootstrap/wire.go new file mode 100644 index 000000000..e596a1da1 --- /dev/null +++ b/internal/bootstrap/wire.go @@ -0,0 +1,60 @@ +//go:build wireinject + +package bootstrap + +import ( + "log/slog" + + "github.com/bddjr/hlfhr" + "github.com/go-chi/chi/v5" + "github.com/go-gormigrate/gormigrate/v2" + "github.com/leonelquinteros/gotext" + "github.com/libtnb/cron" + "github.com/libtnb/sessions" + "github.com/libtnb/validator" + "github.com/libtnb/wire" + "github.com/urfave/cli/v3" + "gorm.io/gorm" + + "github.com/acepanel/panel/v3/internal/middleware" + "github.com/acepanel/panel/v3/pkg/apploader" + "github.com/acepanel/panel/v3/pkg/config" + "github.com/acepanel/panel/v3/pkg/tlscert" + "github.com/acepanel/panel/v3/pkg/types" + "github.com/acepanel/panel/v3/pkg/websitestat" +) + +// Module 装配基础设施层,*Logger 与 *middleware.Middlewares 仅本层内部使用,不导出 +var Module = wire.New(). + Provide(NewConf). + Provide(NewT). + Provide(NewLogger). + Provide(NewSlog). + Provide(NewDB). + Provide(NewMigrate). + Provide(NewSession). + Provide(NewRunner). + Provide(NewValidator). + Provide(middleware.NewMiddlewares). + Provide(NewLoader). + Provide(NewRouter). + Provide(NewTLSReloader). + Provide(NewHttp). + Provide(NewCron). + Provide(NewCli). + Provide(websitestat.NewAggregator). + Export[*config.Config](). + Export[*gotext.Locale](). + Export[*slog.Logger](). + Export[*gorm.DB](). + Export[*gormigrate.Gormigrate](). + Export[*sessions.Manager](). + Export[types.TaskRunner](). + Export[*validator.Validator](). + Export[*apploader.Loader](). + Export[*chi.Mux](). + Export[*tlscert.Reloader](). + Export[*hlfhr.Server](). + Export[*cron.Cron](). + Export[*cli.Command](). + Export[*websitestat.Aggregator]() diff --git a/internal/command/app.go b/internal/command/app.go index 9531215f8..73ba02db1 100644 --- a/internal/command/app.go +++ b/internal/command/app.go @@ -11,7 +11,6 @@ import ( // AppCommand 应用管理命令组 func AppCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "app", Usage: t.Get("Application management"), diff --git a/internal/command/backup.go b/internal/command/backup.go index 88cfe9a5e..bf8c5d2a7 100644 --- a/internal/command/backup.go +++ b/internal/command/backup.go @@ -11,7 +11,6 @@ import ( // BackupCommand 数据备份命令组 func BackupCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "backup", Usage: t.Get("Data backup"), diff --git a/internal/command/cert.go b/internal/command/cert.go index 3e085e336..5e14490f7 100644 --- a/internal/command/cert.go +++ b/internal/command/cert.go @@ -11,7 +11,6 @@ import ( // CertCommand 证书管理命令组 func CertCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "cert", Usage: t.Get("Certificate management"), diff --git a/internal/command/command.go b/internal/command/command.go index c8bec51c8..86052bcdb 100644 --- a/internal/command/command.go +++ b/internal/command/command.go @@ -1,15 +1,12 @@ package command import ( - "github.com/google/wire" "github.com/leonelquinteros/gotext" "github.com/urfave/cli/v3" "github.com/acepanel/panel/v3/internal/service" ) -var ProviderSet = wire.NewSet(Commands) - // Commands 组装全部 CLI 命令。 func Commands(t *gotext.Locale, cliService *service.CliService) []*cli.Command { return []*cli.Command{ diff --git a/internal/command/cron.go b/internal/command/cron.go index 5cf41da6c..8d6bbae14 100644 --- a/internal/command/cron.go +++ b/internal/command/cron.go @@ -11,7 +11,6 @@ import ( // CronCommand 计划任务命令组 func CronCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "cron", Usage: t.Get("Cron task"), diff --git a/internal/command/cutoff.go b/internal/command/cutoff.go index cedc72702..a4535ffb7 100644 --- a/internal/command/cutoff.go +++ b/internal/command/cutoff.go @@ -11,7 +11,6 @@ import ( // CutoffCommand 日志切割命令组 func CutoffCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "cutoff", Usage: t.Get("Log rotation"), diff --git a/internal/command/database.go b/internal/command/database.go index 5f8805c91..4124b3b2f 100644 --- a/internal/command/database.go +++ b/internal/command/database.go @@ -11,7 +11,6 @@ import ( // DatabaseCommand 数据库管理命令组 func DatabaseCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "database", Usage: t.Get("Database management"), diff --git a/internal/command/entrance.go b/internal/command/entrance.go index 0fcad0e73..bef9ca328 100644 --- a/internal/command/entrance.go +++ b/internal/command/entrance.go @@ -11,7 +11,6 @@ import ( // EntranceCommand 访问入口管理命令组 func EntranceCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "entrance", Usage: t.Get("Operate AcePanel access entrance"), @@ -37,7 +36,6 @@ func EntranceCommand(t *gotext.Locale, cliService *service.CliService) *cli.Comm // BindDomainCommand 域名绑定管理命令组 func BindDomainCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "bind-domain", Usage: t.Get("Operate AcePanel domain binding"), @@ -63,7 +61,6 @@ func BindDomainCommand(t *gotext.Locale, cliService *service.CliService) *cli.Co // BindIPCommand IP 绑定管理命令组 func BindIPCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "bind-ip", Usage: t.Get("Operate AcePanel IP binding"), @@ -89,7 +86,6 @@ func BindIPCommand(t *gotext.Locale, cliService *service.CliService) *cli.Comman // BindUACommand UA 绑定管理命令组 func BindUACommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "bind-ua", Usage: t.Get("Operate AcePanel UA binding"), diff --git a/internal/command/firewall.go b/internal/command/firewall.go index 820ddc276..672d6f78d 100644 --- a/internal/command/firewall.go +++ b/internal/command/firewall.go @@ -11,7 +11,6 @@ import ( // FirewallCommand 防火墙管理命令组 func FirewallCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "firewall", Usage: t.Get("Firewall management"), diff --git a/internal/command/https.go b/internal/command/https.go index 77f8abc3a..5304958a7 100644 --- a/internal/command/https.go +++ b/internal/command/https.go @@ -11,7 +11,6 @@ import ( // HttpsCommand 面板 HTTPS 管理命令组 func HttpsCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "https", Usage: t.Get("Operate AcePanel HTTPS"), diff --git a/internal/command/panel.go b/internal/command/panel.go index 057090c5c..bec6625e4 100644 --- a/internal/command/panel.go +++ b/internal/command/panel.go @@ -11,7 +11,6 @@ import ( // UpdateCommand 更新面板 func UpdateCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "update", Usage: t.Get("Update AcePanel to the latest version"), @@ -23,7 +22,6 @@ func UpdateCommand(t *gotext.Locale, cliService *service.CliService) *cli.Comman // SyncCommand 同步云端缓存数据 func SyncCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "sync", Usage: t.Get("Sync AcePanel cached data with cloud"), @@ -35,7 +33,6 @@ func SyncCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command // FixCommand 修复升级问题 func FixCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "fix", Usage: t.Get("Fix AcePanel upgrade issues"), @@ -47,7 +44,6 @@ func FixCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { // InfoCommand 输出面板基础信息 func InfoCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "info", Usage: t.Get("Output AcePanel basic information"), @@ -71,7 +67,6 @@ func InfoCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command // PortCommand 修改监听端口 func PortCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "port", Usage: t.Get("Change the AcePanel listening port"), @@ -91,7 +86,6 @@ func PortCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command // SyncTimeCommand 通过 NTP 同步系统时间 func SyncTimeCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "sync-time", Usage: t.Get("Sync server time with NTP"), @@ -103,7 +97,6 @@ func SyncTimeCommand(t *gotext.Locale, cliService *service.CliService) *cli.Comm // ClearTaskCommand 清理卡住的任务队列 func ClearTaskCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "clear-task", Usage: t.Get("Clear all tasks in the task queue if they are stuck (use only under guidance)"), @@ -116,7 +109,6 @@ func ClearTaskCommand(t *gotext.Locale, cliService *service.CliService) *cli.Com // InitCommand 初始化面板 func InitCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "init", Usage: t.Get("Initialize AcePanel (use only under guidance)"), diff --git a/internal/command/restore.go b/internal/command/restore.go index 60525f300..829d8273c 100644 --- a/internal/command/restore.go +++ b/internal/command/restore.go @@ -11,7 +11,6 @@ import ( // RestoreCommand 数据恢复命令组 func RestoreCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "restore", Usage: t.Get("Data restore"), diff --git a/internal/command/service.go b/internal/command/service.go index 52faa96ac..a69d961f2 100644 --- a/internal/command/service.go +++ b/internal/command/service.go @@ -11,7 +11,6 @@ import ( // StatusCommand 查询服务状态 func StatusCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "status", Usage: t.Get("Get AcePanel service status"), @@ -23,7 +22,6 @@ func StatusCommand(t *gotext.Locale, cliService *service.CliService) *cli.Comman // RestartCommand 重启服务 func RestartCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "restart", Usage: t.Get("Restart AcePanel service"), @@ -35,7 +33,6 @@ func RestartCommand(t *gotext.Locale, cliService *service.CliService) *cli.Comma // StopCommand 停止服务 func StopCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "stop", Usage: t.Get("Stop AcePanel service"), @@ -47,7 +44,6 @@ func StopCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command // StartCommand 启动服务 func StartCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "start", Usage: t.Get("Start AcePanel service"), diff --git a/internal/command/setting.go b/internal/command/setting.go index 68b4c679e..13b86c33b 100644 --- a/internal/command/setting.go +++ b/internal/command/setting.go @@ -11,7 +11,6 @@ import ( // SettingCommand 面板设置管理命令组 func SettingCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "setting", Usage: t.Get("Setting management"), diff --git a/internal/command/user.go b/internal/command/user.go index 1de7a59e6..1e6577f5c 100644 --- a/internal/command/user.go +++ b/internal/command/user.go @@ -11,7 +11,6 @@ import ( // UserCommand 用户管理命令组 func UserCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "user", Usage: t.Get("Operate AcePanel users"), diff --git a/internal/command/website.go b/internal/command/website.go index 5130fa738..b531dfa3a 100644 --- a/internal/command/website.go +++ b/internal/command/website.go @@ -11,7 +11,6 @@ import ( // WebsiteCommand 网站管理命令组 func WebsiteCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command { - return &cli.Command{ Name: "website", Usage: t.Get("Website management"), diff --git a/internal/command/wire.go b/internal/command/wire.go new file mode 100644 index 000000000..017f6d672 --- /dev/null +++ b/internal/command/wire.go @@ -0,0 +1,13 @@ +//go:build wireinject + +package command + +import ( + "github.com/libtnb/wire" + "github.com/urfave/cli/v3" +) + +// Module 装配 CLI 命令 +var Module = wire.New(). + Provide(Commands). + Export[[]*cli.Command]() diff --git a/internal/data/app.go b/internal/data/app.go index d6e56699f..d9f339bd7 100644 --- a/internal/data/app.go +++ b/internal/data/app.go @@ -48,7 +48,6 @@ func (r *appRepo) Installed() ([]*biz.App, error) { } return apps, nil - } func (r *appRepo) GetInstalled(slug string) (*biz.App, error) { diff --git a/internal/data/backup.go b/internal/data/backup.go index 759470986..f12708b18 100644 --- a/internal/data/backup.go +++ b/internal/data/backup.go @@ -142,9 +142,9 @@ func (r *backupRepo) Create(ctx context.Context, typ biz.BackupType, target stri case biz.BackupTypeWebsite: err = r.createWebsite(name, client, target) case biz.BackupTypeMySQL: - err = r.createMySQL(name, client, target) + err = r.createMySQL(ctx, name, client, target) case biz.BackupTypePostgres: - err = r.createPostgres(name, client, target) + err = r.createPostgres(ctx, name, client, target) case biz.BackupTypeClickHouse: err = r.createClickHouse(name, client, target) case biz.BackupTypeRedis: @@ -251,7 +251,7 @@ func (r *backupRepo) Delete(typ biz.BackupType, name string) error { // typ 备份类型 // backup 备份压缩包,可以是绝对路径或者相对路径 // target 目标名称 -func (r *backupRepo) Restore(typ biz.BackupType, backup, target string) error { +func (r *backupRepo) Restore(ctx context.Context, typ biz.BackupType, backup, target string) error { if !io.Exists(backup) { backup = filepath.Join(r.GetDefaultPath(typ), backup) } @@ -274,11 +274,11 @@ func (r *backupRepo) Restore(typ biz.BackupType, backup, target string) error { case biz.BackupTypeWebsite: err = r.restoreWebsite(backup, target) case biz.BackupTypeMySQL: - err = r.restoreMySQL(backup, target) + err = r.restoreMySQL(ctx, backup, target) case biz.BackupTypePostgres: - err = r.restorePostgres(backup, target) + err = r.restorePostgres(ctx, backup, target) case biz.BackupTypeClickHouse: - err = r.restoreClickHouse(backup, target) + err = r.restoreClickHouse(ctx, backup, target) case biz.BackupTypeRedis: err = r.restoreRedisLike(backup, "redis") case biz.BackupTypeValkey: @@ -574,12 +574,12 @@ func (r *backupRepo) createWebsite(name string, storage storage.Storage, target } // createMySQL 创建 MySQL 备份 -func (r *backupRepo) createMySQL(name string, storage storage.Storage, target string) error { +func (r *backupRepo) createMySQL(ctx context.Context, name string, storage storage.Storage, target string) error { rootPassword, err := r.setting.Get(biz.SettingKeyMySQLRootPassword) if err != nil { return err } - mysql, err := db.NewMySQL(context.Background(), "root", rootPassword, db.MySQLSocket(app.Root), "unix") + mysql, err := db.NewMySQL(ctx, "root", rootPassword, db.MySQLSocket(app.Root), "unix") if err != nil { return err } @@ -641,13 +641,13 @@ func (r *backupRepo) createMySQL(name string, storage storage.Storage, target st } // createPostgres 创建 PostgreSQL 备份 -func (r *backupRepo) createPostgres(name string, storage storage.Storage, target string) error { +func (r *backupRepo) createPostgres(ctx context.Context, name string, storage storage.Storage, target string) error { postgresPassword, err := r.setting.Get(biz.SettingKeyPostgresPassword) if err != nil { return err } port := db.PostgresPort(app.Root) - postgres, err := db.NewPostgres(context.Background(), "postgres", postgresPassword, "127.0.0.1", port) + postgres, err := db.NewPostgres(ctx, "postgres", postgresPassword, "127.0.0.1", port) if err != nil { return err } @@ -927,7 +927,7 @@ func (r *backupRepo) restoreWebsite(backup, target string) error { // importFile 把备份文件喂给数据库客户端 stdin,并按秒级周期打印大致进度 // pipe 有背压,已写入字节数 ≈ 客户端已消费字节数,足以作为进度参考 -func (r *backupRepo) importFile(path, name string, env, args []string) error { +func (r *backupRepo) importFile(ctx context.Context, path, name string, env, args []string) error { f, err := os.Open(path) if err != nil { return err @@ -954,17 +954,17 @@ func (r *backupRepo) importFile(path, name string, env, args []string) error { } } - _, err = shell.ExecWithStdinProgress(context.Background(), name, args, env, f, total, 5*time.Second, progress) + _, err = shell.ExecWithStdinProgress(ctx, name, args, env, f, total, 5*time.Second, progress) return err } // restoreMySQL 恢复 MySQL 备份 -func (r *backupRepo) restoreMySQL(backup, target string) error { +func (r *backupRepo) restoreMySQL(ctx context.Context, backup, target string) error { rootPassword, err := r.setting.Get(biz.SettingKeyMySQLRootPassword) if err != nil { return err } - mysql, err := db.NewMySQL(context.Background(), "root", rootPassword, db.MySQLSocket(app.Root), "unix") + mysql, err := db.NewMySQL(ctx, "root", rootPassword, db.MySQLSocket(app.Root), "unix") if err != nil { return err } @@ -987,17 +987,17 @@ func (r *backupRepo) restoreMySQL(backup, target string) error { if app.IsCli { fmt.Println(r.t.Get("|-Importing SQL into database...")) } - return r.importFile(backup, "mysql", []string{"MYSQL_PWD=" + rootPassword}, []string{"-u", "root", "--max-allowed-packet=1G", "--database=" + target}) + return r.importFile(ctx, backup, "mysql", []string{"MYSQL_PWD=" + rootPassword}, []string{"-u", "root", "--max-allowed-packet=1G", "--database=" + target}) } // restorePostgres 恢复 PostgreSQL 备份 -func (r *backupRepo) restorePostgres(backup, target string) error { +func (r *backupRepo) restorePostgres(ctx context.Context, backup, target string) error { postgresPassword, err := r.setting.Get(biz.SettingKeyPostgresPassword) if err != nil { return err } port := db.PostgresPort(app.Root) - postgres, err := db.NewPostgres(context.Background(), "postgres", postgresPassword, "127.0.0.1", port) + postgres, err := db.NewPostgres(ctx, "postgres", postgresPassword, "127.0.0.1", port) if err != nil { return err } @@ -1026,19 +1026,19 @@ func (r *backupRepo) restorePostgres(backup, target string) error { fmt.Println(r.t.Get("|-Importing PostgreSQL backup...")) } if archive { - command := exec.Command("pg_restore", "--exit-on-error", "-h", "127.0.0.1", "-p", cast.ToString(port), "-U", "postgres", "--dbname="+target, backup) + command := exec.CommandContext(ctx, "pg_restore", "--exit-on-error", "-h", "127.0.0.1", "-p", cast.ToString(port), "-U", "postgres", "--dbname="+target, backup) shell.ApplyEnv(command, "PGPASSWORD="+postgresPassword) if output, restoreErr := command.CombinedOutput(); restoreErr != nil { return fmt.Errorf("%w: %s", restoreErr, strings.TrimSpace(string(output))) } return nil } - return r.importFile(backup, "psql", []string{"PGPASSWORD=" + postgresPassword}, + return r.importFile(ctx, backup, "psql", []string{"PGPASSWORD=" + postgresPassword}, []string{"-h", "127.0.0.1", "-p", cast.ToString(port), "-U", "postgres", "-v", "ON_ERROR_STOP=1", "--single-transaction", "--dbname=" + target}) } // restoreClickHouse 恢复 ClickHouse 备份 -func (r *backupRepo) restoreClickHouse(backup, target string) error { +func (r *backupRepo) restoreClickHouse(ctx context.Context, backup, target string) error { password, err := r.setting.Get(biz.SettingKeyClickHouseDefaultPassword) if err != nil { return err @@ -1060,7 +1060,7 @@ func (r *backupRepo) restoreClickHouse(backup, target string) error { if app.IsCli { fmt.Println(r.t.Get("|-Importing SQL into database...")) } - return r.importFile(backup, "clickhouse-client", nil, append(slices.Clone(connArgs), "--database", target, "--multiquery")) + return r.importFile(ctx, backup, "clickhouse-client", nil, append(slices.Clone(connArgs), "--database", target, "--multiquery")) } // 解压到临时目录 @@ -1084,7 +1084,7 @@ func (r *backupRepo) restoreClickHouse(backup, target string) error { if app.IsCli { fmt.Println(r.t.Get("|-Restoring schema...")) } - if err = r.importFile(schemaPath, "clickhouse-client", nil, append(slices.Clone(connArgs), "--database", target, "--multiquery")); err != nil { + if err = r.importFile(ctx, schemaPath, "clickhouse-client", nil, append(slices.Clone(connArgs), "--database", target, "--multiquery")); err != nil { return err } } @@ -1103,7 +1103,7 @@ func (r *backupRepo) restoreClickHouse(backup, target string) error { fmt.Println(r.t.Get("|-Importing table: %s", tbl)) } query := fmt.Sprintf("INSERT INTO `%s` FORMAT Native", tbl) - if err = r.importFile(filepath.Join(tmpDir, entry.Name()), "clickhouse-client", nil, append(slices.Clone(connArgs), "--database", target, "--query", query)); err != nil { + if err = r.importFile(ctx, filepath.Join(tmpDir, entry.Name()), "clickhouse-client", nil, append(slices.Clone(connArgs), "--database", target, "--query", query)); err != nil { return err } } diff --git a/internal/data/cert_account.go b/internal/data/cert_account.go index 56236c6ca..d0a618486 100644 --- a/internal/data/cert_account.go +++ b/internal/data/cert_account.go @@ -82,7 +82,10 @@ func (r certAccountRepo) GetGoogleEAB() (*acme.EAB, error) { if err != nil || !resp.IsStatusSuccess() { return &acme.EAB{}, errors.New(r.t.Get("failed to get Google EAB: %v", err)) } - eab := resp.Result().(*data) + eab, ok := resp.Result().(*data) + if !ok { + return &acme.EAB{}, errors.New(r.t.Get("failed to get Google EAB: %s", r.t.Get("invalid response"))) + } if eab.Msg != "success" { return &acme.EAB{}, errors.New(r.t.Get("failed to get Google EAB: %s", eab.Msg)) } @@ -108,7 +111,10 @@ func (r certAccountRepo) GetZeroSSLEAB(email string) (*acme.EAB, error) { if err != nil || !resp.IsStatusSuccess() { return &acme.EAB{}, errors.New(r.t.Get("failed to get ZeroSSL EAB: %v", err)) } - eab := resp.Result().(*data) + eab, ok := resp.Result().(*data) + if !ok { + return &acme.EAB{}, errors.New(r.t.Get("failed to get ZeroSSL EAB")) + } if !eab.Success { return &acme.EAB{}, errors.New(r.t.Get("failed to get ZeroSSL EAB")) } diff --git a/internal/data/container.go b/internal/data/container.go index 0569c82ea..5bddd6075 100644 --- a/internal/data/container.go +++ b/internal/data/container.go @@ -57,11 +57,11 @@ func (r *containerRepo) ListAll(sock string) ([]types.Container, error) { } } slices.SortFunc(ports, func(a, b types.ContainerPort) int { - aOffset := int64(a.HostStart) - int64(a.ContainerStart) + aOffset := int64(a.HostStart) - int64(a.ContainerStart) //nolint:gosec if a.HostStart == 0 { aOffset = 0 } - bOffset := int64(b.HostStart) - int64(b.ContainerStart) + bOffset := int64(b.HostStart) - int64(b.ContainerStart) //nolint:gosec if b.HostStart == 0 { bOffset = 0 } @@ -142,7 +142,7 @@ func (r *containerRepo) Create(sock string, req *request.ContainerCreate) (strin // 获取镜像信息 image, err := apiClient.ImageInspect(ctx, req.Image) if err != nil { - return "", fmt.Errorf("failed to inspect image: %v", err) + return "", fmt.Errorf("failed to inspect image: %w", err) } // 兼容一些没有指定命令和入口点的镜像 if image.Config != nil { diff --git a/internal/data/container_image.go b/internal/data/container_image.go index ae6a9acbd..537beb80a 100644 --- a/internal/data/container_image.go +++ b/internal/data/container_image.go @@ -93,7 +93,7 @@ func (r *containerImageRepo) Pull(sock string, req *request.ContainerImagePull) Username: req.Username, Password: req.Password, } - encodedJSON, err := json.Marshal(authConfig) + encodedJSON, err := json.Marshal(authConfig) //nolint:gosec if err != nil { return err } diff --git a/internal/data/data.go b/internal/data/data.go deleted file mode 100644 index e573581ac..000000000 --- a/internal/data/data.go +++ /dev/null @@ -1,20 +0,0 @@ -package data - -import "github.com/google/wire" - -var ProviderSet = wire.NewSet( - NewAlertRepo, NewAppRepo, NewBackupRepo, NewBackupAccountRepo, - NewCacheRepo, NewCertRepo, NewCertAccountRepo, - NewCertDNSRepo, NewContainerRepo, NewContainerComposeRepo, - NewContainerImageRepo, NewContainerNetworkRepo, NewContainerVolumeRepo, - NewCronRepo, NewDatabaseRepo, NewDatabaseRedisRepo, - NewDatabaseElasticsearchRepo, NewDatabaseServerRepo, NewDatabaseUserRepo, - NewEnvironmentRepo, NewFileShareRepo, NewLogRepo, NewMonitorRepo, - NewNotifyChannelRepo, - NewProjectRepo, NewSafeRepo, NewScanEventRepo, - NewSettingRepo, NewSSHRepo, NewTamperRepo, NewTaskRepo, - NewTemplateRepo, NewUserRepo, NewUserPasskeyRepo, - NewUserTokenRepo, NewWebHookRepo, NewWebsiteRepo, - NewWebsiteStatRepo, - NewMigrationSourceRepo, NewMigrationRemoteRepo, NewMigrationArchiveRepo, -) diff --git a/internal/data/database.go b/internal/data/database.go index adb01efdd..227216166 100644 --- a/internal/data/database.go +++ b/internal/data/database.go @@ -43,7 +43,7 @@ func (r *databaseRepo) DatabasesOf(ctx context.Context, server *biz.DatabaseServ if err != nil { return nil, err } - if databases, err := mongo.Databases(); err == nil { + if databases, err := mongo.Databases(); err == nil { //nolint:contextcheck for item := range slices.Values(databases) { database = append(database, &biz.Database{ Type: server.Type, @@ -55,11 +55,11 @@ func (r *databaseRepo) DatabasesOf(ctx context.Context, server *biz.DatabaseServ } mongo.Close() case biz.DatabaseTypeSQLite: - sqlite, err := db.NewSQLite(server.Host) + sqlite, err := db.NewSQLite(server.Host) //nolint:contextcheck if err != nil { return nil, err } - if tables, err := sqlite.Tables(); err == nil { + if tables, err := sqlite.Tables(); err == nil { //nolint:contextcheck for table := range slices.Values(tables) { database = append(database, &biz.Database{ Type: server.Type, diff --git a/internal/data/database_server.go b/internal/data/database_server.go index 6263605b2..5b9488c91 100644 --- a/internal/data/database_server.go +++ b/internal/data/database_server.go @@ -146,7 +146,7 @@ func (r *databaseServerRepo) CheckServer(ctx context.Context, server *biz.Databa return true } case biz.DatabaseTypeSQLite: - sqlite, err := db.NewSQLite(server.Host) + sqlite, err := db.NewSQLite(server.Host) //nolint:contextcheck if err == nil { sqlite.Close() server.Status = biz.DatabaseServerStatusValid diff --git a/internal/data/database_user.go b/internal/data/database_user.go index ee1fd218b..c2a93e84c 100644 --- a/internal/data/database_user.go +++ b/internal/data/database_user.go @@ -178,6 +178,7 @@ func (r *databaseUserRepo) fillUser(ctx context.Context, user *biz.DatabaseUser) } else { user.Status = biz.DatabaseUserStatusInvalid } + default: } } diff --git a/internal/data/notify.go b/internal/data/notify.go index b8e696f46..8fb039805 100644 --- a/internal/data/notify.go +++ b/internal/data/notify.go @@ -2,6 +2,7 @@ package data import ( "encoding/json" + "errors" "github.com/samber/lo" "gorm.io/gorm" @@ -88,13 +89,15 @@ func (r *notifyChannelRepo) Delete(id uint) error { func (r *notifyChannelRepo) removeEventChannel(tx *gorm.DB, id uint) error { setting := new(biz.Setting) if err := tx.Where("key = ?", biz.SettingKeyNotifyEventChannels).First(setting).Error; err != nil { - // 未配置过事件通知 - return nil + if errors.Is(err, gorm.ErrRecordNotFound) { + return nil + } + return err } channels := make([]uint, 0) if json.Unmarshal([]byte(setting.Value), &channels) != nil { - return nil + return nil //nolint:nilerr } remain := lo.Without(channels, id) diff --git a/internal/data/project.go b/internal/data/project.go index 1f4cc9367..6d5e59cbd 100644 --- a/internal/data/project.go +++ b/internal/data/project.go @@ -105,9 +105,9 @@ func (r *projectRepo) Save(project *biz.Project) error { } // RenameUnitFile 重命名 systemd unit 文件 -func (r *projectRepo) RenameUnitFile(old, new string) error { - oldPath := r.unitFilePath(old) - newPath := r.unitFilePath(new) +func (r *projectRepo) RenameUnitFile(oldName, newName string) error { + oldPath := r.unitFilePath(oldName) + newPath := r.unitFilePath(newName) if err := os.Rename(oldPath, newPath); err != nil && !os.IsNotExist(err) { return fmt.Errorf("%s: %w", r.t.Get("failed to rename systemd config"), err) } diff --git a/internal/data/scan_event.go b/internal/data/scan_event.go index a63ceb3f0..ae1a77cd0 100644 --- a/internal/data/scan_event.go +++ b/internal/data/scan_event.go @@ -105,7 +105,7 @@ func (r *scanEventRepo) List(start, end, sourceIP string, port uint, location st return nil, 0, err } - return items, uint(total), nil + return items, uint(total), nil //nolint:gosec } func (r *scanEventRepo) Summary(start, end string) (*biz.ScanSummary, error) { diff --git a/internal/data/tamper.go b/internal/data/tamper.go index 8cd7c4382..7672576dc 100644 --- a/internal/data/tamper.go +++ b/internal/data/tamper.go @@ -17,7 +17,6 @@ type tamperRepo struct { // NewTamperRepo 创建防篡改数据访问实例 func NewTamperRepo(db *gorm.DB) (biz.TamperRepo, error) { - logDB, err := openSharedDB("tamper") if err != nil { return nil, err diff --git a/internal/data/toolbox_migration.go b/internal/data/toolbox_migration.go index a21d7c443..d24db687d 100644 --- a/internal/data/toolbox_migration.go +++ b/internal/data/toolbox_migration.go @@ -196,7 +196,7 @@ func (c *migrationClient) download(ctx context.Context, remote, local string, pr func (c *migrationClient) client(timeout time.Duration) *resty.Client { return resty.New(). SetBaseURL(c.origin()). - SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}). + SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}). //nolint:gosec SetTimeout(timeout) } diff --git a/internal/data/toolbox_migration_archive.go b/internal/data/toolbox_migration_archive.go index c848dd3b0..6199362ed 100644 --- a/internal/data/toolbox_migration_archive.go +++ b/internal/data/toolbox_migration_archive.go @@ -40,7 +40,7 @@ func (r *migrationArchiveRepo) Extract(ctx context.Context, archive, target stri } entries, err := os.ReadDir(target) if err != nil || len(entries) != 1 || !entries[0].IsDir() { - return target, nil + return target, nil //nolint:nilerr } return filepath.Join(target, entries[0].Name()), nil } diff --git a/internal/data/toolbox_migration_baota.go b/internal/data/toolbox_migration_baota.go index 9a76fca2b..8e39bce35 100644 --- a/internal/data/toolbox_migration_baota.go +++ b/internal/data/toolbox_migration_baota.go @@ -2,7 +2,7 @@ package data import ( "context" - "crypto/md5" + "crypto/md5" //nolint:gosec "encoding/hex" "encoding/json" "errors" @@ -47,8 +47,8 @@ func newBaotaClient(conn *request.ToolboxMigrationConnection) *migrationClient { // 认证一律走 query,resty 在签名时还未确定请求方法,无法按方法分流 sign: func(req *resty.Request) { timestamp := strconv.FormatInt(time.Now().Unix(), 10) - secret := md5.Sum([]byte(conn.APIKey)) - token := md5.Sum([]byte(timestamp + hex.EncodeToString(secret[:]))) + secret := md5.Sum([]byte(conn.APIKey)) //nolint:gosec + token := md5.Sum([]byte(timestamp + hex.EncodeToString(secret[:]))) //nolint:gosec req.SetQueryParams(map[string]string{"request_time": timestamp, "request_token": hex.EncodeToString(token[:])}) }, // 宝塔失败响应为 {status: false, msg: "..."},部分接口的业务数据也含 status 字段,需同时判断 msg @@ -287,7 +287,7 @@ func (a *baotaAdapter) Detail(ctx context.Context, item types.MigrationItem) (*t var err error switch item.Type { case "website": - detail.Website, err = a.websiteDetail(ctx, item) + detail.Website = a.websiteDetail(ctx, item) case "database": detail.Database, err = a.databaseDetail(ctx, item) case "database_user": @@ -300,7 +300,7 @@ func (a *baotaAdapter) Detail(ctx context.Context, item types.MigrationItem) (*t return detail, err } -func (a *baotaAdapter) websiteDetail(ctx context.Context, item types.MigrationItem) (*types.MigrationWebsite, error) { +func (a *baotaAdapter) websiteDetail(ctx context.Context, item types.MigrationItem) *types.MigrationWebsite { website := &types.MigrationWebsite{ Type: item.Subtype, Path: item.SourcePath, Root: item.SourcePath, Domains: []string{item.Name}, Listens: []string{"80"}, @@ -367,7 +367,7 @@ func (a *baotaAdapter) websiteDetail(ctx context.Context, item types.MigrationIt } website.Redirects = a.redirects(ctx, item.Name) a.applySSL(ctx, item.Name, website) - return website, nil + return website } // domains 读取站点绑定的域名与端口 diff --git a/internal/data/toolbox_migration_onepanel.go b/internal/data/toolbox_migration_onepanel.go index bac9b35b6..114309f59 100644 --- a/internal/data/toolbox_migration_onepanel.go +++ b/internal/data/toolbox_migration_onepanel.go @@ -2,7 +2,7 @@ package data import ( "context" - "crypto/md5" + "crypto/md5" //nolint:gosec "encoding/hex" "encoding/json" "errors" @@ -37,7 +37,7 @@ func newOnePanelClient(conn *request.ToolboxMigrationConnection) *migrationClien url: conn.URL, sign: func(req *resty.Request) { timestamp := strconv.FormatInt(time.Now().Unix(), 10) - token := md5.Sum([]byte("1panel" + conn.APIKey + timestamp)) + token := md5.Sum([]byte("1panel" + conn.APIKey + timestamp)) //nolint:gosec req.SetHeader("1Panel-Timestamp", timestamp).SetHeader("1Panel-Token", hex.EncodeToString(token[:])) }, unwrap: func(body []byte) (any, error) { diff --git a/internal/data/toolbox_migration_remote.go b/internal/data/toolbox_migration_remote.go index 5900e6700..c30ce301f 100644 --- a/internal/data/toolbox_migration_remote.go +++ b/internal/data/toolbox_migration_remote.go @@ -44,7 +44,7 @@ func NewMigrationRemoteRepo(t *gotext.Locale) biz.MigrationRemoteRepo { func (r *migrationRemoteRepo) client(conn *request.ToolboxMigrationConnection, timeout time.Duration) *resty.Client { client := resty.New(). SetBaseURL(strings.TrimRight(conn.URL, "/")). - SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}). + SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}). //nolint:gosec SetHeader("Content-Type", "application/json") if timeout > 0 { client.SetTimeout(timeout) diff --git a/internal/data/webhook.go b/internal/data/webhook.go index b71c1ae05..2735ddd0d 100644 --- a/internal/data/webhook.go +++ b/internal/data/webhook.go @@ -118,9 +118,9 @@ func (r *webhookRepo) Call(key string) (string, error) { // 执行脚本 var cmd *exec.Cmd if webhook.User == "" || webhook.User == "root" { - cmd = exec.Command("bash", scriptFile) + cmd = exec.Command("bash", scriptFile) //nolint:noctx } else { - cmd = exec.Command("su", "-s", "/bin/bash", "-c", "bash "+scriptFile, webhook.User) + cmd = exec.Command("su", "-s", "/bin/bash", "-c", "bash "+scriptFile, webhook.User) //nolint:noctx } shell.ApplyEnv(cmd) diff --git a/internal/data/website.go b/internal/data/website.go index 98904f529..601d49492 100644 --- a/internal/data/website.go +++ b/internal/data/website.go @@ -47,12 +47,12 @@ func NewWebsiteRepo(db *gorm.DB, t *gotext.Locale, settingRepo biz.SettingRepo) func (r *websiteRepo) GetRewrites() (map[string]string, error) { d, err := r.dialect() if err != nil { - return make(map[string]string), nil + return make(map[string]string), nil //nolint:nilerr } entries, err := embed.RewritesFS.ReadDir(filepath.Join("rewrites", d.RewritesDir())) if err != nil { - return make(map[string]string), nil + return make(map[string]string), nil //nolint:nilerr } rw := make(map[string]string) @@ -548,6 +548,8 @@ func (r *websiteRepo) SwitchType(req *request.WebsiteSwitchType) (*biz.Website, Location: "^~ /", Pass: req.Proxy, }} + default: + // 静态站点沿用默认配置 } configDir := filepath.Join(app.Root, "sites", website.Name, "config") @@ -1189,6 +1191,7 @@ func (r *websiteRepo) ResetConfig(id uint) error { Pass: setting.Proxies[0].Pass, }} } + default: } if website.Type == biz.WebsiteTypePHP { @@ -1462,6 +1465,8 @@ func writeTypeConfigs(d webserver.Dialect, vhost webservertypes.Vhost, typ biz.W return vhost.SetConfig("010-cache.conf", webservertypes.ScopeSite, d.PHPCacheConf()) case biz.WebsiteTypeStatic: return vhost.SetRawConfig("800-spa.conf", webservertypes.ScopeSite, d.SPAConf()) + default: + // 反代站点无需额外片段 } return nil diff --git a/internal/data/website_stat.go b/internal/data/website_stat.go index a2973e997..7e90def8c 100644 --- a/internal/data/website_stat.go +++ b/internal/data/website_stat.go @@ -263,7 +263,7 @@ func (r *websiteStatRepo) TopIPs(start, end string, sites []string, page, limit } offset := (page - 1) * limit err := dataQ.Group("ip").Order("requests DESC").Offset(int(offset)).Limit(int(limit)).Scan(&items).Error - return items, uint(total), err + return items, uint(total), err //nolint:gosec } func (r *websiteStatRepo) ClearIPsBefore(date string) error { @@ -341,7 +341,7 @@ func (r *websiteStatRepo) TopURIs(start, end string, sites []string, page, limit } offset := (page - 1) * limit err := dataQ.Group("uri").Order("requests DESC").Offset(int(offset)).Limit(int(limit)).Scan(&items).Error - return items, uint(total), err + return items, uint(total), err //nolint:gosec } func (r *websiteStatRepo) ClearURIsBefore(date string) error { @@ -383,7 +383,7 @@ func (r *websiteStatRepo) TopSlowURIs(start, end string, sites []string, thresho err := dataQ.Group("uri").Having(having, havingArgs...). Order("CAST(SUM(request_time_sum) AS REAL) / SUM(request_time_count) DESC"). Offset(int(offset)).Limit(int(limit)).Scan(&items).Error - return items, uint(total), err + return items, uint(total), err //nolint:gosec } // ========== 错误日志查询 ========== @@ -405,7 +405,7 @@ func (r *websiteStatRepo) ListErrors(start, end string, sites []string, status i var items []*biz.WebsiteErrorLog offset := (page - 1) * limit err := q.Order("created_at DESC").Offset(int(offset)).Limit(int(limit)).Find(&items).Error - return items, uint(total), err + return items, uint(total), err //nolint:gosec } // ========== 网站维度汇总 ========== diff --git a/internal/data/wire.go b/internal/data/wire.go new file mode 100644 index 000000000..93b2480d6 --- /dev/null +++ b/internal/data/wire.go @@ -0,0 +1,94 @@ +//go:build wireinject + +package data + +import ( + "github.com/libtnb/wire" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Module 装配数据访问层,对外导出 biz 中定义的仓储接口 +var Module = wire.New(). + Provide(NewAlertRepo). + Provide(NewAppRepo). + Provide(NewBackupRepo). + Provide(NewBackupAccountRepo). + Provide(NewCacheRepo). + Provide(NewCertRepo). + Provide(NewCertAccountRepo). + Provide(NewCertDNSRepo). + Provide(NewContainerRepo). + Provide(NewContainerComposeRepo). + Provide(NewContainerImageRepo). + Provide(NewContainerNetworkRepo). + Provide(NewContainerVolumeRepo). + Provide(NewCronRepo). + Provide(NewDatabaseRepo). + Provide(NewDatabaseRedisRepo). + Provide(NewDatabaseElasticsearchRepo). + Provide(NewDatabaseServerRepo). + Provide(NewDatabaseUserRepo). + Provide(NewEnvironmentRepo). + Provide(NewFileShareRepo). + Provide(NewLogRepo). + Provide(NewMonitorRepo). + Provide(NewNotifyChannelRepo). + Provide(NewProjectRepo). + Provide(NewSafeRepo). + Provide(NewScanEventRepo). + Provide(NewSettingRepo). + Provide(NewSSHRepo). + Provide(NewTamperRepo). + Provide(NewTaskRepo). + Provide(NewTemplateRepo). + Provide(NewUserRepo). + Provide(NewUserPasskeyRepo). + Provide(NewUserTokenRepo). + Provide(NewWebHookRepo). + Provide(NewWebsiteRepo). + Provide(NewWebsiteStatRepo). + Provide(NewMigrationSourceRepo). + Provide(NewMigrationRemoteRepo). + Provide(NewMigrationArchiveRepo). + Export[biz.AlertRepo](). + Export[biz.AppRepo](). + Export[biz.BackupRepo](). + Export[biz.BackupAccountRepo](). + Export[biz.CacheRepo](). + Export[biz.CertRepo](). + Export[biz.CertAccountRepo](). + Export[biz.CertDNSRepo](). + Export[biz.ContainerRepo](). + Export[biz.ContainerComposeRepo](). + Export[biz.ContainerImageRepo](). + Export[biz.ContainerNetworkRepo](). + Export[biz.ContainerVolumeRepo](). + Export[biz.CronRepo](). + Export[biz.DatabaseRepo](). + Export[biz.DatabaseRedisRepo](). + Export[biz.DatabaseElasticsearchRepo](). + Export[biz.DatabaseServerRepo](). + Export[biz.DatabaseUserRepo](). + Export[biz.EnvironmentRepo](). + Export[biz.FileShareRepo](). + Export[biz.LogRepo](). + Export[biz.MonitorRepo](). + Export[biz.NotifyChannelRepo](). + Export[biz.ProjectRepo](). + Export[biz.SafeRepo](). + Export[biz.ScanEventRepo](). + Export[biz.SettingRepo](). + Export[biz.SSHRepo](). + Export[biz.TamperRepo](). + Export[biz.TaskRepo](). + Export[biz.TemplateRepo](). + Export[biz.UserRepo](). + Export[biz.UserPasskeyRepo](). + Export[biz.UserTokenRepo](). + Export[biz.WebHookRepo](). + Export[biz.WebsiteRepo](). + Export[biz.WebsiteStatRepo](). + Export[biz.MigrationSourceRepo](). + Export[biz.MigrationRemoteRepo](). + Export[biz.MigrationArchiveRepo]() diff --git a/internal/job/cert_renew.go b/internal/job/cert_renew.go index 848bed87f..450635332 100644 --- a/internal/job/cert_renew.go +++ b/internal/job/cert_renew.go @@ -48,7 +48,7 @@ func NewCertRenew(certAccountUsecase *biz.CertAccountUsecase, certUsecase *biz.C } } -func (r *CertRenew) Run(_ context.Context) error { +func (r *CertRenew) Run(ctx context.Context) error { if app.Status != app.StatusNormal { return nil } @@ -67,7 +67,7 @@ func (r *CertRenew) Run(_ context.Context) error { // 刷新续签信息 if cert.RenewalInfo.NeedsRefresh() { - renewInfo, err := r.certRepo.RefreshRenewalInfo(cert.ID) + renewInfo, err := r.certRepo.RefreshRenewalInfo(ctx, cert.ID) if err != nil { r.log.Warn("failed to refresh renewal info", slog.String("type", biz.OperationTypeCert), slog.Uint64("operator_id", 0), slog.Any("err", err)) continue @@ -77,7 +77,7 @@ func (r *CertRenew) Run(_ context.Context) error { // 到达建议时间,续签证书 if time.Now().After(cert.RenewalInfo.SelectedTime) { - if _, err := r.certRepo.Renew(cert.ID); err != nil { + if _, err := r.certRepo.RenewWithProgressCallback(ctx, cert.ID, nil); err != nil { r.log.Warn("failed to renew certificate", slog.String("type", biz.OperationTypeCert), slog.Uint64("operator_id", 0), slog.Any("err", err)) r.notifyFailed(strings.Join(cert.Domains, ", "), err) } @@ -98,7 +98,7 @@ func (r *CertRenew) Run(_ context.Context) error { r.log.Warn("failed to parse panel certificate", slog.String("type", biz.OperationTypeCert), slog.Uint64("operator_id", 0), slog.Any("err", err)) } - newCrt, newKey, err := pkgcert.GenerateSelfSigned(tools.CollectLocalNames()) + newCrt, newKey, err := pkgcert.GenerateSelfSigned(tools.CollectLocalNames()) //nolint:contextcheck if err != nil { r.log.Warn("failed to generate self-signed certificate", slog.String("type", biz.OperationTypeCert), slog.Uint64("operator_id", 0), slog.Any("err", err)) r.notifyFailed(r.t.Get("panel certificate"), err) @@ -139,7 +139,7 @@ func (r *CertRenew) Run(_ context.Context) error { r.log.Warn("failed to get a panel user", slog.String("type", biz.OperationTypeCert), slog.Uint64("operator_id", 0), slog.Any("err", err)) return nil } - account, err := r.certAccountRepo.GetDefault(user.ID) + account, err := r.certAccountRepo.GetDefault(ctx, user.ID) if err != nil { r.log.Warn("failed to get panel ACME account", slog.String("type", biz.OperationTypeCert), slog.Uint64("operator_id", 0), slog.Any("err", err)) r.notifyFailed(r.t.Get("panel certificate"), err) diff --git a/internal/job/firewall_scan.go b/internal/job/firewall_scan.go index 1d0b9673b..2b4d59a2a 100644 --- a/internal/job/firewall_scan.go +++ b/internal/job/firewall_scan.go @@ -72,7 +72,7 @@ func (r *FirewallScan) Run(_ context.Context) error { if err != nil || !enabled { // 未启用时,确保 scanner 已停止 r.stopScanner() - return nil + return nil //nolint:nilerr } // 确保 scanner 已启动 @@ -245,8 +245,8 @@ func (r *FirewallScan) autoBlock() { // 解析白名单 whitelist := parseWhitelist(setting.Whitelist) now := time.Now() - window := time.Duration(setting.BlockWindow) * time.Minute - duration := time.Duration(setting.BlockDuration) * time.Hour + window := time.Duration(setting.BlockWindow) * time.Minute //nolint:gosec + duration := time.Duration(setting.BlockDuration) * time.Hour //nolint:gosec var toBlock []struct { ip string diff --git a/internal/job/job.go b/internal/job/job.go index 587cb03cc..ab9e603ba 100644 --- a/internal/job/job.go +++ b/internal/job/job.go @@ -3,7 +3,6 @@ package job import ( "log/slog" - "github.com/google/wire" "github.com/leonelquinteros/gotext" "github.com/libtnb/cron" "gorm.io/gorm" @@ -20,8 +19,6 @@ type Job struct { Immediate bool // 调度器启动后立即执行一次,不等首个调度点 } -var ProviderSet = wire.NewSet(wire.Struct(new(Dependencies), "*"), NewJobs) - // Dependencies 汇总定时任务依赖,Wire 会在生成期校验完整性。 type Dependencies struct { Alert *biz.AlertUsecase diff --git a/internal/job/monitoring.go b/internal/job/monitoring.go index 599db5ed7..830e7a344 100644 --- a/internal/job/monitoring.go +++ b/internal/job/monitoring.go @@ -40,7 +40,7 @@ func (r *Monitoring) Run(_ context.Context) error { monitor, err := r.settingRepo.Get(biz.SettingKeyMonitor) if err != nil || !cast.ToBool(monitor) { - return nil + return nil //nolint:nilerr } // 根据采集间隔判断是否该采集 @@ -77,7 +77,7 @@ func (r *Monitoring) Run(_ context.Context) error { dayStr, err := r.settingRepo.Get(biz.SettingKeyMonitorDays) if err != nil { - return nil + return nil //nolint:nilerr } day := cast.ToInt(dayStr) if day <= 0 || app.Status != app.StatusNormal { diff --git a/internal/job/panel_task.go b/internal/job/panel_task.go index 944bd5748..553bcbc30 100644 --- a/internal/job/panel_task.go +++ b/internal/job/panel_task.go @@ -123,7 +123,7 @@ func (r *PanelTask) Run(_ context.Context) error { // 更新分类缓存 func (r *PanelTask) updateCategories() { - time.AfterFunc(time.Duration(rand.IntN(300))*time.Second, func() { + time.AfterFunc(time.Duration(rand.IntN(300))*time.Second, func() { //nolint:gosec if err := r.cacheRepo.UpdateCategories(); err != nil { r.log.Warn("failed to update categories cache", slog.String("type", biz.OperationTypePanel), slog.Uint64("operator_id", 0), slog.Any("err", err)) } @@ -132,7 +132,7 @@ func (r *PanelTask) updateCategories() { // 更新商店缓存 func (r *PanelTask) updateApps() { - time.AfterFunc(time.Duration(rand.IntN(300))*time.Second, func() { + time.AfterFunc(time.Duration(rand.IntN(300))*time.Second, func() { //nolint:gosec if err := r.cacheRepo.UpdateApps(); err != nil { r.log.Warn("failed to update apps cache", slog.String("type", biz.OperationTypePanel), slog.Uint64("operator_id", 0), slog.Any("err", err)) } @@ -141,7 +141,7 @@ func (r *PanelTask) updateApps() { // 更新运行环境缓存 func (r *PanelTask) updateEnvironments() { - time.AfterFunc(time.Duration(rand.IntN(300))*time.Second, func() { + time.AfterFunc(time.Duration(rand.IntN(300))*time.Second, func() { //nolint:gosec if err := r.cacheRepo.UpdateEnvironments(); err != nil { r.log.Warn("failed to update environment cache", slog.String("type", biz.OperationTypePanel), slog.Uint64("operator_id", 0), slog.Any("err", err)) } @@ -150,7 +150,7 @@ func (r *PanelTask) updateEnvironments() { // 更新模版缓存 func (r *PanelTask) updateTemplates() { - time.AfterFunc(time.Duration(rand.IntN(300))*time.Second, func() { + time.AfterFunc(time.Duration(rand.IntN(300))*time.Second, func() { //nolint:gosec if err := r.cacheRepo.UpdateTemplates(); err != nil { r.log.Warn("failed to update template cache", slog.String("type", biz.OperationTypePanel), slog.Uint64("operator_id", 0), slog.Any("err", err)) } @@ -166,7 +166,7 @@ func (r *PanelTask) updatePanel() { channel, _ := r.settingRepo.Get(biz.SettingKeyChannel) // 加 360 秒确保在缓存更新后才更新面板 - time.AfterFunc(time.Duration(rand.IntN(300))*time.Second+360*time.Second, func() { + time.AfterFunc(time.Duration(rand.IntN(300))*time.Second+360*time.Second, func() { //nolint:gosec panel, err := r.api.LatestVersion(channel) if err != nil { return diff --git a/internal/job/wire.go b/internal/job/wire.go new file mode 100644 index 000000000..8cd4f8554 --- /dev/null +++ b/internal/job/wire.go @@ -0,0 +1,11 @@ +//go:build wireinject + +package job + +import "github.com/libtnb/wire" + +// Module 装配定时任务 +var Module = wire.New(). + Struct[Dependencies](). + Provide(NewJobs). + Export[[]Job]() diff --git a/internal/middleware/must_login.go b/internal/middleware/must_login.go index fe9429f7a..25e49121b 100644 --- a/internal/middleware/must_login.go +++ b/internal/middleware/must_login.go @@ -79,6 +79,7 @@ func MustLogin(t *gotext.Locale, conf *config.Config, session *sessions.Manager, if time.Now().Unix()-refreshAt > 600 { sess.Put("refresh_at", time.Now().Unix()) // 重新设置 Cookie + //nolint:gosec http.SetCookie(w, &http.Cookie{ Name: sess.GetName(), Value: sess.GetID(), @@ -96,7 +97,8 @@ func MustLogin(t *gotext.Locale, conf *config.Config, session *sessions.Manager, return } - r = r.WithContext(context.WithValue(r.Context(), "user_id", userID)) // nolint:staticcheck + //nolint:staticcheck + r = r.WithContext(context.WithValue(r.Context(), "user_id", userID)) next.ServeHTTP(w, r) }) } diff --git a/internal/middleware/recoverer.go b/internal/middleware/recoverer.go index 82c6b4250..5c76d0d6c 100644 --- a/internal/middleware/recoverer.go +++ b/internal/middleware/recoverer.go @@ -1,6 +1,7 @@ package middleware import ( + "errors" "fmt" "log/slog" "net/http" @@ -12,7 +13,7 @@ func Recoverer(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer func() { if rvr := recover(); rvr != nil { - if rvr == http.ErrAbortHandler { + if err, ok := rvr.(error); ok && errors.Is(err, http.ErrAbortHandler) { panic(rvr) } diff --git a/internal/mocks/biz/AlertRepo.go b/internal/mocks/biz/AlertRepo.go new file mode 100644 index 000000000..9984b5e17 --- /dev/null +++ b/internal/mocks/biz/AlertRepo.go @@ -0,0 +1,657 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + "time" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that AlertRepo does implement biz.AlertRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.AlertRepo = &AlertRepo{} + +// AlertRepo is a mock implementation of biz.AlertRepo. +// +// func TestSomethingThatUsesAlertRepo(t *testing.T) { +// +// // make and configure a mocked biz.AlertRepo +// mockedAlertRepo := &AlertRepo{ +// AddAlertFunc: func(alert *biz.Alert) error { +// panic("mock out the AddAlert method") +// }, +// AllRulesFunc: func() ([]*biz.AlertRule, error) { +// panic("mock out the AllRules method") +// }, +// CertExpiryFunc: func() ([]*biz.AlertMetric, error) { +// panic("mock out the CertExpiry method") +// }, +// ClearAlertsFunc: func() error { +// panic("mock out the ClearAlerts method") +// }, +// ClearAlertsBeforeFunc: func(t time.Time) error { +// panic("mock out the ClearAlertsBefore method") +// }, +// CreateRuleFunc: func(rule *biz.AlertRule) error { +// panic("mock out the CreateRule method") +// }, +// DatabaseServersFunc: func() ([]*biz.DatabaseServer, error) { +// panic("mock out the DatabaseServers method") +// }, +// DeleteRuleFunc: func(id uint) error { +// panic("mock out the DeleteRule method") +// }, +// GetRuleFunc: func(id uint) (*biz.AlertRule, error) { +// panic("mock out the GetRule method") +// }, +// ListAlertsFunc: func(page uint, limit uint) ([]*biz.Alert, int64, error) { +// panic("mock out the ListAlerts method") +// }, +// ListRulesFunc: func(page uint, limit uint) ([]*biz.AlertRule, int64, error) { +// panic("mock out the ListRules method") +// }, +// ProjectNamesFunc: func() ([]string, error) { +// panic("mock out the ProjectNames method") +// }, +// UpdateRuleFunc: func(rule *biz.AlertRule) error { +// panic("mock out the UpdateRule method") +// }, +// WebsiteExpiryFunc: func() ([]*biz.AlertMetric, error) { +// panic("mock out the WebsiteExpiry method") +// }, +// WebsiteHourStatsFunc: func() ([]*biz.WebsiteHourStat, error) { +// panic("mock out the WebsiteHourStats method") +// }, +// } +// +// // use mockedAlertRepo in code that requires biz.AlertRepo +// // and then make assertions. +// +// } +type AlertRepo struct { + // AddAlertFunc mocks the AddAlert method. + AddAlertFunc func(alert *biz.Alert) error + + // AllRulesFunc mocks the AllRules method. + AllRulesFunc func() ([]*biz.AlertRule, error) + + // CertExpiryFunc mocks the CertExpiry method. + CertExpiryFunc func() ([]*biz.AlertMetric, error) + + // ClearAlertsFunc mocks the ClearAlerts method. + ClearAlertsFunc func() error + + // ClearAlertsBeforeFunc mocks the ClearAlertsBefore method. + ClearAlertsBeforeFunc func(t time.Time) error + + // CreateRuleFunc mocks the CreateRule method. + CreateRuleFunc func(rule *biz.AlertRule) error + + // DatabaseServersFunc mocks the DatabaseServers method. + DatabaseServersFunc func() ([]*biz.DatabaseServer, error) + + // DeleteRuleFunc mocks the DeleteRule method. + DeleteRuleFunc func(id uint) error + + // GetRuleFunc mocks the GetRule method. + GetRuleFunc func(id uint) (*biz.AlertRule, error) + + // ListAlertsFunc mocks the ListAlerts method. + ListAlertsFunc func(page uint, limit uint) ([]*biz.Alert, int64, error) + + // ListRulesFunc mocks the ListRules method. + ListRulesFunc func(page uint, limit uint) ([]*biz.AlertRule, int64, error) + + // ProjectNamesFunc mocks the ProjectNames method. + ProjectNamesFunc func() ([]string, error) + + // UpdateRuleFunc mocks the UpdateRule method. + UpdateRuleFunc func(rule *biz.AlertRule) error + + // WebsiteExpiryFunc mocks the WebsiteExpiry method. + WebsiteExpiryFunc func() ([]*biz.AlertMetric, error) + + // WebsiteHourStatsFunc mocks the WebsiteHourStats method. + WebsiteHourStatsFunc func() ([]*biz.WebsiteHourStat, error) + + // calls tracks calls to the methods. + calls struct { + // AddAlert holds details about calls to the AddAlert method. + AddAlert []struct { + // Alert is the alert argument value. + Alert *biz.Alert + } + // AllRules holds details about calls to the AllRules method. + AllRules []struct { + } + // CertExpiry holds details about calls to the CertExpiry method. + CertExpiry []struct { + } + // ClearAlerts holds details about calls to the ClearAlerts method. + ClearAlerts []struct { + } + // ClearAlertsBefore holds details about calls to the ClearAlertsBefore method. + ClearAlertsBefore []struct { + // T is the t argument value. + T time.Time + } + // CreateRule holds details about calls to the CreateRule method. + CreateRule []struct { + // Rule is the rule argument value. + Rule *biz.AlertRule + } + // DatabaseServers holds details about calls to the DatabaseServers method. + DatabaseServers []struct { + } + // DeleteRule holds details about calls to the DeleteRule method. + DeleteRule []struct { + // ID is the id argument value. + ID uint + } + // GetRule holds details about calls to the GetRule method. + GetRule []struct { + // ID is the id argument value. + ID uint + } + // ListAlerts holds details about calls to the ListAlerts method. + ListAlerts []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // ListRules holds details about calls to the ListRules method. + ListRules []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // ProjectNames holds details about calls to the ProjectNames method. + ProjectNames []struct { + } + // UpdateRule holds details about calls to the UpdateRule method. + UpdateRule []struct { + // Rule is the rule argument value. + Rule *biz.AlertRule + } + // WebsiteExpiry holds details about calls to the WebsiteExpiry method. + WebsiteExpiry []struct { + } + // WebsiteHourStats holds details about calls to the WebsiteHourStats method. + WebsiteHourStats []struct { + } + } + lockAddAlert sync.RWMutex + lockAllRules sync.RWMutex + lockCertExpiry sync.RWMutex + lockClearAlerts sync.RWMutex + lockClearAlertsBefore sync.RWMutex + lockCreateRule sync.RWMutex + lockDatabaseServers sync.RWMutex + lockDeleteRule sync.RWMutex + lockGetRule sync.RWMutex + lockListAlerts sync.RWMutex + lockListRules sync.RWMutex + lockProjectNames sync.RWMutex + lockUpdateRule sync.RWMutex + lockWebsiteExpiry sync.RWMutex + lockWebsiteHourStats sync.RWMutex +} + +// AddAlert calls AddAlertFunc. +func (mock *AlertRepo) AddAlert(alert *biz.Alert) error { + if mock.AddAlertFunc == nil { + panic("AlertRepo.AddAlertFunc: method is nil but AlertRepo.AddAlert was just called") + } + callInfo := struct { + Alert *biz.Alert + }{ + Alert: alert, + } + mock.lockAddAlert.Lock() + mock.calls.AddAlert = append(mock.calls.AddAlert, callInfo) + mock.lockAddAlert.Unlock() + return mock.AddAlertFunc(alert) +} + +// AddAlertCalls gets all the calls that were made to AddAlert. +// Check the length with: +// +// len(mockedAlertRepo.AddAlertCalls()) +func (mock *AlertRepo) AddAlertCalls() []struct { + Alert *biz.Alert +} { + var calls []struct { + Alert *biz.Alert + } + mock.lockAddAlert.RLock() + calls = mock.calls.AddAlert + mock.lockAddAlert.RUnlock() + return calls +} + +// AllRules calls AllRulesFunc. +func (mock *AlertRepo) AllRules() ([]*biz.AlertRule, error) { + if mock.AllRulesFunc == nil { + panic("AlertRepo.AllRulesFunc: method is nil but AlertRepo.AllRules was just called") + } + callInfo := struct { + }{} + mock.lockAllRules.Lock() + mock.calls.AllRules = append(mock.calls.AllRules, callInfo) + mock.lockAllRules.Unlock() + return mock.AllRulesFunc() +} + +// AllRulesCalls gets all the calls that were made to AllRules. +// Check the length with: +// +// len(mockedAlertRepo.AllRulesCalls()) +func (mock *AlertRepo) AllRulesCalls() []struct { +} { + var calls []struct { + } + mock.lockAllRules.RLock() + calls = mock.calls.AllRules + mock.lockAllRules.RUnlock() + return calls +} + +// CertExpiry calls CertExpiryFunc. +func (mock *AlertRepo) CertExpiry() ([]*biz.AlertMetric, error) { + if mock.CertExpiryFunc == nil { + panic("AlertRepo.CertExpiryFunc: method is nil but AlertRepo.CertExpiry was just called") + } + callInfo := struct { + }{} + mock.lockCertExpiry.Lock() + mock.calls.CertExpiry = append(mock.calls.CertExpiry, callInfo) + mock.lockCertExpiry.Unlock() + return mock.CertExpiryFunc() +} + +// CertExpiryCalls gets all the calls that were made to CertExpiry. +// Check the length with: +// +// len(mockedAlertRepo.CertExpiryCalls()) +func (mock *AlertRepo) CertExpiryCalls() []struct { +} { + var calls []struct { + } + mock.lockCertExpiry.RLock() + calls = mock.calls.CertExpiry + mock.lockCertExpiry.RUnlock() + return calls +} + +// ClearAlerts calls ClearAlertsFunc. +func (mock *AlertRepo) ClearAlerts() error { + if mock.ClearAlertsFunc == nil { + panic("AlertRepo.ClearAlertsFunc: method is nil but AlertRepo.ClearAlerts was just called") + } + callInfo := struct { + }{} + mock.lockClearAlerts.Lock() + mock.calls.ClearAlerts = append(mock.calls.ClearAlerts, callInfo) + mock.lockClearAlerts.Unlock() + return mock.ClearAlertsFunc() +} + +// ClearAlertsCalls gets all the calls that were made to ClearAlerts. +// Check the length with: +// +// len(mockedAlertRepo.ClearAlertsCalls()) +func (mock *AlertRepo) ClearAlertsCalls() []struct { +} { + var calls []struct { + } + mock.lockClearAlerts.RLock() + calls = mock.calls.ClearAlerts + mock.lockClearAlerts.RUnlock() + return calls +} + +// ClearAlertsBefore calls ClearAlertsBeforeFunc. +func (mock *AlertRepo) ClearAlertsBefore(t time.Time) error { + if mock.ClearAlertsBeforeFunc == nil { + panic("AlertRepo.ClearAlertsBeforeFunc: method is nil but AlertRepo.ClearAlertsBefore was just called") + } + callInfo := struct { + T time.Time + }{ + T: t, + } + mock.lockClearAlertsBefore.Lock() + mock.calls.ClearAlertsBefore = append(mock.calls.ClearAlertsBefore, callInfo) + mock.lockClearAlertsBefore.Unlock() + return mock.ClearAlertsBeforeFunc(t) +} + +// ClearAlertsBeforeCalls gets all the calls that were made to ClearAlertsBefore. +// Check the length with: +// +// len(mockedAlertRepo.ClearAlertsBeforeCalls()) +func (mock *AlertRepo) ClearAlertsBeforeCalls() []struct { + T time.Time +} { + var calls []struct { + T time.Time + } + mock.lockClearAlertsBefore.RLock() + calls = mock.calls.ClearAlertsBefore + mock.lockClearAlertsBefore.RUnlock() + return calls +} + +// CreateRule calls CreateRuleFunc. +func (mock *AlertRepo) CreateRule(rule *biz.AlertRule) error { + if mock.CreateRuleFunc == nil { + panic("AlertRepo.CreateRuleFunc: method is nil but AlertRepo.CreateRule was just called") + } + callInfo := struct { + Rule *biz.AlertRule + }{ + Rule: rule, + } + mock.lockCreateRule.Lock() + mock.calls.CreateRule = append(mock.calls.CreateRule, callInfo) + mock.lockCreateRule.Unlock() + return mock.CreateRuleFunc(rule) +} + +// CreateRuleCalls gets all the calls that were made to CreateRule. +// Check the length with: +// +// len(mockedAlertRepo.CreateRuleCalls()) +func (mock *AlertRepo) CreateRuleCalls() []struct { + Rule *biz.AlertRule +} { + var calls []struct { + Rule *biz.AlertRule + } + mock.lockCreateRule.RLock() + calls = mock.calls.CreateRule + mock.lockCreateRule.RUnlock() + return calls +} + +// DatabaseServers calls DatabaseServersFunc. +func (mock *AlertRepo) DatabaseServers() ([]*biz.DatabaseServer, error) { + if mock.DatabaseServersFunc == nil { + panic("AlertRepo.DatabaseServersFunc: method is nil but AlertRepo.DatabaseServers was just called") + } + callInfo := struct { + }{} + mock.lockDatabaseServers.Lock() + mock.calls.DatabaseServers = append(mock.calls.DatabaseServers, callInfo) + mock.lockDatabaseServers.Unlock() + return mock.DatabaseServersFunc() +} + +// DatabaseServersCalls gets all the calls that were made to DatabaseServers. +// Check the length with: +// +// len(mockedAlertRepo.DatabaseServersCalls()) +func (mock *AlertRepo) DatabaseServersCalls() []struct { +} { + var calls []struct { + } + mock.lockDatabaseServers.RLock() + calls = mock.calls.DatabaseServers + mock.lockDatabaseServers.RUnlock() + return calls +} + +// DeleteRule calls DeleteRuleFunc. +func (mock *AlertRepo) DeleteRule(id uint) error { + if mock.DeleteRuleFunc == nil { + panic("AlertRepo.DeleteRuleFunc: method is nil but AlertRepo.DeleteRule was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDeleteRule.Lock() + mock.calls.DeleteRule = append(mock.calls.DeleteRule, callInfo) + mock.lockDeleteRule.Unlock() + return mock.DeleteRuleFunc(id) +} + +// DeleteRuleCalls gets all the calls that were made to DeleteRule. +// Check the length with: +// +// len(mockedAlertRepo.DeleteRuleCalls()) +func (mock *AlertRepo) DeleteRuleCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDeleteRule.RLock() + calls = mock.calls.DeleteRule + mock.lockDeleteRule.RUnlock() + return calls +} + +// GetRule calls GetRuleFunc. +func (mock *AlertRepo) GetRule(id uint) (*biz.AlertRule, error) { + if mock.GetRuleFunc == nil { + panic("AlertRepo.GetRuleFunc: method is nil but AlertRepo.GetRule was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGetRule.Lock() + mock.calls.GetRule = append(mock.calls.GetRule, callInfo) + mock.lockGetRule.Unlock() + return mock.GetRuleFunc(id) +} + +// GetRuleCalls gets all the calls that were made to GetRule. +// Check the length with: +// +// len(mockedAlertRepo.GetRuleCalls()) +func (mock *AlertRepo) GetRuleCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGetRule.RLock() + calls = mock.calls.GetRule + mock.lockGetRule.RUnlock() + return calls +} + +// ListAlerts calls ListAlertsFunc. +func (mock *AlertRepo) ListAlerts(page uint, limit uint) ([]*biz.Alert, int64, error) { + if mock.ListAlertsFunc == nil { + panic("AlertRepo.ListAlertsFunc: method is nil but AlertRepo.ListAlerts was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockListAlerts.Lock() + mock.calls.ListAlerts = append(mock.calls.ListAlerts, callInfo) + mock.lockListAlerts.Unlock() + return mock.ListAlertsFunc(page, limit) +} + +// ListAlertsCalls gets all the calls that were made to ListAlerts. +// Check the length with: +// +// len(mockedAlertRepo.ListAlertsCalls()) +func (mock *AlertRepo) ListAlertsCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockListAlerts.RLock() + calls = mock.calls.ListAlerts + mock.lockListAlerts.RUnlock() + return calls +} + +// ListRules calls ListRulesFunc. +func (mock *AlertRepo) ListRules(page uint, limit uint) ([]*biz.AlertRule, int64, error) { + if mock.ListRulesFunc == nil { + panic("AlertRepo.ListRulesFunc: method is nil but AlertRepo.ListRules was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockListRules.Lock() + mock.calls.ListRules = append(mock.calls.ListRules, callInfo) + mock.lockListRules.Unlock() + return mock.ListRulesFunc(page, limit) +} + +// ListRulesCalls gets all the calls that were made to ListRules. +// Check the length with: +// +// len(mockedAlertRepo.ListRulesCalls()) +func (mock *AlertRepo) ListRulesCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockListRules.RLock() + calls = mock.calls.ListRules + mock.lockListRules.RUnlock() + return calls +} + +// ProjectNames calls ProjectNamesFunc. +func (mock *AlertRepo) ProjectNames() ([]string, error) { + if mock.ProjectNamesFunc == nil { + panic("AlertRepo.ProjectNamesFunc: method is nil but AlertRepo.ProjectNames was just called") + } + callInfo := struct { + }{} + mock.lockProjectNames.Lock() + mock.calls.ProjectNames = append(mock.calls.ProjectNames, callInfo) + mock.lockProjectNames.Unlock() + return mock.ProjectNamesFunc() +} + +// ProjectNamesCalls gets all the calls that were made to ProjectNames. +// Check the length with: +// +// len(mockedAlertRepo.ProjectNamesCalls()) +func (mock *AlertRepo) ProjectNamesCalls() []struct { +} { + var calls []struct { + } + mock.lockProjectNames.RLock() + calls = mock.calls.ProjectNames + mock.lockProjectNames.RUnlock() + return calls +} + +// UpdateRule calls UpdateRuleFunc. +func (mock *AlertRepo) UpdateRule(rule *biz.AlertRule) error { + if mock.UpdateRuleFunc == nil { + panic("AlertRepo.UpdateRuleFunc: method is nil but AlertRepo.UpdateRule was just called") + } + callInfo := struct { + Rule *biz.AlertRule + }{ + Rule: rule, + } + mock.lockUpdateRule.Lock() + mock.calls.UpdateRule = append(mock.calls.UpdateRule, callInfo) + mock.lockUpdateRule.Unlock() + return mock.UpdateRuleFunc(rule) +} + +// UpdateRuleCalls gets all the calls that were made to UpdateRule. +// Check the length with: +// +// len(mockedAlertRepo.UpdateRuleCalls()) +func (mock *AlertRepo) UpdateRuleCalls() []struct { + Rule *biz.AlertRule +} { + var calls []struct { + Rule *biz.AlertRule + } + mock.lockUpdateRule.RLock() + calls = mock.calls.UpdateRule + mock.lockUpdateRule.RUnlock() + return calls +} + +// WebsiteExpiry calls WebsiteExpiryFunc. +func (mock *AlertRepo) WebsiteExpiry() ([]*biz.AlertMetric, error) { + if mock.WebsiteExpiryFunc == nil { + panic("AlertRepo.WebsiteExpiryFunc: method is nil but AlertRepo.WebsiteExpiry was just called") + } + callInfo := struct { + }{} + mock.lockWebsiteExpiry.Lock() + mock.calls.WebsiteExpiry = append(mock.calls.WebsiteExpiry, callInfo) + mock.lockWebsiteExpiry.Unlock() + return mock.WebsiteExpiryFunc() +} + +// WebsiteExpiryCalls gets all the calls that were made to WebsiteExpiry. +// Check the length with: +// +// len(mockedAlertRepo.WebsiteExpiryCalls()) +func (mock *AlertRepo) WebsiteExpiryCalls() []struct { +} { + var calls []struct { + } + mock.lockWebsiteExpiry.RLock() + calls = mock.calls.WebsiteExpiry + mock.lockWebsiteExpiry.RUnlock() + return calls +} + +// WebsiteHourStats calls WebsiteHourStatsFunc. +func (mock *AlertRepo) WebsiteHourStats() ([]*biz.WebsiteHourStat, error) { + if mock.WebsiteHourStatsFunc == nil { + panic("AlertRepo.WebsiteHourStatsFunc: method is nil but AlertRepo.WebsiteHourStats was just called") + } + callInfo := struct { + }{} + mock.lockWebsiteHourStats.Lock() + mock.calls.WebsiteHourStats = append(mock.calls.WebsiteHourStats, callInfo) + mock.lockWebsiteHourStats.Unlock() + return mock.WebsiteHourStatsFunc() +} + +// WebsiteHourStatsCalls gets all the calls that were made to WebsiteHourStats. +// Check the length with: +// +// len(mockedAlertRepo.WebsiteHourStatsCalls()) +func (mock *AlertRepo) WebsiteHourStatsCalls() []struct { +} { + var calls []struct { + } + mock.lockWebsiteHourStats.RLock() + calls = mock.calls.WebsiteHourStats + mock.lockWebsiteHourStats.RUnlock() + return calls +} diff --git a/internal/mocks/biz/AppRepo.go b/internal/mocks/biz/AppRepo.go new file mode 100644 index 000000000..457d2e68b --- /dev/null +++ b/internal/mocks/biz/AppRepo.go @@ -0,0 +1,677 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/pkg/api" +) + +// Ensure that AppRepo does implement biz.AppRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.AppRepo = &AppRepo{} + +// AppRepo is a mock implementation of biz.AppRepo. +// +// func TestSomethingThatUsesAppRepo(t *testing.T) { +// +// // make and configure a mocked biz.AppRepo +// mockedAppRepo := &AppRepo{ +// CheckPanelVersionFunc: func() error { +// panic("mock out the CheckPanelVersion method") +// }, +// DownloadCallbackFunc: func(slug string) { +// panic("mock out the DownloadCallback method") +// }, +// ExecScriptFunc: func(script string) error { +// panic("mock out the ExecScript method") +// }, +// GetCustomFunc: func(slug string) (*biz.AppCustom, error) { +// panic("mock out the GetCustom method") +// }, +// GetInstalledFunc: func(slug string) (*biz.App, error) { +// panic("mock out the GetInstalled method") +// }, +// GetInstalledAllFunc: func(query string, cond ...string) ([]*biz.App, error) { +// panic("mock out the GetInstalledAll method") +// }, +// InstalledFunc: func() ([]*biz.App, error) { +// panic("mock out the Installed method") +// }, +// IsInstalledFunc: func(query string, cond ...any) (bool, error) { +// panic("mock out the IsInstalled method") +// }, +// ListHomeShowFunc: func() ([]*biz.App, error) { +// panic("mock out the ListHomeShow method") +// }, +// PreCheckFunc: func(item *api.App, catalog api.Apps) error { +// panic("mock out the PreCheck method") +// }, +// ResolveScriptFunc: func(item *api.App, matchChannel string, action string, execVersion string) (string, error) { +// panic("mock out the ResolveScript method") +// }, +// SaveCustomFunc: func(slug string, custom *biz.AppCustom) error { +// panic("mock out the SaveCustom method") +// }, +// UpdateOrderFunc: func(slugs []string) error { +// panic("mock out the UpdateOrder method") +// }, +// UpdateShowFunc: func(slug string, show bool) error { +// panic("mock out the UpdateShow method") +// }, +// } +// +// // use mockedAppRepo in code that requires biz.AppRepo +// // and then make assertions. +// +// } +type AppRepo struct { + // CheckPanelVersionFunc mocks the CheckPanelVersion method. + CheckPanelVersionFunc func() error + + // DownloadCallbackFunc mocks the DownloadCallback method. + DownloadCallbackFunc func(slug string) + + // ExecScriptFunc mocks the ExecScript method. + ExecScriptFunc func(script string) error + + // GetCustomFunc mocks the GetCustom method. + GetCustomFunc func(slug string) (*biz.AppCustom, error) + + // GetInstalledFunc mocks the GetInstalled method. + GetInstalledFunc func(slug string) (*biz.App, error) + + // GetInstalledAllFunc mocks the GetInstalledAll method. + GetInstalledAllFunc func(query string, cond ...string) ([]*biz.App, error) + + // InstalledFunc mocks the Installed method. + InstalledFunc func() ([]*biz.App, error) + + // IsInstalledFunc mocks the IsInstalled method. + IsInstalledFunc func(query string, cond ...any) (bool, error) + + // ListHomeShowFunc mocks the ListHomeShow method. + ListHomeShowFunc func() ([]*biz.App, error) + + // PreCheckFunc mocks the PreCheck method. + PreCheckFunc func(item *api.App, catalog api.Apps) error + + // ResolveScriptFunc mocks the ResolveScript method. + ResolveScriptFunc func(item *api.App, matchChannel string, action string, execVersion string) (string, error) + + // SaveCustomFunc mocks the SaveCustom method. + SaveCustomFunc func(slug string, custom *biz.AppCustom) error + + // UpdateOrderFunc mocks the UpdateOrder method. + UpdateOrderFunc func(slugs []string) error + + // UpdateShowFunc mocks the UpdateShow method. + UpdateShowFunc func(slug string, show bool) error + + // calls tracks calls to the methods. + calls struct { + // CheckPanelVersion holds details about calls to the CheckPanelVersion method. + CheckPanelVersion []struct { + } + // DownloadCallback holds details about calls to the DownloadCallback method. + DownloadCallback []struct { + // Slug is the slug argument value. + Slug string + } + // ExecScript holds details about calls to the ExecScript method. + ExecScript []struct { + // Script is the script argument value. + Script string + } + // GetCustom holds details about calls to the GetCustom method. + GetCustom []struct { + // Slug is the slug argument value. + Slug string + } + // GetInstalled holds details about calls to the GetInstalled method. + GetInstalled []struct { + // Slug is the slug argument value. + Slug string + } + // GetInstalledAll holds details about calls to the GetInstalledAll method. + GetInstalledAll []struct { + // Query is the query argument value. + Query string + // Cond is the cond argument value. + Cond []string + } + // Installed holds details about calls to the Installed method. + Installed []struct { + } + // IsInstalled holds details about calls to the IsInstalled method. + IsInstalled []struct { + // Query is the query argument value. + Query string + // Cond is the cond argument value. + Cond []any + } + // ListHomeShow holds details about calls to the ListHomeShow method. + ListHomeShow []struct { + } + // PreCheck holds details about calls to the PreCheck method. + PreCheck []struct { + // Item is the item argument value. + Item *api.App + // Catalog is the catalog argument value. + Catalog api.Apps + } + // ResolveScript holds details about calls to the ResolveScript method. + ResolveScript []struct { + // Item is the item argument value. + Item *api.App + // MatchChannel is the matchChannel argument value. + MatchChannel string + // Action is the action argument value. + Action string + // ExecVersion is the execVersion argument value. + ExecVersion string + } + // SaveCustom holds details about calls to the SaveCustom method. + SaveCustom []struct { + // Slug is the slug argument value. + Slug string + // Custom is the custom argument value. + Custom *biz.AppCustom + } + // UpdateOrder holds details about calls to the UpdateOrder method. + UpdateOrder []struct { + // Slugs is the slugs argument value. + Slugs []string + } + // UpdateShow holds details about calls to the UpdateShow method. + UpdateShow []struct { + // Slug is the slug argument value. + Slug string + // Show is the show argument value. + Show bool + } + } + lockCheckPanelVersion sync.RWMutex + lockDownloadCallback sync.RWMutex + lockExecScript sync.RWMutex + lockGetCustom sync.RWMutex + lockGetInstalled sync.RWMutex + lockGetInstalledAll sync.RWMutex + lockInstalled sync.RWMutex + lockIsInstalled sync.RWMutex + lockListHomeShow sync.RWMutex + lockPreCheck sync.RWMutex + lockResolveScript sync.RWMutex + lockSaveCustom sync.RWMutex + lockUpdateOrder sync.RWMutex + lockUpdateShow sync.RWMutex +} + +// CheckPanelVersion calls CheckPanelVersionFunc. +func (mock *AppRepo) CheckPanelVersion() error { + if mock.CheckPanelVersionFunc == nil { + panic("AppRepo.CheckPanelVersionFunc: method is nil but AppRepo.CheckPanelVersion was just called") + } + callInfo := struct { + }{} + mock.lockCheckPanelVersion.Lock() + mock.calls.CheckPanelVersion = append(mock.calls.CheckPanelVersion, callInfo) + mock.lockCheckPanelVersion.Unlock() + return mock.CheckPanelVersionFunc() +} + +// CheckPanelVersionCalls gets all the calls that were made to CheckPanelVersion. +// Check the length with: +// +// len(mockedAppRepo.CheckPanelVersionCalls()) +func (mock *AppRepo) CheckPanelVersionCalls() []struct { +} { + var calls []struct { + } + mock.lockCheckPanelVersion.RLock() + calls = mock.calls.CheckPanelVersion + mock.lockCheckPanelVersion.RUnlock() + return calls +} + +// DownloadCallback calls DownloadCallbackFunc. +func (mock *AppRepo) DownloadCallback(slug string) { + if mock.DownloadCallbackFunc == nil { + panic("AppRepo.DownloadCallbackFunc: method is nil but AppRepo.DownloadCallback was just called") + } + callInfo := struct { + Slug string + }{ + Slug: slug, + } + mock.lockDownloadCallback.Lock() + mock.calls.DownloadCallback = append(mock.calls.DownloadCallback, callInfo) + mock.lockDownloadCallback.Unlock() + mock.DownloadCallbackFunc(slug) +} + +// DownloadCallbackCalls gets all the calls that were made to DownloadCallback. +// Check the length with: +// +// len(mockedAppRepo.DownloadCallbackCalls()) +func (mock *AppRepo) DownloadCallbackCalls() []struct { + Slug string +} { + var calls []struct { + Slug string + } + mock.lockDownloadCallback.RLock() + calls = mock.calls.DownloadCallback + mock.lockDownloadCallback.RUnlock() + return calls +} + +// ExecScript calls ExecScriptFunc. +func (mock *AppRepo) ExecScript(script string) error { + if mock.ExecScriptFunc == nil { + panic("AppRepo.ExecScriptFunc: method is nil but AppRepo.ExecScript was just called") + } + callInfo := struct { + Script string + }{ + Script: script, + } + mock.lockExecScript.Lock() + mock.calls.ExecScript = append(mock.calls.ExecScript, callInfo) + mock.lockExecScript.Unlock() + return mock.ExecScriptFunc(script) +} + +// ExecScriptCalls gets all the calls that were made to ExecScript. +// Check the length with: +// +// len(mockedAppRepo.ExecScriptCalls()) +func (mock *AppRepo) ExecScriptCalls() []struct { + Script string +} { + var calls []struct { + Script string + } + mock.lockExecScript.RLock() + calls = mock.calls.ExecScript + mock.lockExecScript.RUnlock() + return calls +} + +// GetCustom calls GetCustomFunc. +func (mock *AppRepo) GetCustom(slug string) (*biz.AppCustom, error) { + if mock.GetCustomFunc == nil { + panic("AppRepo.GetCustomFunc: method is nil but AppRepo.GetCustom was just called") + } + callInfo := struct { + Slug string + }{ + Slug: slug, + } + mock.lockGetCustom.Lock() + mock.calls.GetCustom = append(mock.calls.GetCustom, callInfo) + mock.lockGetCustom.Unlock() + return mock.GetCustomFunc(slug) +} + +// GetCustomCalls gets all the calls that were made to GetCustom. +// Check the length with: +// +// len(mockedAppRepo.GetCustomCalls()) +func (mock *AppRepo) GetCustomCalls() []struct { + Slug string +} { + var calls []struct { + Slug string + } + mock.lockGetCustom.RLock() + calls = mock.calls.GetCustom + mock.lockGetCustom.RUnlock() + return calls +} + +// GetInstalled calls GetInstalledFunc. +func (mock *AppRepo) GetInstalled(slug string) (*biz.App, error) { + if mock.GetInstalledFunc == nil { + panic("AppRepo.GetInstalledFunc: method is nil but AppRepo.GetInstalled was just called") + } + callInfo := struct { + Slug string + }{ + Slug: slug, + } + mock.lockGetInstalled.Lock() + mock.calls.GetInstalled = append(mock.calls.GetInstalled, callInfo) + mock.lockGetInstalled.Unlock() + return mock.GetInstalledFunc(slug) +} + +// GetInstalledCalls gets all the calls that were made to GetInstalled. +// Check the length with: +// +// len(mockedAppRepo.GetInstalledCalls()) +func (mock *AppRepo) GetInstalledCalls() []struct { + Slug string +} { + var calls []struct { + Slug string + } + mock.lockGetInstalled.RLock() + calls = mock.calls.GetInstalled + mock.lockGetInstalled.RUnlock() + return calls +} + +// GetInstalledAll calls GetInstalledAllFunc. +func (mock *AppRepo) GetInstalledAll(query string, cond ...string) ([]*biz.App, error) { + if mock.GetInstalledAllFunc == nil { + panic("AppRepo.GetInstalledAllFunc: method is nil but AppRepo.GetInstalledAll was just called") + } + callInfo := struct { + Query string + Cond []string + }{ + Query: query, + Cond: cond, + } + mock.lockGetInstalledAll.Lock() + mock.calls.GetInstalledAll = append(mock.calls.GetInstalledAll, callInfo) + mock.lockGetInstalledAll.Unlock() + return mock.GetInstalledAllFunc(query, cond...) +} + +// GetInstalledAllCalls gets all the calls that were made to GetInstalledAll. +// Check the length with: +// +// len(mockedAppRepo.GetInstalledAllCalls()) +func (mock *AppRepo) GetInstalledAllCalls() []struct { + Query string + Cond []string +} { + var calls []struct { + Query string + Cond []string + } + mock.lockGetInstalledAll.RLock() + calls = mock.calls.GetInstalledAll + mock.lockGetInstalledAll.RUnlock() + return calls +} + +// Installed calls InstalledFunc. +func (mock *AppRepo) Installed() ([]*biz.App, error) { + if mock.InstalledFunc == nil { + panic("AppRepo.InstalledFunc: method is nil but AppRepo.Installed was just called") + } + callInfo := struct { + }{} + mock.lockInstalled.Lock() + mock.calls.Installed = append(mock.calls.Installed, callInfo) + mock.lockInstalled.Unlock() + return mock.InstalledFunc() +} + +// InstalledCalls gets all the calls that were made to Installed. +// Check the length with: +// +// len(mockedAppRepo.InstalledCalls()) +func (mock *AppRepo) InstalledCalls() []struct { +} { + var calls []struct { + } + mock.lockInstalled.RLock() + calls = mock.calls.Installed + mock.lockInstalled.RUnlock() + return calls +} + +// IsInstalled calls IsInstalledFunc. +func (mock *AppRepo) IsInstalled(query string, cond ...any) (bool, error) { + if mock.IsInstalledFunc == nil { + panic("AppRepo.IsInstalledFunc: method is nil but AppRepo.IsInstalled was just called") + } + callInfo := struct { + Query string + Cond []any + }{ + Query: query, + Cond: cond, + } + mock.lockIsInstalled.Lock() + mock.calls.IsInstalled = append(mock.calls.IsInstalled, callInfo) + mock.lockIsInstalled.Unlock() + return mock.IsInstalledFunc(query, cond...) +} + +// IsInstalledCalls gets all the calls that were made to IsInstalled. +// Check the length with: +// +// len(mockedAppRepo.IsInstalledCalls()) +func (mock *AppRepo) IsInstalledCalls() []struct { + Query string + Cond []any +} { + var calls []struct { + Query string + Cond []any + } + mock.lockIsInstalled.RLock() + calls = mock.calls.IsInstalled + mock.lockIsInstalled.RUnlock() + return calls +} + +// ListHomeShow calls ListHomeShowFunc. +func (mock *AppRepo) ListHomeShow() ([]*biz.App, error) { + if mock.ListHomeShowFunc == nil { + panic("AppRepo.ListHomeShowFunc: method is nil but AppRepo.ListHomeShow was just called") + } + callInfo := struct { + }{} + mock.lockListHomeShow.Lock() + mock.calls.ListHomeShow = append(mock.calls.ListHomeShow, callInfo) + mock.lockListHomeShow.Unlock() + return mock.ListHomeShowFunc() +} + +// ListHomeShowCalls gets all the calls that were made to ListHomeShow. +// Check the length with: +// +// len(mockedAppRepo.ListHomeShowCalls()) +func (mock *AppRepo) ListHomeShowCalls() []struct { +} { + var calls []struct { + } + mock.lockListHomeShow.RLock() + calls = mock.calls.ListHomeShow + mock.lockListHomeShow.RUnlock() + return calls +} + +// PreCheck calls PreCheckFunc. +func (mock *AppRepo) PreCheck(item *api.App, catalog api.Apps) error { + if mock.PreCheckFunc == nil { + panic("AppRepo.PreCheckFunc: method is nil but AppRepo.PreCheck was just called") + } + callInfo := struct { + Item *api.App + Catalog api.Apps + }{ + Item: item, + Catalog: catalog, + } + mock.lockPreCheck.Lock() + mock.calls.PreCheck = append(mock.calls.PreCheck, callInfo) + mock.lockPreCheck.Unlock() + return mock.PreCheckFunc(item, catalog) +} + +// PreCheckCalls gets all the calls that were made to PreCheck. +// Check the length with: +// +// len(mockedAppRepo.PreCheckCalls()) +func (mock *AppRepo) PreCheckCalls() []struct { + Item *api.App + Catalog api.Apps +} { + var calls []struct { + Item *api.App + Catalog api.Apps + } + mock.lockPreCheck.RLock() + calls = mock.calls.PreCheck + mock.lockPreCheck.RUnlock() + return calls +} + +// ResolveScript calls ResolveScriptFunc. +func (mock *AppRepo) ResolveScript(item *api.App, matchChannel string, action string, execVersion string) (string, error) { + if mock.ResolveScriptFunc == nil { + panic("AppRepo.ResolveScriptFunc: method is nil but AppRepo.ResolveScript was just called") + } + callInfo := struct { + Item *api.App + MatchChannel string + Action string + ExecVersion string + }{ + Item: item, + MatchChannel: matchChannel, + Action: action, + ExecVersion: execVersion, + } + mock.lockResolveScript.Lock() + mock.calls.ResolveScript = append(mock.calls.ResolveScript, callInfo) + mock.lockResolveScript.Unlock() + return mock.ResolveScriptFunc(item, matchChannel, action, execVersion) +} + +// ResolveScriptCalls gets all the calls that were made to ResolveScript. +// Check the length with: +// +// len(mockedAppRepo.ResolveScriptCalls()) +func (mock *AppRepo) ResolveScriptCalls() []struct { + Item *api.App + MatchChannel string + Action string + ExecVersion string +} { + var calls []struct { + Item *api.App + MatchChannel string + Action string + ExecVersion string + } + mock.lockResolveScript.RLock() + calls = mock.calls.ResolveScript + mock.lockResolveScript.RUnlock() + return calls +} + +// SaveCustom calls SaveCustomFunc. +func (mock *AppRepo) SaveCustom(slug string, custom *biz.AppCustom) error { + if mock.SaveCustomFunc == nil { + panic("AppRepo.SaveCustomFunc: method is nil but AppRepo.SaveCustom was just called") + } + callInfo := struct { + Slug string + Custom *biz.AppCustom + }{ + Slug: slug, + Custom: custom, + } + mock.lockSaveCustom.Lock() + mock.calls.SaveCustom = append(mock.calls.SaveCustom, callInfo) + mock.lockSaveCustom.Unlock() + return mock.SaveCustomFunc(slug, custom) +} + +// SaveCustomCalls gets all the calls that were made to SaveCustom. +// Check the length with: +// +// len(mockedAppRepo.SaveCustomCalls()) +func (mock *AppRepo) SaveCustomCalls() []struct { + Slug string + Custom *biz.AppCustom +} { + var calls []struct { + Slug string + Custom *biz.AppCustom + } + mock.lockSaveCustom.RLock() + calls = mock.calls.SaveCustom + mock.lockSaveCustom.RUnlock() + return calls +} + +// UpdateOrder calls UpdateOrderFunc. +func (mock *AppRepo) UpdateOrder(slugs []string) error { + if mock.UpdateOrderFunc == nil { + panic("AppRepo.UpdateOrderFunc: method is nil but AppRepo.UpdateOrder was just called") + } + callInfo := struct { + Slugs []string + }{ + Slugs: slugs, + } + mock.lockUpdateOrder.Lock() + mock.calls.UpdateOrder = append(mock.calls.UpdateOrder, callInfo) + mock.lockUpdateOrder.Unlock() + return mock.UpdateOrderFunc(slugs) +} + +// UpdateOrderCalls gets all the calls that were made to UpdateOrder. +// Check the length with: +// +// len(mockedAppRepo.UpdateOrderCalls()) +func (mock *AppRepo) UpdateOrderCalls() []struct { + Slugs []string +} { + var calls []struct { + Slugs []string + } + mock.lockUpdateOrder.RLock() + calls = mock.calls.UpdateOrder + mock.lockUpdateOrder.RUnlock() + return calls +} + +// UpdateShow calls UpdateShowFunc. +func (mock *AppRepo) UpdateShow(slug string, show bool) error { + if mock.UpdateShowFunc == nil { + panic("AppRepo.UpdateShowFunc: method is nil but AppRepo.UpdateShow was just called") + } + callInfo := struct { + Slug string + Show bool + }{ + Slug: slug, + Show: show, + } + mock.lockUpdateShow.Lock() + mock.calls.UpdateShow = append(mock.calls.UpdateShow, callInfo) + mock.lockUpdateShow.Unlock() + return mock.UpdateShowFunc(slug, show) +} + +// UpdateShowCalls gets all the calls that were made to UpdateShow. +// Check the length with: +// +// len(mockedAppRepo.UpdateShowCalls()) +func (mock *AppRepo) UpdateShowCalls() []struct { + Slug string + Show bool +} { + var calls []struct { + Slug string + Show bool + } + mock.lockUpdateShow.RLock() + calls = mock.calls.UpdateShow + mock.lockUpdateShow.RUnlock() + return calls +} diff --git a/internal/mocks/biz/BackupAccountRepo.go b/internal/mocks/biz/BackupAccountRepo.go new file mode 100644 index 000000000..f882e334e --- /dev/null +++ b/internal/mocks/biz/BackupAccountRepo.go @@ -0,0 +1,259 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that BackupAccountRepo does implement biz.BackupAccountRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.BackupAccountRepo = &BackupAccountRepo{} + +// BackupAccountRepo is a mock implementation of biz.BackupAccountRepo. +// +// func TestSomethingThatUsesBackupAccountRepo(t *testing.T) { +// +// // make and configure a mocked biz.BackupAccountRepo +// mockedBackupAccountRepo := &BackupAccountRepo{ +// CreateFunc: func(account *biz.BackupStorage) error { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(id uint) error { +// panic("mock out the Delete method") +// }, +// GetByIDFunc: func(id uint) (*biz.BackupStorage, error) { +// panic("mock out the GetByID method") +// }, +// ListPagedFunc: func(page uint, limit uint) ([]*biz.BackupStorage, int64, error) { +// panic("mock out the ListPaged method") +// }, +// UpdateFunc: func(account *biz.BackupStorage) error { +// panic("mock out the Update method") +// }, +// } +// +// // use mockedBackupAccountRepo in code that requires biz.BackupAccountRepo +// // and then make assertions. +// +// } +type BackupAccountRepo struct { + // CreateFunc mocks the Create method. + CreateFunc func(account *biz.BackupStorage) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) error + + // GetByIDFunc mocks the GetByID method. + GetByIDFunc func(id uint) (*biz.BackupStorage, error) + + // ListPagedFunc mocks the ListPaged method. + ListPagedFunc func(page uint, limit uint) ([]*biz.BackupStorage, int64, error) + + // UpdateFunc mocks the Update method. + UpdateFunc func(account *biz.BackupStorage) error + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // Account is the account argument value. + Account *biz.BackupStorage + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // GetByID holds details about calls to the GetByID method. + GetByID []struct { + // ID is the id argument value. + ID uint + } + // ListPaged holds details about calls to the ListPaged method. + ListPaged []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // Update holds details about calls to the Update method. + Update []struct { + // Account is the account argument value. + Account *biz.BackupStorage + } + } + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockGetByID sync.RWMutex + lockListPaged sync.RWMutex + lockUpdate sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *BackupAccountRepo) Create(account *biz.BackupStorage) error { + if mock.CreateFunc == nil { + panic("BackupAccountRepo.CreateFunc: method is nil but BackupAccountRepo.Create was just called") + } + callInfo := struct { + Account *biz.BackupStorage + }{ + Account: account, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(account) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedBackupAccountRepo.CreateCalls()) +func (mock *BackupAccountRepo) CreateCalls() []struct { + Account *biz.BackupStorage +} { + var calls []struct { + Account *biz.BackupStorage + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *BackupAccountRepo) Delete(id uint) error { + if mock.DeleteFunc == nil { + panic("BackupAccountRepo.DeleteFunc: method is nil but BackupAccountRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedBackupAccountRepo.DeleteCalls()) +func (mock *BackupAccountRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// GetByID calls GetByIDFunc. +func (mock *BackupAccountRepo) GetByID(id uint) (*biz.BackupStorage, error) { + if mock.GetByIDFunc == nil { + panic("BackupAccountRepo.GetByIDFunc: method is nil but BackupAccountRepo.GetByID was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGetByID.Lock() + mock.calls.GetByID = append(mock.calls.GetByID, callInfo) + mock.lockGetByID.Unlock() + return mock.GetByIDFunc(id) +} + +// GetByIDCalls gets all the calls that were made to GetByID. +// Check the length with: +// +// len(mockedBackupAccountRepo.GetByIDCalls()) +func (mock *BackupAccountRepo) GetByIDCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGetByID.RLock() + calls = mock.calls.GetByID + mock.lockGetByID.RUnlock() + return calls +} + +// ListPaged calls ListPagedFunc. +func (mock *BackupAccountRepo) ListPaged(page uint, limit uint) ([]*biz.BackupStorage, int64, error) { + if mock.ListPagedFunc == nil { + panic("BackupAccountRepo.ListPagedFunc: method is nil but BackupAccountRepo.ListPaged was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockListPaged.Lock() + mock.calls.ListPaged = append(mock.calls.ListPaged, callInfo) + mock.lockListPaged.Unlock() + return mock.ListPagedFunc(page, limit) +} + +// ListPagedCalls gets all the calls that were made to ListPaged. +// Check the length with: +// +// len(mockedBackupAccountRepo.ListPagedCalls()) +func (mock *BackupAccountRepo) ListPagedCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockListPaged.RLock() + calls = mock.calls.ListPaged + mock.lockListPaged.RUnlock() + return calls +} + +// Update calls UpdateFunc. +func (mock *BackupAccountRepo) Update(account *biz.BackupStorage) error { + if mock.UpdateFunc == nil { + panic("BackupAccountRepo.UpdateFunc: method is nil but BackupAccountRepo.Update was just called") + } + callInfo := struct { + Account *biz.BackupStorage + }{ + Account: account, + } + mock.lockUpdate.Lock() + mock.calls.Update = append(mock.calls.Update, callInfo) + mock.lockUpdate.Unlock() + return mock.UpdateFunc(account) +} + +// UpdateCalls gets all the calls that were made to Update. +// Check the length with: +// +// len(mockedBackupAccountRepo.UpdateCalls()) +func (mock *BackupAccountRepo) UpdateCalls() []struct { + Account *biz.BackupStorage +} { + var calls []struct { + Account *biz.BackupStorage + } + mock.lockUpdate.RLock() + calls = mock.calls.Update + mock.lockUpdate.RUnlock() + return calls +} diff --git a/internal/mocks/biz/BackupRepo.go b/internal/mocks/biz/BackupRepo.go new file mode 100644 index 000000000..042d332ec --- /dev/null +++ b/internal/mocks/biz/BackupRepo.go @@ -0,0 +1,707 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "context" + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that BackupRepo does implement biz.BackupRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.BackupRepo = &BackupRepo{} + +// BackupRepo is a mock implementation of biz.BackupRepo. +// +// func TestSomethingThatUsesBackupRepo(t *testing.T) { +// +// // make and configure a mocked biz.BackupRepo +// mockedBackupRepo := &BackupRepo{ +// ClearExpiredFunc: func(path string, prefix string, save uint) error { +// panic("mock out the ClearExpired method") +// }, +// ClearStorageExpiredFunc: func(account uint, dir string, prefix string, save uint) error { +// panic("mock out the ClearStorageExpired method") +// }, +// CreateFunc: func(ctx context.Context, typ biz.BackupType, target string, account uint) error { +// panic("mock out the Create method") +// }, +// CreatePanelFunc: func() error { +// panic("mock out the CreatePanel method") +// }, +// CutoffLogFunc: func(path string, target string) (string, error) { +// panic("mock out the CutoffLog method") +// }, +// CutoffUploadFunc: func(account uint, typ biz.BackupType, name string, files []string) error { +// panic("mock out the CutoffUpload method") +// }, +// DeleteFunc: func(typ biz.BackupType, name string) error { +// panic("mock out the Delete method") +// }, +// FixPanelFunc: func() error { +// panic("mock out the FixPanel method") +// }, +// GetDefaultPathFunc: func(typ biz.BackupType) string { +// panic("mock out the GetDefaultPath method") +// }, +// GetStorageFunc: func(id uint) (*biz.BackupStorage, error) { +// panic("mock out the GetStorage method") +// }, +// ListFunc: func(typ biz.BackupType) ([]*types.BackupFile, error) { +// panic("mock out the List method") +// }, +// RestoreFunc: func(ctx context.Context, typ biz.BackupType, backup string, target string) error { +// panic("mock out the Restore method") +// }, +// UpdatePanelFunc: func(version string, url string, checksum string, progress func(string)) error { +// panic("mock out the UpdatePanel method") +// }, +// } +// +// // use mockedBackupRepo in code that requires biz.BackupRepo +// // and then make assertions. +// +// } +type BackupRepo struct { + // ClearExpiredFunc mocks the ClearExpired method. + ClearExpiredFunc func(path string, prefix string, save uint) error + + // ClearStorageExpiredFunc mocks the ClearStorageExpired method. + ClearStorageExpiredFunc func(account uint, dir string, prefix string, save uint) error + + // CreateFunc mocks the Create method. + CreateFunc func(ctx context.Context, typ biz.BackupType, target string, account uint) error + + // CreatePanelFunc mocks the CreatePanel method. + CreatePanelFunc func() error + + // CutoffLogFunc mocks the CutoffLog method. + CutoffLogFunc func(path string, target string) (string, error) + + // CutoffUploadFunc mocks the CutoffUpload method. + CutoffUploadFunc func(account uint, typ biz.BackupType, name string, files []string) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(typ biz.BackupType, name string) error + + // FixPanelFunc mocks the FixPanel method. + FixPanelFunc func() error + + // GetDefaultPathFunc mocks the GetDefaultPath method. + GetDefaultPathFunc func(typ biz.BackupType) string + + // GetStorageFunc mocks the GetStorage method. + GetStorageFunc func(id uint) (*biz.BackupStorage, error) + + // ListFunc mocks the List method. + ListFunc func(typ biz.BackupType) ([]*types.BackupFile, error) + + // RestoreFunc mocks the Restore method. + RestoreFunc func(ctx context.Context, typ biz.BackupType, backup string, target string) error + + // UpdatePanelFunc mocks the UpdatePanel method. + UpdatePanelFunc func(version string, url string, checksum string, progress func(string)) error + + // calls tracks calls to the methods. + calls struct { + // ClearExpired holds details about calls to the ClearExpired method. + ClearExpired []struct { + // Path is the path argument value. + Path string + // Prefix is the prefix argument value. + Prefix string + // Save is the save argument value. + Save uint + } + // ClearStorageExpired holds details about calls to the ClearStorageExpired method. + ClearStorageExpired []struct { + // Account is the account argument value. + Account uint + // Dir is the dir argument value. + Dir string + // Prefix is the prefix argument value. + Prefix string + // Save is the save argument value. + Save uint + } + // Create holds details about calls to the Create method. + Create []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Typ is the typ argument value. + Typ biz.BackupType + // Target is the target argument value. + Target string + // Account is the account argument value. + Account uint + } + // CreatePanel holds details about calls to the CreatePanel method. + CreatePanel []struct { + } + // CutoffLog holds details about calls to the CutoffLog method. + CutoffLog []struct { + // Path is the path argument value. + Path string + // Target is the target argument value. + Target string + } + // CutoffUpload holds details about calls to the CutoffUpload method. + CutoffUpload []struct { + // Account is the account argument value. + Account uint + // Typ is the typ argument value. + Typ biz.BackupType + // Name is the name argument value. + Name string + // Files is the files argument value. + Files []string + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // Typ is the typ argument value. + Typ biz.BackupType + // Name is the name argument value. + Name string + } + // FixPanel holds details about calls to the FixPanel method. + FixPanel []struct { + } + // GetDefaultPath holds details about calls to the GetDefaultPath method. + GetDefaultPath []struct { + // Typ is the typ argument value. + Typ biz.BackupType + } + // GetStorage holds details about calls to the GetStorage method. + GetStorage []struct { + // ID is the id argument value. + ID uint + } + // List holds details about calls to the List method. + List []struct { + // Typ is the typ argument value. + Typ biz.BackupType + } + // Restore holds details about calls to the Restore method. + Restore []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Typ is the typ argument value. + Typ biz.BackupType + // Backup is the backup argument value. + Backup string + // Target is the target argument value. + Target string + } + // UpdatePanel holds details about calls to the UpdatePanel method. + UpdatePanel []struct { + // Version is the version argument value. + Version string + // URL is the url argument value. + URL string + // Checksum is the checksum argument value. + Checksum string + // Progress is the progress argument value. + Progress func(string) + } + } + lockClearExpired sync.RWMutex + lockClearStorageExpired sync.RWMutex + lockCreate sync.RWMutex + lockCreatePanel sync.RWMutex + lockCutoffLog sync.RWMutex + lockCutoffUpload sync.RWMutex + lockDelete sync.RWMutex + lockFixPanel sync.RWMutex + lockGetDefaultPath sync.RWMutex + lockGetStorage sync.RWMutex + lockList sync.RWMutex + lockRestore sync.RWMutex + lockUpdatePanel sync.RWMutex +} + +// ClearExpired calls ClearExpiredFunc. +func (mock *BackupRepo) ClearExpired(path string, prefix string, save uint) error { + if mock.ClearExpiredFunc == nil { + panic("BackupRepo.ClearExpiredFunc: method is nil but BackupRepo.ClearExpired was just called") + } + callInfo := struct { + Path string + Prefix string + Save uint + }{ + Path: path, + Prefix: prefix, + Save: save, + } + mock.lockClearExpired.Lock() + mock.calls.ClearExpired = append(mock.calls.ClearExpired, callInfo) + mock.lockClearExpired.Unlock() + return mock.ClearExpiredFunc(path, prefix, save) +} + +// ClearExpiredCalls gets all the calls that were made to ClearExpired. +// Check the length with: +// +// len(mockedBackupRepo.ClearExpiredCalls()) +func (mock *BackupRepo) ClearExpiredCalls() []struct { + Path string + Prefix string + Save uint +} { + var calls []struct { + Path string + Prefix string + Save uint + } + mock.lockClearExpired.RLock() + calls = mock.calls.ClearExpired + mock.lockClearExpired.RUnlock() + return calls +} + +// ClearStorageExpired calls ClearStorageExpiredFunc. +func (mock *BackupRepo) ClearStorageExpired(account uint, dir string, prefix string, save uint) error { + if mock.ClearStorageExpiredFunc == nil { + panic("BackupRepo.ClearStorageExpiredFunc: method is nil but BackupRepo.ClearStorageExpired was just called") + } + callInfo := struct { + Account uint + Dir string + Prefix string + Save uint + }{ + Account: account, + Dir: dir, + Prefix: prefix, + Save: save, + } + mock.lockClearStorageExpired.Lock() + mock.calls.ClearStorageExpired = append(mock.calls.ClearStorageExpired, callInfo) + mock.lockClearStorageExpired.Unlock() + return mock.ClearStorageExpiredFunc(account, dir, prefix, save) +} + +// ClearStorageExpiredCalls gets all the calls that were made to ClearStorageExpired. +// Check the length with: +// +// len(mockedBackupRepo.ClearStorageExpiredCalls()) +func (mock *BackupRepo) ClearStorageExpiredCalls() []struct { + Account uint + Dir string + Prefix string + Save uint +} { + var calls []struct { + Account uint + Dir string + Prefix string + Save uint + } + mock.lockClearStorageExpired.RLock() + calls = mock.calls.ClearStorageExpired + mock.lockClearStorageExpired.RUnlock() + return calls +} + +// Create calls CreateFunc. +func (mock *BackupRepo) Create(ctx context.Context, typ biz.BackupType, target string, account uint) error { + if mock.CreateFunc == nil { + panic("BackupRepo.CreateFunc: method is nil but BackupRepo.Create was just called") + } + callInfo := struct { + Ctx context.Context + Typ biz.BackupType + Target string + Account uint + }{ + Ctx: ctx, + Typ: typ, + Target: target, + Account: account, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(ctx, typ, target, account) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedBackupRepo.CreateCalls()) +func (mock *BackupRepo) CreateCalls() []struct { + Ctx context.Context + Typ biz.BackupType + Target string + Account uint +} { + var calls []struct { + Ctx context.Context + Typ biz.BackupType + Target string + Account uint + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// CreatePanel calls CreatePanelFunc. +func (mock *BackupRepo) CreatePanel() error { + if mock.CreatePanelFunc == nil { + panic("BackupRepo.CreatePanelFunc: method is nil but BackupRepo.CreatePanel was just called") + } + callInfo := struct { + }{} + mock.lockCreatePanel.Lock() + mock.calls.CreatePanel = append(mock.calls.CreatePanel, callInfo) + mock.lockCreatePanel.Unlock() + return mock.CreatePanelFunc() +} + +// CreatePanelCalls gets all the calls that were made to CreatePanel. +// Check the length with: +// +// len(mockedBackupRepo.CreatePanelCalls()) +func (mock *BackupRepo) CreatePanelCalls() []struct { +} { + var calls []struct { + } + mock.lockCreatePanel.RLock() + calls = mock.calls.CreatePanel + mock.lockCreatePanel.RUnlock() + return calls +} + +// CutoffLog calls CutoffLogFunc. +func (mock *BackupRepo) CutoffLog(path string, target string) (string, error) { + if mock.CutoffLogFunc == nil { + panic("BackupRepo.CutoffLogFunc: method is nil but BackupRepo.CutoffLog was just called") + } + callInfo := struct { + Path string + Target string + }{ + Path: path, + Target: target, + } + mock.lockCutoffLog.Lock() + mock.calls.CutoffLog = append(mock.calls.CutoffLog, callInfo) + mock.lockCutoffLog.Unlock() + return mock.CutoffLogFunc(path, target) +} + +// CutoffLogCalls gets all the calls that were made to CutoffLog. +// Check the length with: +// +// len(mockedBackupRepo.CutoffLogCalls()) +func (mock *BackupRepo) CutoffLogCalls() []struct { + Path string + Target string +} { + var calls []struct { + Path string + Target string + } + mock.lockCutoffLog.RLock() + calls = mock.calls.CutoffLog + mock.lockCutoffLog.RUnlock() + return calls +} + +// CutoffUpload calls CutoffUploadFunc. +func (mock *BackupRepo) CutoffUpload(account uint, typ biz.BackupType, name string, files []string) error { + if mock.CutoffUploadFunc == nil { + panic("BackupRepo.CutoffUploadFunc: method is nil but BackupRepo.CutoffUpload was just called") + } + callInfo := struct { + Account uint + Typ biz.BackupType + Name string + Files []string + }{ + Account: account, + Typ: typ, + Name: name, + Files: files, + } + mock.lockCutoffUpload.Lock() + mock.calls.CutoffUpload = append(mock.calls.CutoffUpload, callInfo) + mock.lockCutoffUpload.Unlock() + return mock.CutoffUploadFunc(account, typ, name, files) +} + +// CutoffUploadCalls gets all the calls that were made to CutoffUpload. +// Check the length with: +// +// len(mockedBackupRepo.CutoffUploadCalls()) +func (mock *BackupRepo) CutoffUploadCalls() []struct { + Account uint + Typ biz.BackupType + Name string + Files []string +} { + var calls []struct { + Account uint + Typ biz.BackupType + Name string + Files []string + } + mock.lockCutoffUpload.RLock() + calls = mock.calls.CutoffUpload + mock.lockCutoffUpload.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *BackupRepo) Delete(typ biz.BackupType, name string) error { + if mock.DeleteFunc == nil { + panic("BackupRepo.DeleteFunc: method is nil but BackupRepo.Delete was just called") + } + callInfo := struct { + Typ biz.BackupType + Name string + }{ + Typ: typ, + Name: name, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(typ, name) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedBackupRepo.DeleteCalls()) +func (mock *BackupRepo) DeleteCalls() []struct { + Typ biz.BackupType + Name string +} { + var calls []struct { + Typ biz.BackupType + Name string + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// FixPanel calls FixPanelFunc. +func (mock *BackupRepo) FixPanel() error { + if mock.FixPanelFunc == nil { + panic("BackupRepo.FixPanelFunc: method is nil but BackupRepo.FixPanel was just called") + } + callInfo := struct { + }{} + mock.lockFixPanel.Lock() + mock.calls.FixPanel = append(mock.calls.FixPanel, callInfo) + mock.lockFixPanel.Unlock() + return mock.FixPanelFunc() +} + +// FixPanelCalls gets all the calls that were made to FixPanel. +// Check the length with: +// +// len(mockedBackupRepo.FixPanelCalls()) +func (mock *BackupRepo) FixPanelCalls() []struct { +} { + var calls []struct { + } + mock.lockFixPanel.RLock() + calls = mock.calls.FixPanel + mock.lockFixPanel.RUnlock() + return calls +} + +// GetDefaultPath calls GetDefaultPathFunc. +func (mock *BackupRepo) GetDefaultPath(typ biz.BackupType) string { + if mock.GetDefaultPathFunc == nil { + panic("BackupRepo.GetDefaultPathFunc: method is nil but BackupRepo.GetDefaultPath was just called") + } + callInfo := struct { + Typ biz.BackupType + }{ + Typ: typ, + } + mock.lockGetDefaultPath.Lock() + mock.calls.GetDefaultPath = append(mock.calls.GetDefaultPath, callInfo) + mock.lockGetDefaultPath.Unlock() + return mock.GetDefaultPathFunc(typ) +} + +// GetDefaultPathCalls gets all the calls that were made to GetDefaultPath. +// Check the length with: +// +// len(mockedBackupRepo.GetDefaultPathCalls()) +func (mock *BackupRepo) GetDefaultPathCalls() []struct { + Typ biz.BackupType +} { + var calls []struct { + Typ biz.BackupType + } + mock.lockGetDefaultPath.RLock() + calls = mock.calls.GetDefaultPath + mock.lockGetDefaultPath.RUnlock() + return calls +} + +// GetStorage calls GetStorageFunc. +func (mock *BackupRepo) GetStorage(id uint) (*biz.BackupStorage, error) { + if mock.GetStorageFunc == nil { + panic("BackupRepo.GetStorageFunc: method is nil but BackupRepo.GetStorage was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGetStorage.Lock() + mock.calls.GetStorage = append(mock.calls.GetStorage, callInfo) + mock.lockGetStorage.Unlock() + return mock.GetStorageFunc(id) +} + +// GetStorageCalls gets all the calls that were made to GetStorage. +// Check the length with: +// +// len(mockedBackupRepo.GetStorageCalls()) +func (mock *BackupRepo) GetStorageCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGetStorage.RLock() + calls = mock.calls.GetStorage + mock.lockGetStorage.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *BackupRepo) List(typ biz.BackupType) ([]*types.BackupFile, error) { + if mock.ListFunc == nil { + panic("BackupRepo.ListFunc: method is nil but BackupRepo.List was just called") + } + callInfo := struct { + Typ biz.BackupType + }{ + Typ: typ, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(typ) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedBackupRepo.ListCalls()) +func (mock *BackupRepo) ListCalls() []struct { + Typ biz.BackupType +} { + var calls []struct { + Typ biz.BackupType + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// Restore calls RestoreFunc. +func (mock *BackupRepo) Restore(ctx context.Context, typ biz.BackupType, backup string, target string) error { + if mock.RestoreFunc == nil { + panic("BackupRepo.RestoreFunc: method is nil but BackupRepo.Restore was just called") + } + callInfo := struct { + Ctx context.Context + Typ biz.BackupType + Backup string + Target string + }{ + Ctx: ctx, + Typ: typ, + Backup: backup, + Target: target, + } + mock.lockRestore.Lock() + mock.calls.Restore = append(mock.calls.Restore, callInfo) + mock.lockRestore.Unlock() + return mock.RestoreFunc(ctx, typ, backup, target) +} + +// RestoreCalls gets all the calls that were made to Restore. +// Check the length with: +// +// len(mockedBackupRepo.RestoreCalls()) +func (mock *BackupRepo) RestoreCalls() []struct { + Ctx context.Context + Typ biz.BackupType + Backup string + Target string +} { + var calls []struct { + Ctx context.Context + Typ biz.BackupType + Backup string + Target string + } + mock.lockRestore.RLock() + calls = mock.calls.Restore + mock.lockRestore.RUnlock() + return calls +} + +// UpdatePanel calls UpdatePanelFunc. +func (mock *BackupRepo) UpdatePanel(version string, url string, checksum string, progress func(string)) error { + if mock.UpdatePanelFunc == nil { + panic("BackupRepo.UpdatePanelFunc: method is nil but BackupRepo.UpdatePanel was just called") + } + callInfo := struct { + Version string + URL string + Checksum string + Progress func(string) + }{ + Version: version, + URL: url, + Checksum: checksum, + Progress: progress, + } + mock.lockUpdatePanel.Lock() + mock.calls.UpdatePanel = append(mock.calls.UpdatePanel, callInfo) + mock.lockUpdatePanel.Unlock() + return mock.UpdatePanelFunc(version, url, checksum, progress) +} + +// UpdatePanelCalls gets all the calls that were made to UpdatePanel. +// Check the length with: +// +// len(mockedBackupRepo.UpdatePanelCalls()) +func (mock *BackupRepo) UpdatePanelCalls() []struct { + Version string + URL string + Checksum string + Progress func(string) +} { + var calls []struct { + Version string + URL string + Checksum string + Progress func(string) + } + mock.lockUpdatePanel.RLock() + calls = mock.calls.UpdatePanel + mock.lockUpdatePanel.RUnlock() + return calls +} diff --git a/internal/mocks/biz/CacheRepo.go b/internal/mocks/biz/CacheRepo.go new file mode 100644 index 000000000..29a8f3ee5 --- /dev/null +++ b/internal/mocks/biz/CacheRepo.go @@ -0,0 +1,282 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/pkg/api" +) + +// Ensure that CacheRepo does implement biz.CacheRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.CacheRepo = &CacheRepo{} + +// CacheRepo is a mock implementation of biz.CacheRepo. +// +// func TestSomethingThatUsesCacheRepo(t *testing.T) { +// +// // make and configure a mocked biz.CacheRepo +// mockedCacheRepo := &CacheRepo{ +// FetchAppsFunc: func() (*api.Apps, error) { +// panic("mock out the FetchApps method") +// }, +// FetchCategoriesFunc: func() (*api.Categories, error) { +// panic("mock out the FetchCategories method") +// }, +// FetchEnvironmentsFunc: func() (*api.Environments, error) { +// panic("mock out the FetchEnvironments method") +// }, +// FetchTemplatesFunc: func() (*api.Templates, error) { +// panic("mock out the FetchTemplates method") +// }, +// GetFunc: func(key biz.CacheKey, defaultValue ...string) (string, error) { +// panic("mock out the Get method") +// }, +// SetFunc: func(key biz.CacheKey, value string) error { +// panic("mock out the Set method") +// }, +// } +// +// // use mockedCacheRepo in code that requires biz.CacheRepo +// // and then make assertions. +// +// } +type CacheRepo struct { + // FetchAppsFunc mocks the FetchApps method. + FetchAppsFunc func() (*api.Apps, error) + + // FetchCategoriesFunc mocks the FetchCategories method. + FetchCategoriesFunc func() (*api.Categories, error) + + // FetchEnvironmentsFunc mocks the FetchEnvironments method. + FetchEnvironmentsFunc func() (*api.Environments, error) + + // FetchTemplatesFunc mocks the FetchTemplates method. + FetchTemplatesFunc func() (*api.Templates, error) + + // GetFunc mocks the Get method. + GetFunc func(key biz.CacheKey, defaultValue ...string) (string, error) + + // SetFunc mocks the Set method. + SetFunc func(key biz.CacheKey, value string) error + + // calls tracks calls to the methods. + calls struct { + // FetchApps holds details about calls to the FetchApps method. + FetchApps []struct { + } + // FetchCategories holds details about calls to the FetchCategories method. + FetchCategories []struct { + } + // FetchEnvironments holds details about calls to the FetchEnvironments method. + FetchEnvironments []struct { + } + // FetchTemplates holds details about calls to the FetchTemplates method. + FetchTemplates []struct { + } + // Get holds details about calls to the Get method. + Get []struct { + // Key is the key argument value. + Key biz.CacheKey + // DefaultValue is the defaultValue argument value. + DefaultValue []string + } + // Set holds details about calls to the Set method. + Set []struct { + // Key is the key argument value. + Key biz.CacheKey + // Value is the value argument value. + Value string + } + } + lockFetchApps sync.RWMutex + lockFetchCategories sync.RWMutex + lockFetchEnvironments sync.RWMutex + lockFetchTemplates sync.RWMutex + lockGet sync.RWMutex + lockSet sync.RWMutex +} + +// FetchApps calls FetchAppsFunc. +func (mock *CacheRepo) FetchApps() (*api.Apps, error) { + if mock.FetchAppsFunc == nil { + panic("CacheRepo.FetchAppsFunc: method is nil but CacheRepo.FetchApps was just called") + } + callInfo := struct { + }{} + mock.lockFetchApps.Lock() + mock.calls.FetchApps = append(mock.calls.FetchApps, callInfo) + mock.lockFetchApps.Unlock() + return mock.FetchAppsFunc() +} + +// FetchAppsCalls gets all the calls that were made to FetchApps. +// Check the length with: +// +// len(mockedCacheRepo.FetchAppsCalls()) +func (mock *CacheRepo) FetchAppsCalls() []struct { +} { + var calls []struct { + } + mock.lockFetchApps.RLock() + calls = mock.calls.FetchApps + mock.lockFetchApps.RUnlock() + return calls +} + +// FetchCategories calls FetchCategoriesFunc. +func (mock *CacheRepo) FetchCategories() (*api.Categories, error) { + if mock.FetchCategoriesFunc == nil { + panic("CacheRepo.FetchCategoriesFunc: method is nil but CacheRepo.FetchCategories was just called") + } + callInfo := struct { + }{} + mock.lockFetchCategories.Lock() + mock.calls.FetchCategories = append(mock.calls.FetchCategories, callInfo) + mock.lockFetchCategories.Unlock() + return mock.FetchCategoriesFunc() +} + +// FetchCategoriesCalls gets all the calls that were made to FetchCategories. +// Check the length with: +// +// len(mockedCacheRepo.FetchCategoriesCalls()) +func (mock *CacheRepo) FetchCategoriesCalls() []struct { +} { + var calls []struct { + } + mock.lockFetchCategories.RLock() + calls = mock.calls.FetchCategories + mock.lockFetchCategories.RUnlock() + return calls +} + +// FetchEnvironments calls FetchEnvironmentsFunc. +func (mock *CacheRepo) FetchEnvironments() (*api.Environments, error) { + if mock.FetchEnvironmentsFunc == nil { + panic("CacheRepo.FetchEnvironmentsFunc: method is nil but CacheRepo.FetchEnvironments was just called") + } + callInfo := struct { + }{} + mock.lockFetchEnvironments.Lock() + mock.calls.FetchEnvironments = append(mock.calls.FetchEnvironments, callInfo) + mock.lockFetchEnvironments.Unlock() + return mock.FetchEnvironmentsFunc() +} + +// FetchEnvironmentsCalls gets all the calls that were made to FetchEnvironments. +// Check the length with: +// +// len(mockedCacheRepo.FetchEnvironmentsCalls()) +func (mock *CacheRepo) FetchEnvironmentsCalls() []struct { +} { + var calls []struct { + } + mock.lockFetchEnvironments.RLock() + calls = mock.calls.FetchEnvironments + mock.lockFetchEnvironments.RUnlock() + return calls +} + +// FetchTemplates calls FetchTemplatesFunc. +func (mock *CacheRepo) FetchTemplates() (*api.Templates, error) { + if mock.FetchTemplatesFunc == nil { + panic("CacheRepo.FetchTemplatesFunc: method is nil but CacheRepo.FetchTemplates was just called") + } + callInfo := struct { + }{} + mock.lockFetchTemplates.Lock() + mock.calls.FetchTemplates = append(mock.calls.FetchTemplates, callInfo) + mock.lockFetchTemplates.Unlock() + return mock.FetchTemplatesFunc() +} + +// FetchTemplatesCalls gets all the calls that were made to FetchTemplates. +// Check the length with: +// +// len(mockedCacheRepo.FetchTemplatesCalls()) +func (mock *CacheRepo) FetchTemplatesCalls() []struct { +} { + var calls []struct { + } + mock.lockFetchTemplates.RLock() + calls = mock.calls.FetchTemplates + mock.lockFetchTemplates.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *CacheRepo) Get(key biz.CacheKey, defaultValue ...string) (string, error) { + if mock.GetFunc == nil { + panic("CacheRepo.GetFunc: method is nil but CacheRepo.Get was just called") + } + callInfo := struct { + Key biz.CacheKey + DefaultValue []string + }{ + Key: key, + DefaultValue: defaultValue, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(key, defaultValue...) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedCacheRepo.GetCalls()) +func (mock *CacheRepo) GetCalls() []struct { + Key biz.CacheKey + DefaultValue []string +} { + var calls []struct { + Key biz.CacheKey + DefaultValue []string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// Set calls SetFunc. +func (mock *CacheRepo) Set(key biz.CacheKey, value string) error { + if mock.SetFunc == nil { + panic("CacheRepo.SetFunc: method is nil but CacheRepo.Set was just called") + } + callInfo := struct { + Key biz.CacheKey + Value string + }{ + Key: key, + Value: value, + } + mock.lockSet.Lock() + mock.calls.Set = append(mock.calls.Set, callInfo) + mock.lockSet.Unlock() + return mock.SetFunc(key, value) +} + +// SetCalls gets all the calls that were made to Set. +// Check the length with: +// +// len(mockedCacheRepo.SetCalls()) +func (mock *CacheRepo) SetCalls() []struct { + Key biz.CacheKey + Value string +} { + var calls []struct { + Key biz.CacheKey + Value string + } + mock.lockSet.RLock() + calls = mock.calls.Set + mock.lockSet.RUnlock() + return calls +} diff --git a/internal/mocks/biz/CertAccountRepo.go b/internal/mocks/biz/CertAccountRepo.go new file mode 100644 index 000000000..f25cb5e85 --- /dev/null +++ b/internal/mocks/biz/CertAccountRepo.go @@ -0,0 +1,453 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/pkg/acme" +) + +// Ensure that CertAccountRepo does implement biz.CertAccountRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.CertAccountRepo = &CertAccountRepo{} + +// CertAccountRepo is a mock implementation of biz.CertAccountRepo. +// +// func TestSomethingThatUsesCertAccountRepo(t *testing.T) { +// +// // make and configure a mocked biz.CertAccountRepo +// mockedCertAccountRepo := &CertAccountRepo{ +// CreateFunc: func(account *biz.CertAccount) error { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(id uint) error { +// panic("mock out the Delete method") +// }, +// GetFunc: func(id uint) (*biz.CertAccount, error) { +// panic("mock out the Get method") +// }, +// GetByCAEmailFunc: func(ca string, email string) (*biz.CertAccount, error) { +// panic("mock out the GetByCAEmail method") +// }, +// GetGoogleEABFunc: func() (*acme.EAB, error) { +// panic("mock out the GetGoogleEAB method") +// }, +// GetZeroSSLEABFunc: func(email string) (*acme.EAB, error) { +// panic("mock out the GetZeroSSLEAB method") +// }, +// ListFunc: func(page uint, limit uint) ([]*biz.CertAccount, int64, error) { +// panic("mock out the List method") +// }, +// RegisterAccountFunc: func(email string, ca string, eab *acme.EAB, keyType acme.KeyType) (*acme.Client, error) { +// panic("mock out the RegisterAccount method") +// }, +// SaveFunc: func(account *biz.CertAccount) error { +// panic("mock out the Save method") +// }, +// } +// +// // use mockedCertAccountRepo in code that requires biz.CertAccountRepo +// // and then make assertions. +// +// } +type CertAccountRepo struct { + // CreateFunc mocks the Create method. + CreateFunc func(account *biz.CertAccount) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) error + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*biz.CertAccount, error) + + // GetByCAEmailFunc mocks the GetByCAEmail method. + GetByCAEmailFunc func(ca string, email string) (*biz.CertAccount, error) + + // GetGoogleEABFunc mocks the GetGoogleEAB method. + GetGoogleEABFunc func() (*acme.EAB, error) + + // GetZeroSSLEABFunc mocks the GetZeroSSLEAB method. + GetZeroSSLEABFunc func(email string) (*acme.EAB, error) + + // ListFunc mocks the List method. + ListFunc func(page uint, limit uint) ([]*biz.CertAccount, int64, error) + + // RegisterAccountFunc mocks the RegisterAccount method. + RegisterAccountFunc func(email string, ca string, eab *acme.EAB, keyType acme.KeyType) (*acme.Client, error) + + // SaveFunc mocks the Save method. + SaveFunc func(account *biz.CertAccount) error + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // Account is the account argument value. + Account *biz.CertAccount + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // GetByCAEmail holds details about calls to the GetByCAEmail method. + GetByCAEmail []struct { + // Ca is the ca argument value. + Ca string + // Email is the email argument value. + Email string + } + // GetGoogleEAB holds details about calls to the GetGoogleEAB method. + GetGoogleEAB []struct { + } + // GetZeroSSLEAB holds details about calls to the GetZeroSSLEAB method. + GetZeroSSLEAB []struct { + // Email is the email argument value. + Email string + } + // List holds details about calls to the List method. + List []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // RegisterAccount holds details about calls to the RegisterAccount method. + RegisterAccount []struct { + // Email is the email argument value. + Email string + // Ca is the ca argument value. + Ca string + // Eab is the eab argument value. + Eab *acme.EAB + // KeyType is the keyType argument value. + KeyType acme.KeyType + } + // Save holds details about calls to the Save method. + Save []struct { + // Account is the account argument value. + Account *biz.CertAccount + } + } + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockGet sync.RWMutex + lockGetByCAEmail sync.RWMutex + lockGetGoogleEAB sync.RWMutex + lockGetZeroSSLEAB sync.RWMutex + lockList sync.RWMutex + lockRegisterAccount sync.RWMutex + lockSave sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *CertAccountRepo) Create(account *biz.CertAccount) error { + if mock.CreateFunc == nil { + panic("CertAccountRepo.CreateFunc: method is nil but CertAccountRepo.Create was just called") + } + callInfo := struct { + Account *biz.CertAccount + }{ + Account: account, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(account) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedCertAccountRepo.CreateCalls()) +func (mock *CertAccountRepo) CreateCalls() []struct { + Account *biz.CertAccount +} { + var calls []struct { + Account *biz.CertAccount + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *CertAccountRepo) Delete(id uint) error { + if mock.DeleteFunc == nil { + panic("CertAccountRepo.DeleteFunc: method is nil but CertAccountRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedCertAccountRepo.DeleteCalls()) +func (mock *CertAccountRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *CertAccountRepo) Get(id uint) (*biz.CertAccount, error) { + if mock.GetFunc == nil { + panic("CertAccountRepo.GetFunc: method is nil but CertAccountRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedCertAccountRepo.GetCalls()) +func (mock *CertAccountRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// GetByCAEmail calls GetByCAEmailFunc. +func (mock *CertAccountRepo) GetByCAEmail(ca string, email string) (*biz.CertAccount, error) { + if mock.GetByCAEmailFunc == nil { + panic("CertAccountRepo.GetByCAEmailFunc: method is nil but CertAccountRepo.GetByCAEmail was just called") + } + callInfo := struct { + Ca string + Email string + }{ + Ca: ca, + Email: email, + } + mock.lockGetByCAEmail.Lock() + mock.calls.GetByCAEmail = append(mock.calls.GetByCAEmail, callInfo) + mock.lockGetByCAEmail.Unlock() + return mock.GetByCAEmailFunc(ca, email) +} + +// GetByCAEmailCalls gets all the calls that were made to GetByCAEmail. +// Check the length with: +// +// len(mockedCertAccountRepo.GetByCAEmailCalls()) +func (mock *CertAccountRepo) GetByCAEmailCalls() []struct { + Ca string + Email string +} { + var calls []struct { + Ca string + Email string + } + mock.lockGetByCAEmail.RLock() + calls = mock.calls.GetByCAEmail + mock.lockGetByCAEmail.RUnlock() + return calls +} + +// GetGoogleEAB calls GetGoogleEABFunc. +func (mock *CertAccountRepo) GetGoogleEAB() (*acme.EAB, error) { + if mock.GetGoogleEABFunc == nil { + panic("CertAccountRepo.GetGoogleEABFunc: method is nil but CertAccountRepo.GetGoogleEAB was just called") + } + callInfo := struct { + }{} + mock.lockGetGoogleEAB.Lock() + mock.calls.GetGoogleEAB = append(mock.calls.GetGoogleEAB, callInfo) + mock.lockGetGoogleEAB.Unlock() + return mock.GetGoogleEABFunc() +} + +// GetGoogleEABCalls gets all the calls that were made to GetGoogleEAB. +// Check the length with: +// +// len(mockedCertAccountRepo.GetGoogleEABCalls()) +func (mock *CertAccountRepo) GetGoogleEABCalls() []struct { +} { + var calls []struct { + } + mock.lockGetGoogleEAB.RLock() + calls = mock.calls.GetGoogleEAB + mock.lockGetGoogleEAB.RUnlock() + return calls +} + +// GetZeroSSLEAB calls GetZeroSSLEABFunc. +func (mock *CertAccountRepo) GetZeroSSLEAB(email string) (*acme.EAB, error) { + if mock.GetZeroSSLEABFunc == nil { + panic("CertAccountRepo.GetZeroSSLEABFunc: method is nil but CertAccountRepo.GetZeroSSLEAB was just called") + } + callInfo := struct { + Email string + }{ + Email: email, + } + mock.lockGetZeroSSLEAB.Lock() + mock.calls.GetZeroSSLEAB = append(mock.calls.GetZeroSSLEAB, callInfo) + mock.lockGetZeroSSLEAB.Unlock() + return mock.GetZeroSSLEABFunc(email) +} + +// GetZeroSSLEABCalls gets all the calls that were made to GetZeroSSLEAB. +// Check the length with: +// +// len(mockedCertAccountRepo.GetZeroSSLEABCalls()) +func (mock *CertAccountRepo) GetZeroSSLEABCalls() []struct { + Email string +} { + var calls []struct { + Email string + } + mock.lockGetZeroSSLEAB.RLock() + calls = mock.calls.GetZeroSSLEAB + mock.lockGetZeroSSLEAB.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *CertAccountRepo) List(page uint, limit uint) ([]*biz.CertAccount, int64, error) { + if mock.ListFunc == nil { + panic("CertAccountRepo.ListFunc: method is nil but CertAccountRepo.List was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedCertAccountRepo.ListCalls()) +func (mock *CertAccountRepo) ListCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// RegisterAccount calls RegisterAccountFunc. +func (mock *CertAccountRepo) RegisterAccount(email string, ca string, eab *acme.EAB, keyType acme.KeyType) (*acme.Client, error) { + if mock.RegisterAccountFunc == nil { + panic("CertAccountRepo.RegisterAccountFunc: method is nil but CertAccountRepo.RegisterAccount was just called") + } + callInfo := struct { + Email string + Ca string + Eab *acme.EAB + KeyType acme.KeyType + }{ + Email: email, + Ca: ca, + Eab: eab, + KeyType: keyType, + } + mock.lockRegisterAccount.Lock() + mock.calls.RegisterAccount = append(mock.calls.RegisterAccount, callInfo) + mock.lockRegisterAccount.Unlock() + return mock.RegisterAccountFunc(email, ca, eab, keyType) +} + +// RegisterAccountCalls gets all the calls that were made to RegisterAccount. +// Check the length with: +// +// len(mockedCertAccountRepo.RegisterAccountCalls()) +func (mock *CertAccountRepo) RegisterAccountCalls() []struct { + Email string + Ca string + Eab *acme.EAB + KeyType acme.KeyType +} { + var calls []struct { + Email string + Ca string + Eab *acme.EAB + KeyType acme.KeyType + } + mock.lockRegisterAccount.RLock() + calls = mock.calls.RegisterAccount + mock.lockRegisterAccount.RUnlock() + return calls +} + +// Save calls SaveFunc. +func (mock *CertAccountRepo) Save(account *biz.CertAccount) error { + if mock.SaveFunc == nil { + panic("CertAccountRepo.SaveFunc: method is nil but CertAccountRepo.Save was just called") + } + callInfo := struct { + Account *biz.CertAccount + }{ + Account: account, + } + mock.lockSave.Lock() + mock.calls.Save = append(mock.calls.Save, callInfo) + mock.lockSave.Unlock() + return mock.SaveFunc(account) +} + +// SaveCalls gets all the calls that were made to Save. +// Check the length with: +// +// len(mockedCertAccountRepo.SaveCalls()) +func (mock *CertAccountRepo) SaveCalls() []struct { + Account *biz.CertAccount +} { + var calls []struct { + Account *biz.CertAccount + } + mock.lockSave.RLock() + calls = mock.calls.Save + mock.lockSave.RUnlock() + return calls +} diff --git a/internal/mocks/biz/CertDNSRepo.go b/internal/mocks/biz/CertDNSRepo.go new file mode 100644 index 000000000..5ef1a51b6 --- /dev/null +++ b/internal/mocks/biz/CertDNSRepo.go @@ -0,0 +1,260 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" +) + +// Ensure that CertDNSRepo does implement biz.CertDNSRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.CertDNSRepo = &CertDNSRepo{} + +// CertDNSRepo is a mock implementation of biz.CertDNSRepo. +// +// func TestSomethingThatUsesCertDNSRepo(t *testing.T) { +// +// // make and configure a mocked biz.CertDNSRepo +// mockedCertDNSRepo := &CertDNSRepo{ +// CreateFunc: func(req *request.CertDNSCreate) (*biz.CertDNS, error) { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(id uint) error { +// panic("mock out the Delete method") +// }, +// GetFunc: func(id uint) (*biz.CertDNS, error) { +// panic("mock out the Get method") +// }, +// ListFunc: func(page uint, limit uint) ([]*biz.CertDNS, int64, error) { +// panic("mock out the List method") +// }, +// UpdateFunc: func(req *request.CertDNSUpdate) error { +// panic("mock out the Update method") +// }, +// } +// +// // use mockedCertDNSRepo in code that requires biz.CertDNSRepo +// // and then make assertions. +// +// } +type CertDNSRepo struct { + // CreateFunc mocks the Create method. + CreateFunc func(req *request.CertDNSCreate) (*biz.CertDNS, error) + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) error + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*biz.CertDNS, error) + + // ListFunc mocks the List method. + ListFunc func(page uint, limit uint) ([]*biz.CertDNS, int64, error) + + // UpdateFunc mocks the Update method. + UpdateFunc func(req *request.CertDNSUpdate) error + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // Req is the req argument value. + Req *request.CertDNSCreate + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // List holds details about calls to the List method. + List []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // Update holds details about calls to the Update method. + Update []struct { + // Req is the req argument value. + Req *request.CertDNSUpdate + } + } + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockGet sync.RWMutex + lockList sync.RWMutex + lockUpdate sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *CertDNSRepo) Create(req *request.CertDNSCreate) (*biz.CertDNS, error) { + if mock.CreateFunc == nil { + panic("CertDNSRepo.CreateFunc: method is nil but CertDNSRepo.Create was just called") + } + callInfo := struct { + Req *request.CertDNSCreate + }{ + Req: req, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(req) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedCertDNSRepo.CreateCalls()) +func (mock *CertDNSRepo) CreateCalls() []struct { + Req *request.CertDNSCreate +} { + var calls []struct { + Req *request.CertDNSCreate + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *CertDNSRepo) Delete(id uint) error { + if mock.DeleteFunc == nil { + panic("CertDNSRepo.DeleteFunc: method is nil but CertDNSRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedCertDNSRepo.DeleteCalls()) +func (mock *CertDNSRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *CertDNSRepo) Get(id uint) (*biz.CertDNS, error) { + if mock.GetFunc == nil { + panic("CertDNSRepo.GetFunc: method is nil but CertDNSRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedCertDNSRepo.GetCalls()) +func (mock *CertDNSRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *CertDNSRepo) List(page uint, limit uint) ([]*biz.CertDNS, int64, error) { + if mock.ListFunc == nil { + panic("CertDNSRepo.ListFunc: method is nil but CertDNSRepo.List was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedCertDNSRepo.ListCalls()) +func (mock *CertDNSRepo) ListCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// Update calls UpdateFunc. +func (mock *CertDNSRepo) Update(req *request.CertDNSUpdate) error { + if mock.UpdateFunc == nil { + panic("CertDNSRepo.UpdateFunc: method is nil but CertDNSRepo.Update was just called") + } + callInfo := struct { + Req *request.CertDNSUpdate + }{ + Req: req, + } + mock.lockUpdate.Lock() + mock.calls.Update = append(mock.calls.Update, callInfo) + mock.lockUpdate.Unlock() + return mock.UpdateFunc(req) +} + +// UpdateCalls gets all the calls that were made to Update. +// Check the length with: +// +// len(mockedCertDNSRepo.UpdateCalls()) +func (mock *CertDNSRepo) UpdateCalls() []struct { + Req *request.CertDNSUpdate +} { + var calls []struct { + Req *request.CertDNSUpdate + } + mock.lockUpdate.RLock() + calls = mock.calls.Update + mock.lockUpdate.RUnlock() + return calls +} diff --git a/internal/mocks/biz/CertRepo.go b/internal/mocks/biz/CertRepo.go new file mode 100644 index 000000000..63ee3604d --- /dev/null +++ b/internal/mocks/biz/CertRepo.go @@ -0,0 +1,900 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/acme" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that CertRepo does implement biz.CertRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.CertRepo = &CertRepo{} + +// CertRepo is a mock implementation of biz.CertRepo. +// +// func TestSomethingThatUsesCertRepo(t *testing.T) { +// +// // make and configure a mocked biz.CertRepo +// mockedCertRepo := &CertRepo{ +// BindWebsitesFunc: func(certID uint, websiteIDs []uint) error { +// panic("mock out the BindWebsites method") +// }, +// CreateFunc: func(req *request.CertCreate) (*biz.Cert, error) { +// panic("mock out the Create method") +// }, +// CreateUploadedFunc: func(cert *biz.Cert) error { +// panic("mock out the CreateUploaded method") +// }, +// DeleteFunc: func(id uint) error { +// panic("mock out the Delete method") +// }, +// EnableWebsiteSSLFunc: func(website *biz.Website, certPath string, keyPath string, webServer string, tlsVersions []string, listenIPv6 bool) error { +// panic("mock out the EnableWebsiteSSL method") +// }, +// GenerateSelfSignedFunc: func(domains []string) ([]byte, []byte, error) { +// panic("mock out the GenerateSelfSigned method") +// }, +// GetFunc: func(id uint) (*biz.Cert, error) { +// panic("mock out the Get method") +// }, +// GetByWebsiteFunc: func(WebsiteID uint) (*biz.Cert, error) { +// panic("mock out the GetByWebsite method") +// }, +// GetClientFunc: func(cert *biz.Cert) (*acme.Client, error) { +// panic("mock out the GetClient method") +// }, +// HTTPConfsFunc: func(cert *biz.Cert, webServer string) (map[string]string, []string) { +// panic("mock out the HTTPConfs method") +// }, +// ListFunc: func(page uint, limit uint) ([]*types.CertList, int64, error) { +// panic("mock out the List method") +// }, +// LoadWebsitesFunc: func(websiteIDs []uint) ([]*biz.Website, error) { +// panic("mock out the LoadWebsites method") +// }, +// ObtainPanelFunc: func(account *biz.CertAccount, names []string, webServer string) ([]byte, []byte, error) { +// panic("mock out the ObtainPanel method") +// }, +// ReloadWebserverFunc: func(webServer string) error { +// panic("mock out the ReloadWebserver method") +// }, +// RunScriptFunc: func(cert *biz.Cert) error { +// panic("mock out the RunScript method") +// }, +// SaveFunc: func(cert *biz.Cert) error { +// panic("mock out the Save method") +// }, +// UpdateFunc: func(req *request.CertUpdate) error { +// panic("mock out the Update method") +// }, +// WriteCertFilesFunc: func(cert *biz.Cert, certPath string, keyPath string) error { +// panic("mock out the WriteCertFiles method") +// }, +// } +// +// // use mockedCertRepo in code that requires biz.CertRepo +// // and then make assertions. +// +// } +type CertRepo struct { + // BindWebsitesFunc mocks the BindWebsites method. + BindWebsitesFunc func(certID uint, websiteIDs []uint) error + + // CreateFunc mocks the Create method. + CreateFunc func(req *request.CertCreate) (*biz.Cert, error) + + // CreateUploadedFunc mocks the CreateUploaded method. + CreateUploadedFunc func(cert *biz.Cert) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) error + + // EnableWebsiteSSLFunc mocks the EnableWebsiteSSL method. + EnableWebsiteSSLFunc func(website *biz.Website, certPath string, keyPath string, webServer string, tlsVersions []string, listenIPv6 bool) error + + // GenerateSelfSignedFunc mocks the GenerateSelfSigned method. + GenerateSelfSignedFunc func(domains []string) ([]byte, []byte, error) + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*biz.Cert, error) + + // GetByWebsiteFunc mocks the GetByWebsite method. + GetByWebsiteFunc func(WebsiteID uint) (*biz.Cert, error) + + // GetClientFunc mocks the GetClient method. + GetClientFunc func(cert *biz.Cert) (*acme.Client, error) + + // HTTPConfsFunc mocks the HTTPConfs method. + HTTPConfsFunc func(cert *biz.Cert, webServer string) (map[string]string, []string) + + // ListFunc mocks the List method. + ListFunc func(page uint, limit uint) ([]*types.CertList, int64, error) + + // LoadWebsitesFunc mocks the LoadWebsites method. + LoadWebsitesFunc func(websiteIDs []uint) ([]*biz.Website, error) + + // ObtainPanelFunc mocks the ObtainPanel method. + ObtainPanelFunc func(account *biz.CertAccount, names []string, webServer string) ([]byte, []byte, error) + + // ReloadWebserverFunc mocks the ReloadWebserver method. + ReloadWebserverFunc func(webServer string) error + + // RunScriptFunc mocks the RunScript method. + RunScriptFunc func(cert *biz.Cert) error + + // SaveFunc mocks the Save method. + SaveFunc func(cert *biz.Cert) error + + // UpdateFunc mocks the Update method. + UpdateFunc func(req *request.CertUpdate) error + + // WriteCertFilesFunc mocks the WriteCertFiles method. + WriteCertFilesFunc func(cert *biz.Cert, certPath string, keyPath string) error + + // calls tracks calls to the methods. + calls struct { + // BindWebsites holds details about calls to the BindWebsites method. + BindWebsites []struct { + // CertID is the certID argument value. + CertID uint + // WebsiteIDs is the websiteIDs argument value. + WebsiteIDs []uint + } + // Create holds details about calls to the Create method. + Create []struct { + // Req is the req argument value. + Req *request.CertCreate + } + // CreateUploaded holds details about calls to the CreateUploaded method. + CreateUploaded []struct { + // Cert is the cert argument value. + Cert *biz.Cert + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // EnableWebsiteSSL holds details about calls to the EnableWebsiteSSL method. + EnableWebsiteSSL []struct { + // Website is the website argument value. + Website *biz.Website + // CertPath is the certPath argument value. + CertPath string + // KeyPath is the keyPath argument value. + KeyPath string + // WebServer is the webServer argument value. + WebServer string + // TlsVersions is the tlsVersions argument value. + TlsVersions []string + // ListenIPv6 is the listenIPv6 argument value. + ListenIPv6 bool + } + // GenerateSelfSigned holds details about calls to the GenerateSelfSigned method. + GenerateSelfSigned []struct { + // Domains is the domains argument value. + Domains []string + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // GetByWebsite holds details about calls to the GetByWebsite method. + GetByWebsite []struct { + // WebsiteID is the WebsiteID argument value. + WebsiteID uint + } + // GetClient holds details about calls to the GetClient method. + GetClient []struct { + // Cert is the cert argument value. + Cert *biz.Cert + } + // HTTPConfs holds details about calls to the HTTPConfs method. + HTTPConfs []struct { + // Cert is the cert argument value. + Cert *biz.Cert + // WebServer is the webServer argument value. + WebServer string + } + // List holds details about calls to the List method. + List []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // LoadWebsites holds details about calls to the LoadWebsites method. + LoadWebsites []struct { + // WebsiteIDs is the websiteIDs argument value. + WebsiteIDs []uint + } + // ObtainPanel holds details about calls to the ObtainPanel method. + ObtainPanel []struct { + // Account is the account argument value. + Account *biz.CertAccount + // Names is the names argument value. + Names []string + // WebServer is the webServer argument value. + WebServer string + } + // ReloadWebserver holds details about calls to the ReloadWebserver method. + ReloadWebserver []struct { + // WebServer is the webServer argument value. + WebServer string + } + // RunScript holds details about calls to the RunScript method. + RunScript []struct { + // Cert is the cert argument value. + Cert *biz.Cert + } + // Save holds details about calls to the Save method. + Save []struct { + // Cert is the cert argument value. + Cert *biz.Cert + } + // Update holds details about calls to the Update method. + Update []struct { + // Req is the req argument value. + Req *request.CertUpdate + } + // WriteCertFiles holds details about calls to the WriteCertFiles method. + WriteCertFiles []struct { + // Cert is the cert argument value. + Cert *biz.Cert + // CertPath is the certPath argument value. + CertPath string + // KeyPath is the keyPath argument value. + KeyPath string + } + } + lockBindWebsites sync.RWMutex + lockCreate sync.RWMutex + lockCreateUploaded sync.RWMutex + lockDelete sync.RWMutex + lockEnableWebsiteSSL sync.RWMutex + lockGenerateSelfSigned sync.RWMutex + lockGet sync.RWMutex + lockGetByWebsite sync.RWMutex + lockGetClient sync.RWMutex + lockHTTPConfs sync.RWMutex + lockList sync.RWMutex + lockLoadWebsites sync.RWMutex + lockObtainPanel sync.RWMutex + lockReloadWebserver sync.RWMutex + lockRunScript sync.RWMutex + lockSave sync.RWMutex + lockUpdate sync.RWMutex + lockWriteCertFiles sync.RWMutex +} + +// BindWebsites calls BindWebsitesFunc. +func (mock *CertRepo) BindWebsites(certID uint, websiteIDs []uint) error { + if mock.BindWebsitesFunc == nil { + panic("CertRepo.BindWebsitesFunc: method is nil but CertRepo.BindWebsites was just called") + } + callInfo := struct { + CertID uint + WebsiteIDs []uint + }{ + CertID: certID, + WebsiteIDs: websiteIDs, + } + mock.lockBindWebsites.Lock() + mock.calls.BindWebsites = append(mock.calls.BindWebsites, callInfo) + mock.lockBindWebsites.Unlock() + return mock.BindWebsitesFunc(certID, websiteIDs) +} + +// BindWebsitesCalls gets all the calls that were made to BindWebsites. +// Check the length with: +// +// len(mockedCertRepo.BindWebsitesCalls()) +func (mock *CertRepo) BindWebsitesCalls() []struct { + CertID uint + WebsiteIDs []uint +} { + var calls []struct { + CertID uint + WebsiteIDs []uint + } + mock.lockBindWebsites.RLock() + calls = mock.calls.BindWebsites + mock.lockBindWebsites.RUnlock() + return calls +} + +// Create calls CreateFunc. +func (mock *CertRepo) Create(req *request.CertCreate) (*biz.Cert, error) { + if mock.CreateFunc == nil { + panic("CertRepo.CreateFunc: method is nil but CertRepo.Create was just called") + } + callInfo := struct { + Req *request.CertCreate + }{ + Req: req, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(req) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedCertRepo.CreateCalls()) +func (mock *CertRepo) CreateCalls() []struct { + Req *request.CertCreate +} { + var calls []struct { + Req *request.CertCreate + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// CreateUploaded calls CreateUploadedFunc. +func (mock *CertRepo) CreateUploaded(cert *biz.Cert) error { + if mock.CreateUploadedFunc == nil { + panic("CertRepo.CreateUploadedFunc: method is nil but CertRepo.CreateUploaded was just called") + } + callInfo := struct { + Cert *biz.Cert + }{ + Cert: cert, + } + mock.lockCreateUploaded.Lock() + mock.calls.CreateUploaded = append(mock.calls.CreateUploaded, callInfo) + mock.lockCreateUploaded.Unlock() + return mock.CreateUploadedFunc(cert) +} + +// CreateUploadedCalls gets all the calls that were made to CreateUploaded. +// Check the length with: +// +// len(mockedCertRepo.CreateUploadedCalls()) +func (mock *CertRepo) CreateUploadedCalls() []struct { + Cert *biz.Cert +} { + var calls []struct { + Cert *biz.Cert + } + mock.lockCreateUploaded.RLock() + calls = mock.calls.CreateUploaded + mock.lockCreateUploaded.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *CertRepo) Delete(id uint) error { + if mock.DeleteFunc == nil { + panic("CertRepo.DeleteFunc: method is nil but CertRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedCertRepo.DeleteCalls()) +func (mock *CertRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// EnableWebsiteSSL calls EnableWebsiteSSLFunc. +func (mock *CertRepo) EnableWebsiteSSL(website *biz.Website, certPath string, keyPath string, webServer string, tlsVersions []string, listenIPv6 bool) error { + if mock.EnableWebsiteSSLFunc == nil { + panic("CertRepo.EnableWebsiteSSLFunc: method is nil but CertRepo.EnableWebsiteSSL was just called") + } + callInfo := struct { + Website *biz.Website + CertPath string + KeyPath string + WebServer string + TlsVersions []string + ListenIPv6 bool + }{ + Website: website, + CertPath: certPath, + KeyPath: keyPath, + WebServer: webServer, + TlsVersions: tlsVersions, + ListenIPv6: listenIPv6, + } + mock.lockEnableWebsiteSSL.Lock() + mock.calls.EnableWebsiteSSL = append(mock.calls.EnableWebsiteSSL, callInfo) + mock.lockEnableWebsiteSSL.Unlock() + return mock.EnableWebsiteSSLFunc(website, certPath, keyPath, webServer, tlsVersions, listenIPv6) +} + +// EnableWebsiteSSLCalls gets all the calls that were made to EnableWebsiteSSL. +// Check the length with: +// +// len(mockedCertRepo.EnableWebsiteSSLCalls()) +func (mock *CertRepo) EnableWebsiteSSLCalls() []struct { + Website *biz.Website + CertPath string + KeyPath string + WebServer string + TlsVersions []string + ListenIPv6 bool +} { + var calls []struct { + Website *biz.Website + CertPath string + KeyPath string + WebServer string + TlsVersions []string + ListenIPv6 bool + } + mock.lockEnableWebsiteSSL.RLock() + calls = mock.calls.EnableWebsiteSSL + mock.lockEnableWebsiteSSL.RUnlock() + return calls +} + +// GenerateSelfSigned calls GenerateSelfSignedFunc. +func (mock *CertRepo) GenerateSelfSigned(domains []string) ([]byte, []byte, error) { + if mock.GenerateSelfSignedFunc == nil { + panic("CertRepo.GenerateSelfSignedFunc: method is nil but CertRepo.GenerateSelfSigned was just called") + } + callInfo := struct { + Domains []string + }{ + Domains: domains, + } + mock.lockGenerateSelfSigned.Lock() + mock.calls.GenerateSelfSigned = append(mock.calls.GenerateSelfSigned, callInfo) + mock.lockGenerateSelfSigned.Unlock() + return mock.GenerateSelfSignedFunc(domains) +} + +// GenerateSelfSignedCalls gets all the calls that were made to GenerateSelfSigned. +// Check the length with: +// +// len(mockedCertRepo.GenerateSelfSignedCalls()) +func (mock *CertRepo) GenerateSelfSignedCalls() []struct { + Domains []string +} { + var calls []struct { + Domains []string + } + mock.lockGenerateSelfSigned.RLock() + calls = mock.calls.GenerateSelfSigned + mock.lockGenerateSelfSigned.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *CertRepo) Get(id uint) (*biz.Cert, error) { + if mock.GetFunc == nil { + panic("CertRepo.GetFunc: method is nil but CertRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedCertRepo.GetCalls()) +func (mock *CertRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// GetByWebsite calls GetByWebsiteFunc. +func (mock *CertRepo) GetByWebsite(WebsiteID uint) (*biz.Cert, error) { + if mock.GetByWebsiteFunc == nil { + panic("CertRepo.GetByWebsiteFunc: method is nil but CertRepo.GetByWebsite was just called") + } + callInfo := struct { + WebsiteID uint + }{ + WebsiteID: WebsiteID, + } + mock.lockGetByWebsite.Lock() + mock.calls.GetByWebsite = append(mock.calls.GetByWebsite, callInfo) + mock.lockGetByWebsite.Unlock() + return mock.GetByWebsiteFunc(WebsiteID) +} + +// GetByWebsiteCalls gets all the calls that were made to GetByWebsite. +// Check the length with: +// +// len(mockedCertRepo.GetByWebsiteCalls()) +func (mock *CertRepo) GetByWebsiteCalls() []struct { + WebsiteID uint +} { + var calls []struct { + WebsiteID uint + } + mock.lockGetByWebsite.RLock() + calls = mock.calls.GetByWebsite + mock.lockGetByWebsite.RUnlock() + return calls +} + +// GetClient calls GetClientFunc. +func (mock *CertRepo) GetClient(cert *biz.Cert) (*acme.Client, error) { + if mock.GetClientFunc == nil { + panic("CertRepo.GetClientFunc: method is nil but CertRepo.GetClient was just called") + } + callInfo := struct { + Cert *biz.Cert + }{ + Cert: cert, + } + mock.lockGetClient.Lock() + mock.calls.GetClient = append(mock.calls.GetClient, callInfo) + mock.lockGetClient.Unlock() + return mock.GetClientFunc(cert) +} + +// GetClientCalls gets all the calls that were made to GetClient. +// Check the length with: +// +// len(mockedCertRepo.GetClientCalls()) +func (mock *CertRepo) GetClientCalls() []struct { + Cert *biz.Cert +} { + var calls []struct { + Cert *biz.Cert + } + mock.lockGetClient.RLock() + calls = mock.calls.GetClient + mock.lockGetClient.RUnlock() + return calls +} + +// HTTPConfs calls HTTPConfsFunc. +func (mock *CertRepo) HTTPConfs(cert *biz.Cert, webServer string) (map[string]string, []string) { + if mock.HTTPConfsFunc == nil { + panic("CertRepo.HTTPConfsFunc: method is nil but CertRepo.HTTPConfs was just called") + } + callInfo := struct { + Cert *biz.Cert + WebServer string + }{ + Cert: cert, + WebServer: webServer, + } + mock.lockHTTPConfs.Lock() + mock.calls.HTTPConfs = append(mock.calls.HTTPConfs, callInfo) + mock.lockHTTPConfs.Unlock() + return mock.HTTPConfsFunc(cert, webServer) +} + +// HTTPConfsCalls gets all the calls that were made to HTTPConfs. +// Check the length with: +// +// len(mockedCertRepo.HTTPConfsCalls()) +func (mock *CertRepo) HTTPConfsCalls() []struct { + Cert *biz.Cert + WebServer string +} { + var calls []struct { + Cert *biz.Cert + WebServer string + } + mock.lockHTTPConfs.RLock() + calls = mock.calls.HTTPConfs + mock.lockHTTPConfs.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *CertRepo) List(page uint, limit uint) ([]*types.CertList, int64, error) { + if mock.ListFunc == nil { + panic("CertRepo.ListFunc: method is nil but CertRepo.List was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedCertRepo.ListCalls()) +func (mock *CertRepo) ListCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// LoadWebsites calls LoadWebsitesFunc. +func (mock *CertRepo) LoadWebsites(websiteIDs []uint) ([]*biz.Website, error) { + if mock.LoadWebsitesFunc == nil { + panic("CertRepo.LoadWebsitesFunc: method is nil but CertRepo.LoadWebsites was just called") + } + callInfo := struct { + WebsiteIDs []uint + }{ + WebsiteIDs: websiteIDs, + } + mock.lockLoadWebsites.Lock() + mock.calls.LoadWebsites = append(mock.calls.LoadWebsites, callInfo) + mock.lockLoadWebsites.Unlock() + return mock.LoadWebsitesFunc(websiteIDs) +} + +// LoadWebsitesCalls gets all the calls that were made to LoadWebsites. +// Check the length with: +// +// len(mockedCertRepo.LoadWebsitesCalls()) +func (mock *CertRepo) LoadWebsitesCalls() []struct { + WebsiteIDs []uint +} { + var calls []struct { + WebsiteIDs []uint + } + mock.lockLoadWebsites.RLock() + calls = mock.calls.LoadWebsites + mock.lockLoadWebsites.RUnlock() + return calls +} + +// ObtainPanel calls ObtainPanelFunc. +func (mock *CertRepo) ObtainPanel(account *biz.CertAccount, names []string, webServer string) ([]byte, []byte, error) { + if mock.ObtainPanelFunc == nil { + panic("CertRepo.ObtainPanelFunc: method is nil but CertRepo.ObtainPanel was just called") + } + callInfo := struct { + Account *biz.CertAccount + Names []string + WebServer string + }{ + Account: account, + Names: names, + WebServer: webServer, + } + mock.lockObtainPanel.Lock() + mock.calls.ObtainPanel = append(mock.calls.ObtainPanel, callInfo) + mock.lockObtainPanel.Unlock() + return mock.ObtainPanelFunc(account, names, webServer) +} + +// ObtainPanelCalls gets all the calls that were made to ObtainPanel. +// Check the length with: +// +// len(mockedCertRepo.ObtainPanelCalls()) +func (mock *CertRepo) ObtainPanelCalls() []struct { + Account *biz.CertAccount + Names []string + WebServer string +} { + var calls []struct { + Account *biz.CertAccount + Names []string + WebServer string + } + mock.lockObtainPanel.RLock() + calls = mock.calls.ObtainPanel + mock.lockObtainPanel.RUnlock() + return calls +} + +// ReloadWebserver calls ReloadWebserverFunc. +func (mock *CertRepo) ReloadWebserver(webServer string) error { + if mock.ReloadWebserverFunc == nil { + panic("CertRepo.ReloadWebserverFunc: method is nil but CertRepo.ReloadWebserver was just called") + } + callInfo := struct { + WebServer string + }{ + WebServer: webServer, + } + mock.lockReloadWebserver.Lock() + mock.calls.ReloadWebserver = append(mock.calls.ReloadWebserver, callInfo) + mock.lockReloadWebserver.Unlock() + return mock.ReloadWebserverFunc(webServer) +} + +// ReloadWebserverCalls gets all the calls that were made to ReloadWebserver. +// Check the length with: +// +// len(mockedCertRepo.ReloadWebserverCalls()) +func (mock *CertRepo) ReloadWebserverCalls() []struct { + WebServer string +} { + var calls []struct { + WebServer string + } + mock.lockReloadWebserver.RLock() + calls = mock.calls.ReloadWebserver + mock.lockReloadWebserver.RUnlock() + return calls +} + +// RunScript calls RunScriptFunc. +func (mock *CertRepo) RunScript(cert *biz.Cert) error { + if mock.RunScriptFunc == nil { + panic("CertRepo.RunScriptFunc: method is nil but CertRepo.RunScript was just called") + } + callInfo := struct { + Cert *biz.Cert + }{ + Cert: cert, + } + mock.lockRunScript.Lock() + mock.calls.RunScript = append(mock.calls.RunScript, callInfo) + mock.lockRunScript.Unlock() + return mock.RunScriptFunc(cert) +} + +// RunScriptCalls gets all the calls that were made to RunScript. +// Check the length with: +// +// len(mockedCertRepo.RunScriptCalls()) +func (mock *CertRepo) RunScriptCalls() []struct { + Cert *biz.Cert +} { + var calls []struct { + Cert *biz.Cert + } + mock.lockRunScript.RLock() + calls = mock.calls.RunScript + mock.lockRunScript.RUnlock() + return calls +} + +// Save calls SaveFunc. +func (mock *CertRepo) Save(cert *biz.Cert) error { + if mock.SaveFunc == nil { + panic("CertRepo.SaveFunc: method is nil but CertRepo.Save was just called") + } + callInfo := struct { + Cert *biz.Cert + }{ + Cert: cert, + } + mock.lockSave.Lock() + mock.calls.Save = append(mock.calls.Save, callInfo) + mock.lockSave.Unlock() + return mock.SaveFunc(cert) +} + +// SaveCalls gets all the calls that were made to Save. +// Check the length with: +// +// len(mockedCertRepo.SaveCalls()) +func (mock *CertRepo) SaveCalls() []struct { + Cert *biz.Cert +} { + var calls []struct { + Cert *biz.Cert + } + mock.lockSave.RLock() + calls = mock.calls.Save + mock.lockSave.RUnlock() + return calls +} + +// Update calls UpdateFunc. +func (mock *CertRepo) Update(req *request.CertUpdate) error { + if mock.UpdateFunc == nil { + panic("CertRepo.UpdateFunc: method is nil but CertRepo.Update was just called") + } + callInfo := struct { + Req *request.CertUpdate + }{ + Req: req, + } + mock.lockUpdate.Lock() + mock.calls.Update = append(mock.calls.Update, callInfo) + mock.lockUpdate.Unlock() + return mock.UpdateFunc(req) +} + +// UpdateCalls gets all the calls that were made to Update. +// Check the length with: +// +// len(mockedCertRepo.UpdateCalls()) +func (mock *CertRepo) UpdateCalls() []struct { + Req *request.CertUpdate +} { + var calls []struct { + Req *request.CertUpdate + } + mock.lockUpdate.RLock() + calls = mock.calls.Update + mock.lockUpdate.RUnlock() + return calls +} + +// WriteCertFiles calls WriteCertFilesFunc. +func (mock *CertRepo) WriteCertFiles(cert *biz.Cert, certPath string, keyPath string) error { + if mock.WriteCertFilesFunc == nil { + panic("CertRepo.WriteCertFilesFunc: method is nil but CertRepo.WriteCertFiles was just called") + } + callInfo := struct { + Cert *biz.Cert + CertPath string + KeyPath string + }{ + Cert: cert, + CertPath: certPath, + KeyPath: keyPath, + } + mock.lockWriteCertFiles.Lock() + mock.calls.WriteCertFiles = append(mock.calls.WriteCertFiles, callInfo) + mock.lockWriteCertFiles.Unlock() + return mock.WriteCertFilesFunc(cert, certPath, keyPath) +} + +// WriteCertFilesCalls gets all the calls that were made to WriteCertFiles. +// Check the length with: +// +// len(mockedCertRepo.WriteCertFilesCalls()) +func (mock *CertRepo) WriteCertFilesCalls() []struct { + Cert *biz.Cert + CertPath string + KeyPath string +} { + var calls []struct { + Cert *biz.Cert + CertPath string + KeyPath string + } + mock.lockWriteCertFiles.RLock() + calls = mock.calls.WriteCertFiles + mock.lockWriteCertFiles.RUnlock() + return calls +} diff --git a/internal/mocks/biz/ContainerComposeRepo.go b/internal/mocks/biz/ContainerComposeRepo.go new file mode 100644 index 000000000..7f4ed8f39 --- /dev/null +++ b/internal/mocks/biz/ContainerComposeRepo.go @@ -0,0 +1,365 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that ContainerComposeRepo does implement biz.ContainerComposeRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.ContainerComposeRepo = &ContainerComposeRepo{} + +// ContainerComposeRepo is a mock implementation of biz.ContainerComposeRepo. +// +// func TestSomethingThatUsesContainerComposeRepo(t *testing.T) { +// +// // make and configure a mocked biz.ContainerComposeRepo +// mockedContainerComposeRepo := &ContainerComposeRepo{ +// CreateFunc: func(name string, compose string, envs []types.KV) error { +// panic("mock out the Create method") +// }, +// DownFunc: func(name string) error { +// panic("mock out the Down method") +// }, +// GetFunc: func(name string) (string, []types.KV, error) { +// panic("mock out the Get method") +// }, +// ListFunc: func() ([]types.ContainerCompose, error) { +// panic("mock out the List method") +// }, +// RemoveDirFunc: func(name string) error { +// panic("mock out the RemoveDir method") +// }, +// UpFunc: func(name string, force bool) error { +// panic("mock out the Up method") +// }, +// UpdateFunc: func(name string, compose string, envs []types.KV) error { +// panic("mock out the Update method") +// }, +// } +// +// // use mockedContainerComposeRepo in code that requires biz.ContainerComposeRepo +// // and then make assertions. +// +// } +type ContainerComposeRepo struct { + // CreateFunc mocks the Create method. + CreateFunc func(name string, compose string, envs []types.KV) error + + // DownFunc mocks the Down method. + DownFunc func(name string) error + + // GetFunc mocks the Get method. + GetFunc func(name string) (string, []types.KV, error) + + // ListFunc mocks the List method. + ListFunc func() ([]types.ContainerCompose, error) + + // RemoveDirFunc mocks the RemoveDir method. + RemoveDirFunc func(name string) error + + // UpFunc mocks the Up method. + UpFunc func(name string, force bool) error + + // UpdateFunc mocks the Update method. + UpdateFunc func(name string, compose string, envs []types.KV) error + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // Name is the name argument value. + Name string + // Compose is the compose argument value. + Compose string + // Envs is the envs argument value. + Envs []types.KV + } + // Down holds details about calls to the Down method. + Down []struct { + // Name is the name argument value. + Name string + } + // Get holds details about calls to the Get method. + Get []struct { + // Name is the name argument value. + Name string + } + // List holds details about calls to the List method. + List []struct { + } + // RemoveDir holds details about calls to the RemoveDir method. + RemoveDir []struct { + // Name is the name argument value. + Name string + } + // Up holds details about calls to the Up method. + Up []struct { + // Name is the name argument value. + Name string + // Force is the force argument value. + Force bool + } + // Update holds details about calls to the Update method. + Update []struct { + // Name is the name argument value. + Name string + // Compose is the compose argument value. + Compose string + // Envs is the envs argument value. + Envs []types.KV + } + } + lockCreate sync.RWMutex + lockDown sync.RWMutex + lockGet sync.RWMutex + lockList sync.RWMutex + lockRemoveDir sync.RWMutex + lockUp sync.RWMutex + lockUpdate sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *ContainerComposeRepo) Create(name string, compose string, envs []types.KV) error { + if mock.CreateFunc == nil { + panic("ContainerComposeRepo.CreateFunc: method is nil but ContainerComposeRepo.Create was just called") + } + callInfo := struct { + Name string + Compose string + Envs []types.KV + }{ + Name: name, + Compose: compose, + Envs: envs, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(name, compose, envs) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedContainerComposeRepo.CreateCalls()) +func (mock *ContainerComposeRepo) CreateCalls() []struct { + Name string + Compose string + Envs []types.KV +} { + var calls []struct { + Name string + Compose string + Envs []types.KV + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Down calls DownFunc. +func (mock *ContainerComposeRepo) Down(name string) error { + if mock.DownFunc == nil { + panic("ContainerComposeRepo.DownFunc: method is nil but ContainerComposeRepo.Down was just called") + } + callInfo := struct { + Name string + }{ + Name: name, + } + mock.lockDown.Lock() + mock.calls.Down = append(mock.calls.Down, callInfo) + mock.lockDown.Unlock() + return mock.DownFunc(name) +} + +// DownCalls gets all the calls that were made to Down. +// Check the length with: +// +// len(mockedContainerComposeRepo.DownCalls()) +func (mock *ContainerComposeRepo) DownCalls() []struct { + Name string +} { + var calls []struct { + Name string + } + mock.lockDown.RLock() + calls = mock.calls.Down + mock.lockDown.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *ContainerComposeRepo) Get(name string) (string, []types.KV, error) { + if mock.GetFunc == nil { + panic("ContainerComposeRepo.GetFunc: method is nil but ContainerComposeRepo.Get was just called") + } + callInfo := struct { + Name string + }{ + Name: name, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(name) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedContainerComposeRepo.GetCalls()) +func (mock *ContainerComposeRepo) GetCalls() []struct { + Name string +} { + var calls []struct { + Name string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *ContainerComposeRepo) List() ([]types.ContainerCompose, error) { + if mock.ListFunc == nil { + panic("ContainerComposeRepo.ListFunc: method is nil but ContainerComposeRepo.List was just called") + } + callInfo := struct { + }{} + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc() +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedContainerComposeRepo.ListCalls()) +func (mock *ContainerComposeRepo) ListCalls() []struct { +} { + var calls []struct { + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// RemoveDir calls RemoveDirFunc. +func (mock *ContainerComposeRepo) RemoveDir(name string) error { + if mock.RemoveDirFunc == nil { + panic("ContainerComposeRepo.RemoveDirFunc: method is nil but ContainerComposeRepo.RemoveDir was just called") + } + callInfo := struct { + Name string + }{ + Name: name, + } + mock.lockRemoveDir.Lock() + mock.calls.RemoveDir = append(mock.calls.RemoveDir, callInfo) + mock.lockRemoveDir.Unlock() + return mock.RemoveDirFunc(name) +} + +// RemoveDirCalls gets all the calls that were made to RemoveDir. +// Check the length with: +// +// len(mockedContainerComposeRepo.RemoveDirCalls()) +func (mock *ContainerComposeRepo) RemoveDirCalls() []struct { + Name string +} { + var calls []struct { + Name string + } + mock.lockRemoveDir.RLock() + calls = mock.calls.RemoveDir + mock.lockRemoveDir.RUnlock() + return calls +} + +// Up calls UpFunc. +func (mock *ContainerComposeRepo) Up(name string, force bool) error { + if mock.UpFunc == nil { + panic("ContainerComposeRepo.UpFunc: method is nil but ContainerComposeRepo.Up was just called") + } + callInfo := struct { + Name string + Force bool + }{ + Name: name, + Force: force, + } + mock.lockUp.Lock() + mock.calls.Up = append(mock.calls.Up, callInfo) + mock.lockUp.Unlock() + return mock.UpFunc(name, force) +} + +// UpCalls gets all the calls that were made to Up. +// Check the length with: +// +// len(mockedContainerComposeRepo.UpCalls()) +func (mock *ContainerComposeRepo) UpCalls() []struct { + Name string + Force bool +} { + var calls []struct { + Name string + Force bool + } + mock.lockUp.RLock() + calls = mock.calls.Up + mock.lockUp.RUnlock() + return calls +} + +// Update calls UpdateFunc. +func (mock *ContainerComposeRepo) Update(name string, compose string, envs []types.KV) error { + if mock.UpdateFunc == nil { + panic("ContainerComposeRepo.UpdateFunc: method is nil but ContainerComposeRepo.Update was just called") + } + callInfo := struct { + Name string + Compose string + Envs []types.KV + }{ + Name: name, + Compose: compose, + Envs: envs, + } + mock.lockUpdate.Lock() + mock.calls.Update = append(mock.calls.Update, callInfo) + mock.lockUpdate.Unlock() + return mock.UpdateFunc(name, compose, envs) +} + +// UpdateCalls gets all the calls that were made to Update. +// Check the length with: +// +// len(mockedContainerComposeRepo.UpdateCalls()) +func (mock *ContainerComposeRepo) UpdateCalls() []struct { + Name string + Compose string + Envs []types.KV +} { + var calls []struct { + Name string + Compose string + Envs []types.KV + } + mock.lockUpdate.RLock() + calls = mock.calls.Update + mock.lockUpdate.RUnlock() + return calls +} diff --git a/internal/mocks/biz/ContainerImageRepo.go b/internal/mocks/biz/ContainerImageRepo.go new file mode 100644 index 000000000..8accb3eb7 --- /dev/null +++ b/internal/mocks/biz/ContainerImageRepo.go @@ -0,0 +1,273 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that ContainerImageRepo does implement biz.ContainerImageRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.ContainerImageRepo = &ContainerImageRepo{} + +// ContainerImageRepo is a mock implementation of biz.ContainerImageRepo. +// +// func TestSomethingThatUsesContainerImageRepo(t *testing.T) { +// +// // make and configure a mocked biz.ContainerImageRepo +// mockedContainerImageRepo := &ContainerImageRepo{ +// ExistFunc: func(sock string, name string) (bool, error) { +// panic("mock out the Exist method") +// }, +// ListFunc: func(sock string) ([]types.ContainerImage, error) { +// panic("mock out the List method") +// }, +// PruneFunc: func(sock string) error { +// panic("mock out the Prune method") +// }, +// PullFunc: func(sock string, req *request.ContainerImagePull) error { +// panic("mock out the Pull method") +// }, +// RemoveFunc: func(sock string, id string) error { +// panic("mock out the Remove method") +// }, +// } +// +// // use mockedContainerImageRepo in code that requires biz.ContainerImageRepo +// // and then make assertions. +// +// } +type ContainerImageRepo struct { + // ExistFunc mocks the Exist method. + ExistFunc func(sock string, name string) (bool, error) + + // ListFunc mocks the List method. + ListFunc func(sock string) ([]types.ContainerImage, error) + + // PruneFunc mocks the Prune method. + PruneFunc func(sock string) error + + // PullFunc mocks the Pull method. + PullFunc func(sock string, req *request.ContainerImagePull) error + + // RemoveFunc mocks the Remove method. + RemoveFunc func(sock string, id string) error + + // calls tracks calls to the methods. + calls struct { + // Exist holds details about calls to the Exist method. + Exist []struct { + // Sock is the sock argument value. + Sock string + // Name is the name argument value. + Name string + } + // List holds details about calls to the List method. + List []struct { + // Sock is the sock argument value. + Sock string + } + // Prune holds details about calls to the Prune method. + Prune []struct { + // Sock is the sock argument value. + Sock string + } + // Pull holds details about calls to the Pull method. + Pull []struct { + // Sock is the sock argument value. + Sock string + // Req is the req argument value. + Req *request.ContainerImagePull + } + // Remove holds details about calls to the Remove method. + Remove []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + } + } + lockExist sync.RWMutex + lockList sync.RWMutex + lockPrune sync.RWMutex + lockPull sync.RWMutex + lockRemove sync.RWMutex +} + +// Exist calls ExistFunc. +func (mock *ContainerImageRepo) Exist(sock string, name string) (bool, error) { + if mock.ExistFunc == nil { + panic("ContainerImageRepo.ExistFunc: method is nil but ContainerImageRepo.Exist was just called") + } + callInfo := struct { + Sock string + Name string + }{ + Sock: sock, + Name: name, + } + mock.lockExist.Lock() + mock.calls.Exist = append(mock.calls.Exist, callInfo) + mock.lockExist.Unlock() + return mock.ExistFunc(sock, name) +} + +// ExistCalls gets all the calls that were made to Exist. +// Check the length with: +// +// len(mockedContainerImageRepo.ExistCalls()) +func (mock *ContainerImageRepo) ExistCalls() []struct { + Sock string + Name string +} { + var calls []struct { + Sock string + Name string + } + mock.lockExist.RLock() + calls = mock.calls.Exist + mock.lockExist.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *ContainerImageRepo) List(sock string) ([]types.ContainerImage, error) { + if mock.ListFunc == nil { + panic("ContainerImageRepo.ListFunc: method is nil but ContainerImageRepo.List was just called") + } + callInfo := struct { + Sock string + }{ + Sock: sock, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(sock) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedContainerImageRepo.ListCalls()) +func (mock *ContainerImageRepo) ListCalls() []struct { + Sock string +} { + var calls []struct { + Sock string + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// Prune calls PruneFunc. +func (mock *ContainerImageRepo) Prune(sock string) error { + if mock.PruneFunc == nil { + panic("ContainerImageRepo.PruneFunc: method is nil but ContainerImageRepo.Prune was just called") + } + callInfo := struct { + Sock string + }{ + Sock: sock, + } + mock.lockPrune.Lock() + mock.calls.Prune = append(mock.calls.Prune, callInfo) + mock.lockPrune.Unlock() + return mock.PruneFunc(sock) +} + +// PruneCalls gets all the calls that were made to Prune. +// Check the length with: +// +// len(mockedContainerImageRepo.PruneCalls()) +func (mock *ContainerImageRepo) PruneCalls() []struct { + Sock string +} { + var calls []struct { + Sock string + } + mock.lockPrune.RLock() + calls = mock.calls.Prune + mock.lockPrune.RUnlock() + return calls +} + +// Pull calls PullFunc. +func (mock *ContainerImageRepo) Pull(sock string, req *request.ContainerImagePull) error { + if mock.PullFunc == nil { + panic("ContainerImageRepo.PullFunc: method is nil but ContainerImageRepo.Pull was just called") + } + callInfo := struct { + Sock string + Req *request.ContainerImagePull + }{ + Sock: sock, + Req: req, + } + mock.lockPull.Lock() + mock.calls.Pull = append(mock.calls.Pull, callInfo) + mock.lockPull.Unlock() + return mock.PullFunc(sock, req) +} + +// PullCalls gets all the calls that were made to Pull. +// Check the length with: +// +// len(mockedContainerImageRepo.PullCalls()) +func (mock *ContainerImageRepo) PullCalls() []struct { + Sock string + Req *request.ContainerImagePull +} { + var calls []struct { + Sock string + Req *request.ContainerImagePull + } + mock.lockPull.RLock() + calls = mock.calls.Pull + mock.lockPull.RUnlock() + return calls +} + +// Remove calls RemoveFunc. +func (mock *ContainerImageRepo) Remove(sock string, id string) error { + if mock.RemoveFunc == nil { + panic("ContainerImageRepo.RemoveFunc: method is nil but ContainerImageRepo.Remove was just called") + } + callInfo := struct { + Sock string + ID string + }{ + Sock: sock, + ID: id, + } + mock.lockRemove.Lock() + mock.calls.Remove = append(mock.calls.Remove, callInfo) + mock.lockRemove.Unlock() + return mock.RemoveFunc(sock, id) +} + +// RemoveCalls gets all the calls that were made to Remove. +// Check the length with: +// +// len(mockedContainerImageRepo.RemoveCalls()) +func (mock *ContainerImageRepo) RemoveCalls() []struct { + Sock string + ID string +} { + var calls []struct { + Sock string + ID string + } + mock.lockRemove.RLock() + calls = mock.calls.Remove + mock.lockRemove.RUnlock() + return calls +} diff --git a/internal/mocks/biz/ContainerNetworkRepo.go b/internal/mocks/biz/ContainerNetworkRepo.go new file mode 100644 index 000000000..5ef352198 --- /dev/null +++ b/internal/mocks/biz/ContainerNetworkRepo.go @@ -0,0 +1,223 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that ContainerNetworkRepo does implement biz.ContainerNetworkRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.ContainerNetworkRepo = &ContainerNetworkRepo{} + +// ContainerNetworkRepo is a mock implementation of biz.ContainerNetworkRepo. +// +// func TestSomethingThatUsesContainerNetworkRepo(t *testing.T) { +// +// // make and configure a mocked biz.ContainerNetworkRepo +// mockedContainerNetworkRepo := &ContainerNetworkRepo{ +// CreateFunc: func(sock string, req *request.ContainerNetworkCreate) (string, error) { +// panic("mock out the Create method") +// }, +// ListFunc: func(sock string) ([]types.ContainerNetwork, error) { +// panic("mock out the List method") +// }, +// PruneFunc: func(sock string) error { +// panic("mock out the Prune method") +// }, +// RemoveFunc: func(sock string, id string) error { +// panic("mock out the Remove method") +// }, +// } +// +// // use mockedContainerNetworkRepo in code that requires biz.ContainerNetworkRepo +// // and then make assertions. +// +// } +type ContainerNetworkRepo struct { + // CreateFunc mocks the Create method. + CreateFunc func(sock string, req *request.ContainerNetworkCreate) (string, error) + + // ListFunc mocks the List method. + ListFunc func(sock string) ([]types.ContainerNetwork, error) + + // PruneFunc mocks the Prune method. + PruneFunc func(sock string) error + + // RemoveFunc mocks the Remove method. + RemoveFunc func(sock string, id string) error + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // Sock is the sock argument value. + Sock string + // Req is the req argument value. + Req *request.ContainerNetworkCreate + } + // List holds details about calls to the List method. + List []struct { + // Sock is the sock argument value. + Sock string + } + // Prune holds details about calls to the Prune method. + Prune []struct { + // Sock is the sock argument value. + Sock string + } + // Remove holds details about calls to the Remove method. + Remove []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + } + } + lockCreate sync.RWMutex + lockList sync.RWMutex + lockPrune sync.RWMutex + lockRemove sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *ContainerNetworkRepo) Create(sock string, req *request.ContainerNetworkCreate) (string, error) { + if mock.CreateFunc == nil { + panic("ContainerNetworkRepo.CreateFunc: method is nil but ContainerNetworkRepo.Create was just called") + } + callInfo := struct { + Sock string + Req *request.ContainerNetworkCreate + }{ + Sock: sock, + Req: req, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(sock, req) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedContainerNetworkRepo.CreateCalls()) +func (mock *ContainerNetworkRepo) CreateCalls() []struct { + Sock string + Req *request.ContainerNetworkCreate +} { + var calls []struct { + Sock string + Req *request.ContainerNetworkCreate + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *ContainerNetworkRepo) List(sock string) ([]types.ContainerNetwork, error) { + if mock.ListFunc == nil { + panic("ContainerNetworkRepo.ListFunc: method is nil but ContainerNetworkRepo.List was just called") + } + callInfo := struct { + Sock string + }{ + Sock: sock, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(sock) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedContainerNetworkRepo.ListCalls()) +func (mock *ContainerNetworkRepo) ListCalls() []struct { + Sock string +} { + var calls []struct { + Sock string + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// Prune calls PruneFunc. +func (mock *ContainerNetworkRepo) Prune(sock string) error { + if mock.PruneFunc == nil { + panic("ContainerNetworkRepo.PruneFunc: method is nil but ContainerNetworkRepo.Prune was just called") + } + callInfo := struct { + Sock string + }{ + Sock: sock, + } + mock.lockPrune.Lock() + mock.calls.Prune = append(mock.calls.Prune, callInfo) + mock.lockPrune.Unlock() + return mock.PruneFunc(sock) +} + +// PruneCalls gets all the calls that were made to Prune. +// Check the length with: +// +// len(mockedContainerNetworkRepo.PruneCalls()) +func (mock *ContainerNetworkRepo) PruneCalls() []struct { + Sock string +} { + var calls []struct { + Sock string + } + mock.lockPrune.RLock() + calls = mock.calls.Prune + mock.lockPrune.RUnlock() + return calls +} + +// Remove calls RemoveFunc. +func (mock *ContainerNetworkRepo) Remove(sock string, id string) error { + if mock.RemoveFunc == nil { + panic("ContainerNetworkRepo.RemoveFunc: method is nil but ContainerNetworkRepo.Remove was just called") + } + callInfo := struct { + Sock string + ID string + }{ + Sock: sock, + ID: id, + } + mock.lockRemove.Lock() + mock.calls.Remove = append(mock.calls.Remove, callInfo) + mock.lockRemove.Unlock() + return mock.RemoveFunc(sock, id) +} + +// RemoveCalls gets all the calls that were made to Remove. +// Check the length with: +// +// len(mockedContainerNetworkRepo.RemoveCalls()) +func (mock *ContainerNetworkRepo) RemoveCalls() []struct { + Sock string + ID string +} { + var calls []struct { + Sock string + ID string + } + mock.lockRemove.RLock() + calls = mock.calls.Remove + mock.lockRemove.RUnlock() + return calls +} diff --git a/internal/mocks/biz/ContainerRepo.go b/internal/mocks/biz/ContainerRepo.go new file mode 100644 index 000000000..4965b8c17 --- /dev/null +++ b/internal/mocks/biz/ContainerRepo.go @@ -0,0 +1,685 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that ContainerRepo does implement biz.ContainerRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.ContainerRepo = &ContainerRepo{} + +// ContainerRepo is a mock implementation of biz.ContainerRepo. +// +// func TestSomethingThatUsesContainerRepo(t *testing.T) { +// +// // make and configure a mocked biz.ContainerRepo +// mockedContainerRepo := &ContainerRepo{ +// CreateFunc: func(sock string, req *request.ContainerCreate) (string, error) { +// panic("mock out the Create method") +// }, +// InspectFunc: func(sock string, id string) (any, error) { +// panic("mock out the Inspect method") +// }, +// KillFunc: func(sock string, id string) error { +// panic("mock out the Kill method") +// }, +// ListAllFunc: func(sock string) ([]types.Container, error) { +// panic("mock out the ListAll method") +// }, +// LogsFunc: func(sock string, id string, tail int) (string, error) { +// panic("mock out the Logs method") +// }, +// PauseFunc: func(sock string, id string) error { +// panic("mock out the Pause method") +// }, +// PruneFunc: func(sock string) error { +// panic("mock out the Prune method") +// }, +// RemoveFunc: func(sock string, id string) error { +// panic("mock out the Remove method") +// }, +// RenameFunc: func(sock string, id string, newName string) error { +// panic("mock out the Rename method") +// }, +// RestartFunc: func(sock string, id string) error { +// panic("mock out the Restart method") +// }, +// StartFunc: func(sock string, id string) error { +// panic("mock out the Start method") +// }, +// StopFunc: func(sock string, id string) error { +// panic("mock out the Stop method") +// }, +// UnpauseFunc: func(sock string, id string) error { +// panic("mock out the Unpause method") +// }, +// } +// +// // use mockedContainerRepo in code that requires biz.ContainerRepo +// // and then make assertions. +// +// } +type ContainerRepo struct { + // CreateFunc mocks the Create method. + CreateFunc func(sock string, req *request.ContainerCreate) (string, error) + + // InspectFunc mocks the Inspect method. + InspectFunc func(sock string, id string) (any, error) + + // KillFunc mocks the Kill method. + KillFunc func(sock string, id string) error + + // ListAllFunc mocks the ListAll method. + ListAllFunc func(sock string) ([]types.Container, error) + + // LogsFunc mocks the Logs method. + LogsFunc func(sock string, id string, tail int) (string, error) + + // PauseFunc mocks the Pause method. + PauseFunc func(sock string, id string) error + + // PruneFunc mocks the Prune method. + PruneFunc func(sock string) error + + // RemoveFunc mocks the Remove method. + RemoveFunc func(sock string, id string) error + + // RenameFunc mocks the Rename method. + RenameFunc func(sock string, id string, newName string) error + + // RestartFunc mocks the Restart method. + RestartFunc func(sock string, id string) error + + // StartFunc mocks the Start method. + StartFunc func(sock string, id string) error + + // StopFunc mocks the Stop method. + StopFunc func(sock string, id string) error + + // UnpauseFunc mocks the Unpause method. + UnpauseFunc func(sock string, id string) error + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // Sock is the sock argument value. + Sock string + // Req is the req argument value. + Req *request.ContainerCreate + } + // Inspect holds details about calls to the Inspect method. + Inspect []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + } + // Kill holds details about calls to the Kill method. + Kill []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + } + // ListAll holds details about calls to the ListAll method. + ListAll []struct { + // Sock is the sock argument value. + Sock string + } + // Logs holds details about calls to the Logs method. + Logs []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + // Tail is the tail argument value. + Tail int + } + // Pause holds details about calls to the Pause method. + Pause []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + } + // Prune holds details about calls to the Prune method. + Prune []struct { + // Sock is the sock argument value. + Sock string + } + // Remove holds details about calls to the Remove method. + Remove []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + } + // Rename holds details about calls to the Rename method. + Rename []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + // NewName is the newName argument value. + NewName string + } + // Restart holds details about calls to the Restart method. + Restart []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + } + // Start holds details about calls to the Start method. + Start []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + } + // Stop holds details about calls to the Stop method. + Stop []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + } + // Unpause holds details about calls to the Unpause method. + Unpause []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + } + } + lockCreate sync.RWMutex + lockInspect sync.RWMutex + lockKill sync.RWMutex + lockListAll sync.RWMutex + lockLogs sync.RWMutex + lockPause sync.RWMutex + lockPrune sync.RWMutex + lockRemove sync.RWMutex + lockRename sync.RWMutex + lockRestart sync.RWMutex + lockStart sync.RWMutex + lockStop sync.RWMutex + lockUnpause sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *ContainerRepo) Create(sock string, req *request.ContainerCreate) (string, error) { + if mock.CreateFunc == nil { + panic("ContainerRepo.CreateFunc: method is nil but ContainerRepo.Create was just called") + } + callInfo := struct { + Sock string + Req *request.ContainerCreate + }{ + Sock: sock, + Req: req, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(sock, req) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedContainerRepo.CreateCalls()) +func (mock *ContainerRepo) CreateCalls() []struct { + Sock string + Req *request.ContainerCreate +} { + var calls []struct { + Sock string + Req *request.ContainerCreate + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Inspect calls InspectFunc. +func (mock *ContainerRepo) Inspect(sock string, id string) (any, error) { + if mock.InspectFunc == nil { + panic("ContainerRepo.InspectFunc: method is nil but ContainerRepo.Inspect was just called") + } + callInfo := struct { + Sock string + ID string + }{ + Sock: sock, + ID: id, + } + mock.lockInspect.Lock() + mock.calls.Inspect = append(mock.calls.Inspect, callInfo) + mock.lockInspect.Unlock() + return mock.InspectFunc(sock, id) +} + +// InspectCalls gets all the calls that were made to Inspect. +// Check the length with: +// +// len(mockedContainerRepo.InspectCalls()) +func (mock *ContainerRepo) InspectCalls() []struct { + Sock string + ID string +} { + var calls []struct { + Sock string + ID string + } + mock.lockInspect.RLock() + calls = mock.calls.Inspect + mock.lockInspect.RUnlock() + return calls +} + +// Kill calls KillFunc. +func (mock *ContainerRepo) Kill(sock string, id string) error { + if mock.KillFunc == nil { + panic("ContainerRepo.KillFunc: method is nil but ContainerRepo.Kill was just called") + } + callInfo := struct { + Sock string + ID string + }{ + Sock: sock, + ID: id, + } + mock.lockKill.Lock() + mock.calls.Kill = append(mock.calls.Kill, callInfo) + mock.lockKill.Unlock() + return mock.KillFunc(sock, id) +} + +// KillCalls gets all the calls that were made to Kill. +// Check the length with: +// +// len(mockedContainerRepo.KillCalls()) +func (mock *ContainerRepo) KillCalls() []struct { + Sock string + ID string +} { + var calls []struct { + Sock string + ID string + } + mock.lockKill.RLock() + calls = mock.calls.Kill + mock.lockKill.RUnlock() + return calls +} + +// ListAll calls ListAllFunc. +func (mock *ContainerRepo) ListAll(sock string) ([]types.Container, error) { + if mock.ListAllFunc == nil { + panic("ContainerRepo.ListAllFunc: method is nil but ContainerRepo.ListAll was just called") + } + callInfo := struct { + Sock string + }{ + Sock: sock, + } + mock.lockListAll.Lock() + mock.calls.ListAll = append(mock.calls.ListAll, callInfo) + mock.lockListAll.Unlock() + return mock.ListAllFunc(sock) +} + +// ListAllCalls gets all the calls that were made to ListAll. +// Check the length with: +// +// len(mockedContainerRepo.ListAllCalls()) +func (mock *ContainerRepo) ListAllCalls() []struct { + Sock string +} { + var calls []struct { + Sock string + } + mock.lockListAll.RLock() + calls = mock.calls.ListAll + mock.lockListAll.RUnlock() + return calls +} + +// Logs calls LogsFunc. +func (mock *ContainerRepo) Logs(sock string, id string, tail int) (string, error) { + if mock.LogsFunc == nil { + panic("ContainerRepo.LogsFunc: method is nil but ContainerRepo.Logs was just called") + } + callInfo := struct { + Sock string + ID string + Tail int + }{ + Sock: sock, + ID: id, + Tail: tail, + } + mock.lockLogs.Lock() + mock.calls.Logs = append(mock.calls.Logs, callInfo) + mock.lockLogs.Unlock() + return mock.LogsFunc(sock, id, tail) +} + +// LogsCalls gets all the calls that were made to Logs. +// Check the length with: +// +// len(mockedContainerRepo.LogsCalls()) +func (mock *ContainerRepo) LogsCalls() []struct { + Sock string + ID string + Tail int +} { + var calls []struct { + Sock string + ID string + Tail int + } + mock.lockLogs.RLock() + calls = mock.calls.Logs + mock.lockLogs.RUnlock() + return calls +} + +// Pause calls PauseFunc. +func (mock *ContainerRepo) Pause(sock string, id string) error { + if mock.PauseFunc == nil { + panic("ContainerRepo.PauseFunc: method is nil but ContainerRepo.Pause was just called") + } + callInfo := struct { + Sock string + ID string + }{ + Sock: sock, + ID: id, + } + mock.lockPause.Lock() + mock.calls.Pause = append(mock.calls.Pause, callInfo) + mock.lockPause.Unlock() + return mock.PauseFunc(sock, id) +} + +// PauseCalls gets all the calls that were made to Pause. +// Check the length with: +// +// len(mockedContainerRepo.PauseCalls()) +func (mock *ContainerRepo) PauseCalls() []struct { + Sock string + ID string +} { + var calls []struct { + Sock string + ID string + } + mock.lockPause.RLock() + calls = mock.calls.Pause + mock.lockPause.RUnlock() + return calls +} + +// Prune calls PruneFunc. +func (mock *ContainerRepo) Prune(sock string) error { + if mock.PruneFunc == nil { + panic("ContainerRepo.PruneFunc: method is nil but ContainerRepo.Prune was just called") + } + callInfo := struct { + Sock string + }{ + Sock: sock, + } + mock.lockPrune.Lock() + mock.calls.Prune = append(mock.calls.Prune, callInfo) + mock.lockPrune.Unlock() + return mock.PruneFunc(sock) +} + +// PruneCalls gets all the calls that were made to Prune. +// Check the length with: +// +// len(mockedContainerRepo.PruneCalls()) +func (mock *ContainerRepo) PruneCalls() []struct { + Sock string +} { + var calls []struct { + Sock string + } + mock.lockPrune.RLock() + calls = mock.calls.Prune + mock.lockPrune.RUnlock() + return calls +} + +// Remove calls RemoveFunc. +func (mock *ContainerRepo) Remove(sock string, id string) error { + if mock.RemoveFunc == nil { + panic("ContainerRepo.RemoveFunc: method is nil but ContainerRepo.Remove was just called") + } + callInfo := struct { + Sock string + ID string + }{ + Sock: sock, + ID: id, + } + mock.lockRemove.Lock() + mock.calls.Remove = append(mock.calls.Remove, callInfo) + mock.lockRemove.Unlock() + return mock.RemoveFunc(sock, id) +} + +// RemoveCalls gets all the calls that were made to Remove. +// Check the length with: +// +// len(mockedContainerRepo.RemoveCalls()) +func (mock *ContainerRepo) RemoveCalls() []struct { + Sock string + ID string +} { + var calls []struct { + Sock string + ID string + } + mock.lockRemove.RLock() + calls = mock.calls.Remove + mock.lockRemove.RUnlock() + return calls +} + +// Rename calls RenameFunc. +func (mock *ContainerRepo) Rename(sock string, id string, newName string) error { + if mock.RenameFunc == nil { + panic("ContainerRepo.RenameFunc: method is nil but ContainerRepo.Rename was just called") + } + callInfo := struct { + Sock string + ID string + NewName string + }{ + Sock: sock, + ID: id, + NewName: newName, + } + mock.lockRename.Lock() + mock.calls.Rename = append(mock.calls.Rename, callInfo) + mock.lockRename.Unlock() + return mock.RenameFunc(sock, id, newName) +} + +// RenameCalls gets all the calls that were made to Rename. +// Check the length with: +// +// len(mockedContainerRepo.RenameCalls()) +func (mock *ContainerRepo) RenameCalls() []struct { + Sock string + ID string + NewName string +} { + var calls []struct { + Sock string + ID string + NewName string + } + mock.lockRename.RLock() + calls = mock.calls.Rename + mock.lockRename.RUnlock() + return calls +} + +// Restart calls RestartFunc. +func (mock *ContainerRepo) Restart(sock string, id string) error { + if mock.RestartFunc == nil { + panic("ContainerRepo.RestartFunc: method is nil but ContainerRepo.Restart was just called") + } + callInfo := struct { + Sock string + ID string + }{ + Sock: sock, + ID: id, + } + mock.lockRestart.Lock() + mock.calls.Restart = append(mock.calls.Restart, callInfo) + mock.lockRestart.Unlock() + return mock.RestartFunc(sock, id) +} + +// RestartCalls gets all the calls that were made to Restart. +// Check the length with: +// +// len(mockedContainerRepo.RestartCalls()) +func (mock *ContainerRepo) RestartCalls() []struct { + Sock string + ID string +} { + var calls []struct { + Sock string + ID string + } + mock.lockRestart.RLock() + calls = mock.calls.Restart + mock.lockRestart.RUnlock() + return calls +} + +// Start calls StartFunc. +func (mock *ContainerRepo) Start(sock string, id string) error { + if mock.StartFunc == nil { + panic("ContainerRepo.StartFunc: method is nil but ContainerRepo.Start was just called") + } + callInfo := struct { + Sock string + ID string + }{ + Sock: sock, + ID: id, + } + mock.lockStart.Lock() + mock.calls.Start = append(mock.calls.Start, callInfo) + mock.lockStart.Unlock() + return mock.StartFunc(sock, id) +} + +// StartCalls gets all the calls that were made to Start. +// Check the length with: +// +// len(mockedContainerRepo.StartCalls()) +func (mock *ContainerRepo) StartCalls() []struct { + Sock string + ID string +} { + var calls []struct { + Sock string + ID string + } + mock.lockStart.RLock() + calls = mock.calls.Start + mock.lockStart.RUnlock() + return calls +} + +// Stop calls StopFunc. +func (mock *ContainerRepo) Stop(sock string, id string) error { + if mock.StopFunc == nil { + panic("ContainerRepo.StopFunc: method is nil but ContainerRepo.Stop was just called") + } + callInfo := struct { + Sock string + ID string + }{ + Sock: sock, + ID: id, + } + mock.lockStop.Lock() + mock.calls.Stop = append(mock.calls.Stop, callInfo) + mock.lockStop.Unlock() + return mock.StopFunc(sock, id) +} + +// StopCalls gets all the calls that were made to Stop. +// Check the length with: +// +// len(mockedContainerRepo.StopCalls()) +func (mock *ContainerRepo) StopCalls() []struct { + Sock string + ID string +} { + var calls []struct { + Sock string + ID string + } + mock.lockStop.RLock() + calls = mock.calls.Stop + mock.lockStop.RUnlock() + return calls +} + +// Unpause calls UnpauseFunc. +func (mock *ContainerRepo) Unpause(sock string, id string) error { + if mock.UnpauseFunc == nil { + panic("ContainerRepo.UnpauseFunc: method is nil but ContainerRepo.Unpause was just called") + } + callInfo := struct { + Sock string + ID string + }{ + Sock: sock, + ID: id, + } + mock.lockUnpause.Lock() + mock.calls.Unpause = append(mock.calls.Unpause, callInfo) + mock.lockUnpause.Unlock() + return mock.UnpauseFunc(sock, id) +} + +// UnpauseCalls gets all the calls that were made to Unpause. +// Check the length with: +// +// len(mockedContainerRepo.UnpauseCalls()) +func (mock *ContainerRepo) UnpauseCalls() []struct { + Sock string + ID string +} { + var calls []struct { + Sock string + ID string + } + mock.lockUnpause.RLock() + calls = mock.calls.Unpause + mock.lockUnpause.RUnlock() + return calls +} diff --git a/internal/mocks/biz/ContainerVolumeRepo.go b/internal/mocks/biz/ContainerVolumeRepo.go new file mode 100644 index 000000000..06c81b3f3 --- /dev/null +++ b/internal/mocks/biz/ContainerVolumeRepo.go @@ -0,0 +1,223 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that ContainerVolumeRepo does implement biz.ContainerVolumeRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.ContainerVolumeRepo = &ContainerVolumeRepo{} + +// ContainerVolumeRepo is a mock implementation of biz.ContainerVolumeRepo. +// +// func TestSomethingThatUsesContainerVolumeRepo(t *testing.T) { +// +// // make and configure a mocked biz.ContainerVolumeRepo +// mockedContainerVolumeRepo := &ContainerVolumeRepo{ +// CreateFunc: func(sock string, req *request.ContainerVolumeCreate) (string, error) { +// panic("mock out the Create method") +// }, +// ListFunc: func(sock string) ([]types.ContainerVolume, error) { +// panic("mock out the List method") +// }, +// PruneFunc: func(sock string) error { +// panic("mock out the Prune method") +// }, +// RemoveFunc: func(sock string, id string) error { +// panic("mock out the Remove method") +// }, +// } +// +// // use mockedContainerVolumeRepo in code that requires biz.ContainerVolumeRepo +// // and then make assertions. +// +// } +type ContainerVolumeRepo struct { + // CreateFunc mocks the Create method. + CreateFunc func(sock string, req *request.ContainerVolumeCreate) (string, error) + + // ListFunc mocks the List method. + ListFunc func(sock string) ([]types.ContainerVolume, error) + + // PruneFunc mocks the Prune method. + PruneFunc func(sock string) error + + // RemoveFunc mocks the Remove method. + RemoveFunc func(sock string, id string) error + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // Sock is the sock argument value. + Sock string + // Req is the req argument value. + Req *request.ContainerVolumeCreate + } + // List holds details about calls to the List method. + List []struct { + // Sock is the sock argument value. + Sock string + } + // Prune holds details about calls to the Prune method. + Prune []struct { + // Sock is the sock argument value. + Sock string + } + // Remove holds details about calls to the Remove method. + Remove []struct { + // Sock is the sock argument value. + Sock string + // ID is the id argument value. + ID string + } + } + lockCreate sync.RWMutex + lockList sync.RWMutex + lockPrune sync.RWMutex + lockRemove sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *ContainerVolumeRepo) Create(sock string, req *request.ContainerVolumeCreate) (string, error) { + if mock.CreateFunc == nil { + panic("ContainerVolumeRepo.CreateFunc: method is nil but ContainerVolumeRepo.Create was just called") + } + callInfo := struct { + Sock string + Req *request.ContainerVolumeCreate + }{ + Sock: sock, + Req: req, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(sock, req) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedContainerVolumeRepo.CreateCalls()) +func (mock *ContainerVolumeRepo) CreateCalls() []struct { + Sock string + Req *request.ContainerVolumeCreate +} { + var calls []struct { + Sock string + Req *request.ContainerVolumeCreate + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *ContainerVolumeRepo) List(sock string) ([]types.ContainerVolume, error) { + if mock.ListFunc == nil { + panic("ContainerVolumeRepo.ListFunc: method is nil but ContainerVolumeRepo.List was just called") + } + callInfo := struct { + Sock string + }{ + Sock: sock, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(sock) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedContainerVolumeRepo.ListCalls()) +func (mock *ContainerVolumeRepo) ListCalls() []struct { + Sock string +} { + var calls []struct { + Sock string + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// Prune calls PruneFunc. +func (mock *ContainerVolumeRepo) Prune(sock string) error { + if mock.PruneFunc == nil { + panic("ContainerVolumeRepo.PruneFunc: method is nil but ContainerVolumeRepo.Prune was just called") + } + callInfo := struct { + Sock string + }{ + Sock: sock, + } + mock.lockPrune.Lock() + mock.calls.Prune = append(mock.calls.Prune, callInfo) + mock.lockPrune.Unlock() + return mock.PruneFunc(sock) +} + +// PruneCalls gets all the calls that were made to Prune. +// Check the length with: +// +// len(mockedContainerVolumeRepo.PruneCalls()) +func (mock *ContainerVolumeRepo) PruneCalls() []struct { + Sock string +} { + var calls []struct { + Sock string + } + mock.lockPrune.RLock() + calls = mock.calls.Prune + mock.lockPrune.RUnlock() + return calls +} + +// Remove calls RemoveFunc. +func (mock *ContainerVolumeRepo) Remove(sock string, id string) error { + if mock.RemoveFunc == nil { + panic("ContainerVolumeRepo.RemoveFunc: method is nil but ContainerVolumeRepo.Remove was just called") + } + callInfo := struct { + Sock string + ID string + }{ + Sock: sock, + ID: id, + } + mock.lockRemove.Lock() + mock.calls.Remove = append(mock.calls.Remove, callInfo) + mock.lockRemove.Unlock() + return mock.RemoveFunc(sock, id) +} + +// RemoveCalls gets all the calls that were made to Remove. +// Check the length with: +// +// len(mockedContainerVolumeRepo.RemoveCalls()) +func (mock *ContainerVolumeRepo) RemoveCalls() []struct { + Sock string + ID string +} { + var calls []struct { + Sock string + ID string + } + mock.lockRemove.RLock() + calls = mock.calls.Remove + mock.lockRemove.RUnlock() + return calls +} diff --git a/internal/mocks/biz/CronRepo.go b/internal/mocks/biz/CronRepo.go new file mode 100644 index 000000000..7fb00c50b --- /dev/null +++ b/internal/mocks/biz/CronRepo.go @@ -0,0 +1,623 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that CronRepo does implement biz.CronRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.CronRepo = &CronRepo{} + +// CronRepo is a mock implementation of biz.CronRepo. +// +// func TestSomethingThatUsesCronRepo(t *testing.T) { +// +// // make and configure a mocked biz.CronRepo +// mockedCronRepo := &CronRepo{ +// AddToSystemFunc: func(cron *biz.Cron) error { +// panic("mock out the AddToSystem method") +// }, +// CountFunc: func() (int64, error) { +// panic("mock out the Count method") +// }, +// CreateFunc: func(cron *biz.Cron) error { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(cron *biz.Cron) error { +// panic("mock out the Delete method") +// }, +// DeleteFromSystemFunc: func(cron *biz.Cron) error { +// panic("mock out the DeleteFromSystem method") +// }, +// Dos2UnixFunc: func(path string) error { +// panic("mock out the Dos2Unix method") +// }, +// GenerateScriptFunc: func(typ string, config types.CronConfig, rawScript string) string { +// panic("mock out the GenerateScript method") +// }, +// GetFunc: func(id uint) (*biz.Cron, error) { +// panic("mock out the Get method") +// }, +// ListFunc: func(page uint, limit uint) ([]*biz.Cron, int64, error) { +// panic("mock out the List method") +// }, +// RemoveScriptFilesFunc: func(shellPath string) error { +// panic("mock out the RemoveScriptFiles method") +// }, +// SaveFunc: func(cron *biz.Cron) error { +// panic("mock out the Save method") +// }, +// WriteNewScriptFunc: func(script string) (string, string, error) { +// panic("mock out the WriteNewScript method") +// }, +// WriteScriptFunc: func(path string, script string) error { +// panic("mock out the WriteScript method") +// }, +// } +// +// // use mockedCronRepo in code that requires biz.CronRepo +// // and then make assertions. +// +// } +type CronRepo struct { + // AddToSystemFunc mocks the AddToSystem method. + AddToSystemFunc func(cron *biz.Cron) error + + // CountFunc mocks the Count method. + CountFunc func() (int64, error) + + // CreateFunc mocks the Create method. + CreateFunc func(cron *biz.Cron) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(cron *biz.Cron) error + + // DeleteFromSystemFunc mocks the DeleteFromSystem method. + DeleteFromSystemFunc func(cron *biz.Cron) error + + // Dos2UnixFunc mocks the Dos2Unix method. + Dos2UnixFunc func(path string) error + + // GenerateScriptFunc mocks the GenerateScript method. + GenerateScriptFunc func(typ string, config types.CronConfig, rawScript string) string + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*biz.Cron, error) + + // ListFunc mocks the List method. + ListFunc func(page uint, limit uint) ([]*biz.Cron, int64, error) + + // RemoveScriptFilesFunc mocks the RemoveScriptFiles method. + RemoveScriptFilesFunc func(shellPath string) error + + // SaveFunc mocks the Save method. + SaveFunc func(cron *biz.Cron) error + + // WriteNewScriptFunc mocks the WriteNewScript method. + WriteNewScriptFunc func(script string) (string, string, error) + + // WriteScriptFunc mocks the WriteScript method. + WriteScriptFunc func(path string, script string) error + + // calls tracks calls to the methods. + calls struct { + // AddToSystem holds details about calls to the AddToSystem method. + AddToSystem []struct { + // Cron is the cron argument value. + Cron *biz.Cron + } + // Count holds details about calls to the Count method. + Count []struct { + } + // Create holds details about calls to the Create method. + Create []struct { + // Cron is the cron argument value. + Cron *biz.Cron + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // Cron is the cron argument value. + Cron *biz.Cron + } + // DeleteFromSystem holds details about calls to the DeleteFromSystem method. + DeleteFromSystem []struct { + // Cron is the cron argument value. + Cron *biz.Cron + } + // Dos2Unix holds details about calls to the Dos2Unix method. + Dos2Unix []struct { + // Path is the path argument value. + Path string + } + // GenerateScript holds details about calls to the GenerateScript method. + GenerateScript []struct { + // Typ is the typ argument value. + Typ string + // Config is the config argument value. + Config types.CronConfig + // RawScript is the rawScript argument value. + RawScript string + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // List holds details about calls to the List method. + List []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // RemoveScriptFiles holds details about calls to the RemoveScriptFiles method. + RemoveScriptFiles []struct { + // ShellPath is the shellPath argument value. + ShellPath string + } + // Save holds details about calls to the Save method. + Save []struct { + // Cron is the cron argument value. + Cron *biz.Cron + } + // WriteNewScript holds details about calls to the WriteNewScript method. + WriteNewScript []struct { + // Script is the script argument value. + Script string + } + // WriteScript holds details about calls to the WriteScript method. + WriteScript []struct { + // Path is the path argument value. + Path string + // Script is the script argument value. + Script string + } + } + lockAddToSystem sync.RWMutex + lockCount sync.RWMutex + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockDeleteFromSystem sync.RWMutex + lockDos2Unix sync.RWMutex + lockGenerateScript sync.RWMutex + lockGet sync.RWMutex + lockList sync.RWMutex + lockRemoveScriptFiles sync.RWMutex + lockSave sync.RWMutex + lockWriteNewScript sync.RWMutex + lockWriteScript sync.RWMutex +} + +// AddToSystem calls AddToSystemFunc. +func (mock *CronRepo) AddToSystem(cron *biz.Cron) error { + if mock.AddToSystemFunc == nil { + panic("CronRepo.AddToSystemFunc: method is nil but CronRepo.AddToSystem was just called") + } + callInfo := struct { + Cron *biz.Cron + }{ + Cron: cron, + } + mock.lockAddToSystem.Lock() + mock.calls.AddToSystem = append(mock.calls.AddToSystem, callInfo) + mock.lockAddToSystem.Unlock() + return mock.AddToSystemFunc(cron) +} + +// AddToSystemCalls gets all the calls that were made to AddToSystem. +// Check the length with: +// +// len(mockedCronRepo.AddToSystemCalls()) +func (mock *CronRepo) AddToSystemCalls() []struct { + Cron *biz.Cron +} { + var calls []struct { + Cron *biz.Cron + } + mock.lockAddToSystem.RLock() + calls = mock.calls.AddToSystem + mock.lockAddToSystem.RUnlock() + return calls +} + +// Count calls CountFunc. +func (mock *CronRepo) Count() (int64, error) { + if mock.CountFunc == nil { + panic("CronRepo.CountFunc: method is nil but CronRepo.Count was just called") + } + callInfo := struct { + }{} + mock.lockCount.Lock() + mock.calls.Count = append(mock.calls.Count, callInfo) + mock.lockCount.Unlock() + return mock.CountFunc() +} + +// CountCalls gets all the calls that were made to Count. +// Check the length with: +// +// len(mockedCronRepo.CountCalls()) +func (mock *CronRepo) CountCalls() []struct { +} { + var calls []struct { + } + mock.lockCount.RLock() + calls = mock.calls.Count + mock.lockCount.RUnlock() + return calls +} + +// Create calls CreateFunc. +func (mock *CronRepo) Create(cron *biz.Cron) error { + if mock.CreateFunc == nil { + panic("CronRepo.CreateFunc: method is nil but CronRepo.Create was just called") + } + callInfo := struct { + Cron *biz.Cron + }{ + Cron: cron, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(cron) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedCronRepo.CreateCalls()) +func (mock *CronRepo) CreateCalls() []struct { + Cron *biz.Cron +} { + var calls []struct { + Cron *biz.Cron + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *CronRepo) Delete(cron *biz.Cron) error { + if mock.DeleteFunc == nil { + panic("CronRepo.DeleteFunc: method is nil but CronRepo.Delete was just called") + } + callInfo := struct { + Cron *biz.Cron + }{ + Cron: cron, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(cron) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedCronRepo.DeleteCalls()) +func (mock *CronRepo) DeleteCalls() []struct { + Cron *biz.Cron +} { + var calls []struct { + Cron *biz.Cron + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// DeleteFromSystem calls DeleteFromSystemFunc. +func (mock *CronRepo) DeleteFromSystem(cron *biz.Cron) error { + if mock.DeleteFromSystemFunc == nil { + panic("CronRepo.DeleteFromSystemFunc: method is nil but CronRepo.DeleteFromSystem was just called") + } + callInfo := struct { + Cron *biz.Cron + }{ + Cron: cron, + } + mock.lockDeleteFromSystem.Lock() + mock.calls.DeleteFromSystem = append(mock.calls.DeleteFromSystem, callInfo) + mock.lockDeleteFromSystem.Unlock() + return mock.DeleteFromSystemFunc(cron) +} + +// DeleteFromSystemCalls gets all the calls that were made to DeleteFromSystem. +// Check the length with: +// +// len(mockedCronRepo.DeleteFromSystemCalls()) +func (mock *CronRepo) DeleteFromSystemCalls() []struct { + Cron *biz.Cron +} { + var calls []struct { + Cron *biz.Cron + } + mock.lockDeleteFromSystem.RLock() + calls = mock.calls.DeleteFromSystem + mock.lockDeleteFromSystem.RUnlock() + return calls +} + +// Dos2Unix calls Dos2UnixFunc. +func (mock *CronRepo) Dos2Unix(path string) error { + if mock.Dos2UnixFunc == nil { + panic("CronRepo.Dos2UnixFunc: method is nil but CronRepo.Dos2Unix was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockDos2Unix.Lock() + mock.calls.Dos2Unix = append(mock.calls.Dos2Unix, callInfo) + mock.lockDos2Unix.Unlock() + return mock.Dos2UnixFunc(path) +} + +// Dos2UnixCalls gets all the calls that were made to Dos2Unix. +// Check the length with: +// +// len(mockedCronRepo.Dos2UnixCalls()) +func (mock *CronRepo) Dos2UnixCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockDos2Unix.RLock() + calls = mock.calls.Dos2Unix + mock.lockDos2Unix.RUnlock() + return calls +} + +// GenerateScript calls GenerateScriptFunc. +func (mock *CronRepo) GenerateScript(typ string, config types.CronConfig, rawScript string) string { + if mock.GenerateScriptFunc == nil { + panic("CronRepo.GenerateScriptFunc: method is nil but CronRepo.GenerateScript was just called") + } + callInfo := struct { + Typ string + Config types.CronConfig + RawScript string + }{ + Typ: typ, + Config: config, + RawScript: rawScript, + } + mock.lockGenerateScript.Lock() + mock.calls.GenerateScript = append(mock.calls.GenerateScript, callInfo) + mock.lockGenerateScript.Unlock() + return mock.GenerateScriptFunc(typ, config, rawScript) +} + +// GenerateScriptCalls gets all the calls that were made to GenerateScript. +// Check the length with: +// +// len(mockedCronRepo.GenerateScriptCalls()) +func (mock *CronRepo) GenerateScriptCalls() []struct { + Typ string + Config types.CronConfig + RawScript string +} { + var calls []struct { + Typ string + Config types.CronConfig + RawScript string + } + mock.lockGenerateScript.RLock() + calls = mock.calls.GenerateScript + mock.lockGenerateScript.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *CronRepo) Get(id uint) (*biz.Cron, error) { + if mock.GetFunc == nil { + panic("CronRepo.GetFunc: method is nil but CronRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedCronRepo.GetCalls()) +func (mock *CronRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *CronRepo) List(page uint, limit uint) ([]*biz.Cron, int64, error) { + if mock.ListFunc == nil { + panic("CronRepo.ListFunc: method is nil but CronRepo.List was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedCronRepo.ListCalls()) +func (mock *CronRepo) ListCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// RemoveScriptFiles calls RemoveScriptFilesFunc. +func (mock *CronRepo) RemoveScriptFiles(shellPath string) error { + if mock.RemoveScriptFilesFunc == nil { + panic("CronRepo.RemoveScriptFilesFunc: method is nil but CronRepo.RemoveScriptFiles was just called") + } + callInfo := struct { + ShellPath string + }{ + ShellPath: shellPath, + } + mock.lockRemoveScriptFiles.Lock() + mock.calls.RemoveScriptFiles = append(mock.calls.RemoveScriptFiles, callInfo) + mock.lockRemoveScriptFiles.Unlock() + return mock.RemoveScriptFilesFunc(shellPath) +} + +// RemoveScriptFilesCalls gets all the calls that were made to RemoveScriptFiles. +// Check the length with: +// +// len(mockedCronRepo.RemoveScriptFilesCalls()) +func (mock *CronRepo) RemoveScriptFilesCalls() []struct { + ShellPath string +} { + var calls []struct { + ShellPath string + } + mock.lockRemoveScriptFiles.RLock() + calls = mock.calls.RemoveScriptFiles + mock.lockRemoveScriptFiles.RUnlock() + return calls +} + +// Save calls SaveFunc. +func (mock *CronRepo) Save(cron *biz.Cron) error { + if mock.SaveFunc == nil { + panic("CronRepo.SaveFunc: method is nil but CronRepo.Save was just called") + } + callInfo := struct { + Cron *biz.Cron + }{ + Cron: cron, + } + mock.lockSave.Lock() + mock.calls.Save = append(mock.calls.Save, callInfo) + mock.lockSave.Unlock() + return mock.SaveFunc(cron) +} + +// SaveCalls gets all the calls that were made to Save. +// Check the length with: +// +// len(mockedCronRepo.SaveCalls()) +func (mock *CronRepo) SaveCalls() []struct { + Cron *biz.Cron +} { + var calls []struct { + Cron *biz.Cron + } + mock.lockSave.RLock() + calls = mock.calls.Save + mock.lockSave.RUnlock() + return calls +} + +// WriteNewScript calls WriteNewScriptFunc. +func (mock *CronRepo) WriteNewScript(script string) (string, string, error) { + if mock.WriteNewScriptFunc == nil { + panic("CronRepo.WriteNewScriptFunc: method is nil but CronRepo.WriteNewScript was just called") + } + callInfo := struct { + Script string + }{ + Script: script, + } + mock.lockWriteNewScript.Lock() + mock.calls.WriteNewScript = append(mock.calls.WriteNewScript, callInfo) + mock.lockWriteNewScript.Unlock() + return mock.WriteNewScriptFunc(script) +} + +// WriteNewScriptCalls gets all the calls that were made to WriteNewScript. +// Check the length with: +// +// len(mockedCronRepo.WriteNewScriptCalls()) +func (mock *CronRepo) WriteNewScriptCalls() []struct { + Script string +} { + var calls []struct { + Script string + } + mock.lockWriteNewScript.RLock() + calls = mock.calls.WriteNewScript + mock.lockWriteNewScript.RUnlock() + return calls +} + +// WriteScript calls WriteScriptFunc. +func (mock *CronRepo) WriteScript(path string, script string) error { + if mock.WriteScriptFunc == nil { + panic("CronRepo.WriteScriptFunc: method is nil but CronRepo.WriteScript was just called") + } + callInfo := struct { + Path string + Script string + }{ + Path: path, + Script: script, + } + mock.lockWriteScript.Lock() + mock.calls.WriteScript = append(mock.calls.WriteScript, callInfo) + mock.lockWriteScript.Unlock() + return mock.WriteScriptFunc(path, script) +} + +// WriteScriptCalls gets all the calls that were made to WriteScript. +// Check the length with: +// +// len(mockedCronRepo.WriteScriptCalls()) +func (mock *CronRepo) WriteScriptCalls() []struct { + Path string + Script string +} { + var calls []struct { + Path string + Script string + } + mock.lockWriteScript.RLock() + calls = mock.calls.WriteScript + mock.lockWriteScript.RUnlock() + return calls +} diff --git a/internal/mocks/biz/DatabaseElasticsearchRepo.go b/internal/mocks/biz/DatabaseElasticsearchRepo.go new file mode 100644 index 000000000..05fa514f2 --- /dev/null +++ b/internal/mocks/biz/DatabaseElasticsearchRepo.go @@ -0,0 +1,386 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "context" + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/db" +) + +// Ensure that DatabaseElasticsearchRepo does implement biz.DatabaseElasticsearchRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.DatabaseElasticsearchRepo = &DatabaseElasticsearchRepo{} + +// DatabaseElasticsearchRepo is a mock implementation of biz.DatabaseElasticsearchRepo. +// +// func TestSomethingThatUsesDatabaseElasticsearchRepo(t *testing.T) { +// +// // make and configure a mocked biz.DatabaseElasticsearchRepo +// mockedDatabaseElasticsearchRepo := &DatabaseElasticsearchRepo{ +// DataFunc: func(ctx context.Context, req *request.DatabaseESData) ([]db.ESDocument, int64, error) { +// panic("mock out the Data method") +// }, +// DocumentDeleteFunc: func(ctx context.Context, req *request.DatabaseESDocumentDelete) error { +// panic("mock out the DocumentDelete method") +// }, +// DocumentGetFunc: func(ctx context.Context, req *request.DatabaseESDocumentGet) (*db.ESDocument, error) { +// panic("mock out the DocumentGet method") +// }, +// DocumentSetFunc: func(ctx context.Context, req *request.DatabaseESDocumentSet) error { +// panic("mock out the DocumentSet method") +// }, +// IndexCreateFunc: func(ctx context.Context, req *request.DatabaseESIndexCreate) error { +// panic("mock out the IndexCreate method") +// }, +// IndexDeleteFunc: func(ctx context.Context, req *request.DatabaseESIndexDelete) error { +// panic("mock out the IndexDelete method") +// }, +// IndicesFunc: func(ctx context.Context, req *request.DatabaseESIndices) ([]db.ESIndex, error) { +// panic("mock out the Indices method") +// }, +// } +// +// // use mockedDatabaseElasticsearchRepo in code that requires biz.DatabaseElasticsearchRepo +// // and then make assertions. +// +// } +type DatabaseElasticsearchRepo struct { + // DataFunc mocks the Data method. + DataFunc func(ctx context.Context, req *request.DatabaseESData) ([]db.ESDocument, int64, error) + + // DocumentDeleteFunc mocks the DocumentDelete method. + DocumentDeleteFunc func(ctx context.Context, req *request.DatabaseESDocumentDelete) error + + // DocumentGetFunc mocks the DocumentGet method. + DocumentGetFunc func(ctx context.Context, req *request.DatabaseESDocumentGet) (*db.ESDocument, error) + + // DocumentSetFunc mocks the DocumentSet method. + DocumentSetFunc func(ctx context.Context, req *request.DatabaseESDocumentSet) error + + // IndexCreateFunc mocks the IndexCreate method. + IndexCreateFunc func(ctx context.Context, req *request.DatabaseESIndexCreate) error + + // IndexDeleteFunc mocks the IndexDelete method. + IndexDeleteFunc func(ctx context.Context, req *request.DatabaseESIndexDelete) error + + // IndicesFunc mocks the Indices method. + IndicesFunc func(ctx context.Context, req *request.DatabaseESIndices) ([]db.ESIndex, error) + + // calls tracks calls to the methods. + calls struct { + // Data holds details about calls to the Data method. + Data []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseESData + } + // DocumentDelete holds details about calls to the DocumentDelete method. + DocumentDelete []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseESDocumentDelete + } + // DocumentGet holds details about calls to the DocumentGet method. + DocumentGet []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseESDocumentGet + } + // DocumentSet holds details about calls to the DocumentSet method. + DocumentSet []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseESDocumentSet + } + // IndexCreate holds details about calls to the IndexCreate method. + IndexCreate []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseESIndexCreate + } + // IndexDelete holds details about calls to the IndexDelete method. + IndexDelete []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseESIndexDelete + } + // Indices holds details about calls to the Indices method. + Indices []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseESIndices + } + } + lockData sync.RWMutex + lockDocumentDelete sync.RWMutex + lockDocumentGet sync.RWMutex + lockDocumentSet sync.RWMutex + lockIndexCreate sync.RWMutex + lockIndexDelete sync.RWMutex + lockIndices sync.RWMutex +} + +// Data calls DataFunc. +func (mock *DatabaseElasticsearchRepo) Data(ctx context.Context, req *request.DatabaseESData) ([]db.ESDocument, int64, error) { + if mock.DataFunc == nil { + panic("DatabaseElasticsearchRepo.DataFunc: method is nil but DatabaseElasticsearchRepo.Data was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseESData + }{ + Ctx: ctx, + Req: req, + } + mock.lockData.Lock() + mock.calls.Data = append(mock.calls.Data, callInfo) + mock.lockData.Unlock() + return mock.DataFunc(ctx, req) +} + +// DataCalls gets all the calls that were made to Data. +// Check the length with: +// +// len(mockedDatabaseElasticsearchRepo.DataCalls()) +func (mock *DatabaseElasticsearchRepo) DataCalls() []struct { + Ctx context.Context + Req *request.DatabaseESData +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseESData + } + mock.lockData.RLock() + calls = mock.calls.Data + mock.lockData.RUnlock() + return calls +} + +// DocumentDelete calls DocumentDeleteFunc. +func (mock *DatabaseElasticsearchRepo) DocumentDelete(ctx context.Context, req *request.DatabaseESDocumentDelete) error { + if mock.DocumentDeleteFunc == nil { + panic("DatabaseElasticsearchRepo.DocumentDeleteFunc: method is nil but DatabaseElasticsearchRepo.DocumentDelete was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseESDocumentDelete + }{ + Ctx: ctx, + Req: req, + } + mock.lockDocumentDelete.Lock() + mock.calls.DocumentDelete = append(mock.calls.DocumentDelete, callInfo) + mock.lockDocumentDelete.Unlock() + return mock.DocumentDeleteFunc(ctx, req) +} + +// DocumentDeleteCalls gets all the calls that were made to DocumentDelete. +// Check the length with: +// +// len(mockedDatabaseElasticsearchRepo.DocumentDeleteCalls()) +func (mock *DatabaseElasticsearchRepo) DocumentDeleteCalls() []struct { + Ctx context.Context + Req *request.DatabaseESDocumentDelete +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseESDocumentDelete + } + mock.lockDocumentDelete.RLock() + calls = mock.calls.DocumentDelete + mock.lockDocumentDelete.RUnlock() + return calls +} + +// DocumentGet calls DocumentGetFunc. +func (mock *DatabaseElasticsearchRepo) DocumentGet(ctx context.Context, req *request.DatabaseESDocumentGet) (*db.ESDocument, error) { + if mock.DocumentGetFunc == nil { + panic("DatabaseElasticsearchRepo.DocumentGetFunc: method is nil but DatabaseElasticsearchRepo.DocumentGet was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseESDocumentGet + }{ + Ctx: ctx, + Req: req, + } + mock.lockDocumentGet.Lock() + mock.calls.DocumentGet = append(mock.calls.DocumentGet, callInfo) + mock.lockDocumentGet.Unlock() + return mock.DocumentGetFunc(ctx, req) +} + +// DocumentGetCalls gets all the calls that were made to DocumentGet. +// Check the length with: +// +// len(mockedDatabaseElasticsearchRepo.DocumentGetCalls()) +func (mock *DatabaseElasticsearchRepo) DocumentGetCalls() []struct { + Ctx context.Context + Req *request.DatabaseESDocumentGet +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseESDocumentGet + } + mock.lockDocumentGet.RLock() + calls = mock.calls.DocumentGet + mock.lockDocumentGet.RUnlock() + return calls +} + +// DocumentSet calls DocumentSetFunc. +func (mock *DatabaseElasticsearchRepo) DocumentSet(ctx context.Context, req *request.DatabaseESDocumentSet) error { + if mock.DocumentSetFunc == nil { + panic("DatabaseElasticsearchRepo.DocumentSetFunc: method is nil but DatabaseElasticsearchRepo.DocumentSet was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseESDocumentSet + }{ + Ctx: ctx, + Req: req, + } + mock.lockDocumentSet.Lock() + mock.calls.DocumentSet = append(mock.calls.DocumentSet, callInfo) + mock.lockDocumentSet.Unlock() + return mock.DocumentSetFunc(ctx, req) +} + +// DocumentSetCalls gets all the calls that were made to DocumentSet. +// Check the length with: +// +// len(mockedDatabaseElasticsearchRepo.DocumentSetCalls()) +func (mock *DatabaseElasticsearchRepo) DocumentSetCalls() []struct { + Ctx context.Context + Req *request.DatabaseESDocumentSet +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseESDocumentSet + } + mock.lockDocumentSet.RLock() + calls = mock.calls.DocumentSet + mock.lockDocumentSet.RUnlock() + return calls +} + +// IndexCreate calls IndexCreateFunc. +func (mock *DatabaseElasticsearchRepo) IndexCreate(ctx context.Context, req *request.DatabaseESIndexCreate) error { + if mock.IndexCreateFunc == nil { + panic("DatabaseElasticsearchRepo.IndexCreateFunc: method is nil but DatabaseElasticsearchRepo.IndexCreate was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseESIndexCreate + }{ + Ctx: ctx, + Req: req, + } + mock.lockIndexCreate.Lock() + mock.calls.IndexCreate = append(mock.calls.IndexCreate, callInfo) + mock.lockIndexCreate.Unlock() + return mock.IndexCreateFunc(ctx, req) +} + +// IndexCreateCalls gets all the calls that were made to IndexCreate. +// Check the length with: +// +// len(mockedDatabaseElasticsearchRepo.IndexCreateCalls()) +func (mock *DatabaseElasticsearchRepo) IndexCreateCalls() []struct { + Ctx context.Context + Req *request.DatabaseESIndexCreate +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseESIndexCreate + } + mock.lockIndexCreate.RLock() + calls = mock.calls.IndexCreate + mock.lockIndexCreate.RUnlock() + return calls +} + +// IndexDelete calls IndexDeleteFunc. +func (mock *DatabaseElasticsearchRepo) IndexDelete(ctx context.Context, req *request.DatabaseESIndexDelete) error { + if mock.IndexDeleteFunc == nil { + panic("DatabaseElasticsearchRepo.IndexDeleteFunc: method is nil but DatabaseElasticsearchRepo.IndexDelete was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseESIndexDelete + }{ + Ctx: ctx, + Req: req, + } + mock.lockIndexDelete.Lock() + mock.calls.IndexDelete = append(mock.calls.IndexDelete, callInfo) + mock.lockIndexDelete.Unlock() + return mock.IndexDeleteFunc(ctx, req) +} + +// IndexDeleteCalls gets all the calls that were made to IndexDelete. +// Check the length with: +// +// len(mockedDatabaseElasticsearchRepo.IndexDeleteCalls()) +func (mock *DatabaseElasticsearchRepo) IndexDeleteCalls() []struct { + Ctx context.Context + Req *request.DatabaseESIndexDelete +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseESIndexDelete + } + mock.lockIndexDelete.RLock() + calls = mock.calls.IndexDelete + mock.lockIndexDelete.RUnlock() + return calls +} + +// Indices calls IndicesFunc. +func (mock *DatabaseElasticsearchRepo) Indices(ctx context.Context, req *request.DatabaseESIndices) ([]db.ESIndex, error) { + if mock.IndicesFunc == nil { + panic("DatabaseElasticsearchRepo.IndicesFunc: method is nil but DatabaseElasticsearchRepo.Indices was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseESIndices + }{ + Ctx: ctx, + Req: req, + } + mock.lockIndices.Lock() + mock.calls.Indices = append(mock.calls.Indices, callInfo) + mock.lockIndices.Unlock() + return mock.IndicesFunc(ctx, req) +} + +// IndicesCalls gets all the calls that were made to Indices. +// Check the length with: +// +// len(mockedDatabaseElasticsearchRepo.IndicesCalls()) +func (mock *DatabaseElasticsearchRepo) IndicesCalls() []struct { + Ctx context.Context + Req *request.DatabaseESIndices +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseESIndices + } + mock.lockIndices.RLock() + calls = mock.calls.Indices + mock.lockIndices.RUnlock() + return calls +} diff --git a/internal/mocks/biz/DatabaseRedisRepo.go b/internal/mocks/biz/DatabaseRedisRepo.go new file mode 100644 index 000000000..fb6fd6125 --- /dev/null +++ b/internal/mocks/biz/DatabaseRedisRepo.go @@ -0,0 +1,436 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "context" + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/db" +) + +// Ensure that DatabaseRedisRepo does implement biz.DatabaseRedisRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.DatabaseRedisRepo = &DatabaseRedisRepo{} + +// DatabaseRedisRepo is a mock implementation of biz.DatabaseRedisRepo. +// +// func TestSomethingThatUsesDatabaseRedisRepo(t *testing.T) { +// +// // make and configure a mocked biz.DatabaseRedisRepo +// mockedDatabaseRedisRepo := &DatabaseRedisRepo{ +// ClearFunc: func(ctx context.Context, req *request.DatabaseRedisClear) error { +// panic("mock out the Clear method") +// }, +// DataFunc: func(ctx context.Context, req *request.DatabaseRedisData) ([]db.RedisKV, int, error) { +// panic("mock out the Data method") +// }, +// DatabasesFunc: func(ctx context.Context, req *request.DatabaseRedisDatabases) (int, error) { +// panic("mock out the Databases method") +// }, +// KeyDeleteFunc: func(ctx context.Context, req *request.DatabaseRedisKeyDelete) error { +// panic("mock out the KeyDelete method") +// }, +// KeyGetFunc: func(ctx context.Context, req *request.DatabaseRedisKeyGet) (*db.RedisKV, error) { +// panic("mock out the KeyGet method") +// }, +// KeyRenameFunc: func(ctx context.Context, req *request.DatabaseRedisKeyRename) error { +// panic("mock out the KeyRename method") +// }, +// KeySetFunc: func(ctx context.Context, req *request.DatabaseRedisKeySet) error { +// panic("mock out the KeySet method") +// }, +// KeyTTLFunc: func(ctx context.Context, req *request.DatabaseRedisKeyTTL) error { +// panic("mock out the KeyTTL method") +// }, +// } +// +// // use mockedDatabaseRedisRepo in code that requires biz.DatabaseRedisRepo +// // and then make assertions. +// +// } +type DatabaseRedisRepo struct { + // ClearFunc mocks the Clear method. + ClearFunc func(ctx context.Context, req *request.DatabaseRedisClear) error + + // DataFunc mocks the Data method. + DataFunc func(ctx context.Context, req *request.DatabaseRedisData) ([]db.RedisKV, int, error) + + // DatabasesFunc mocks the Databases method. + DatabasesFunc func(ctx context.Context, req *request.DatabaseRedisDatabases) (int, error) + + // KeyDeleteFunc mocks the KeyDelete method. + KeyDeleteFunc func(ctx context.Context, req *request.DatabaseRedisKeyDelete) error + + // KeyGetFunc mocks the KeyGet method. + KeyGetFunc func(ctx context.Context, req *request.DatabaseRedisKeyGet) (*db.RedisKV, error) + + // KeyRenameFunc mocks the KeyRename method. + KeyRenameFunc func(ctx context.Context, req *request.DatabaseRedisKeyRename) error + + // KeySetFunc mocks the KeySet method. + KeySetFunc func(ctx context.Context, req *request.DatabaseRedisKeySet) error + + // KeyTTLFunc mocks the KeyTTL method. + KeyTTLFunc func(ctx context.Context, req *request.DatabaseRedisKeyTTL) error + + // calls tracks calls to the methods. + calls struct { + // Clear holds details about calls to the Clear method. + Clear []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseRedisClear + } + // Data holds details about calls to the Data method. + Data []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseRedisData + } + // Databases holds details about calls to the Databases method. + Databases []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseRedisDatabases + } + // KeyDelete holds details about calls to the KeyDelete method. + KeyDelete []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseRedisKeyDelete + } + // KeyGet holds details about calls to the KeyGet method. + KeyGet []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseRedisKeyGet + } + // KeyRename holds details about calls to the KeyRename method. + KeyRename []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseRedisKeyRename + } + // KeySet holds details about calls to the KeySet method. + KeySet []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseRedisKeySet + } + // KeyTTL holds details about calls to the KeyTTL method. + KeyTTL []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseRedisKeyTTL + } + } + lockClear sync.RWMutex + lockData sync.RWMutex + lockDatabases sync.RWMutex + lockKeyDelete sync.RWMutex + lockKeyGet sync.RWMutex + lockKeyRename sync.RWMutex + lockKeySet sync.RWMutex + lockKeyTTL sync.RWMutex +} + +// Clear calls ClearFunc. +func (mock *DatabaseRedisRepo) Clear(ctx context.Context, req *request.DatabaseRedisClear) error { + if mock.ClearFunc == nil { + panic("DatabaseRedisRepo.ClearFunc: method is nil but DatabaseRedisRepo.Clear was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseRedisClear + }{ + Ctx: ctx, + Req: req, + } + mock.lockClear.Lock() + mock.calls.Clear = append(mock.calls.Clear, callInfo) + mock.lockClear.Unlock() + return mock.ClearFunc(ctx, req) +} + +// ClearCalls gets all the calls that were made to Clear. +// Check the length with: +// +// len(mockedDatabaseRedisRepo.ClearCalls()) +func (mock *DatabaseRedisRepo) ClearCalls() []struct { + Ctx context.Context + Req *request.DatabaseRedisClear +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseRedisClear + } + mock.lockClear.RLock() + calls = mock.calls.Clear + mock.lockClear.RUnlock() + return calls +} + +// Data calls DataFunc. +func (mock *DatabaseRedisRepo) Data(ctx context.Context, req *request.DatabaseRedisData) ([]db.RedisKV, int, error) { + if mock.DataFunc == nil { + panic("DatabaseRedisRepo.DataFunc: method is nil but DatabaseRedisRepo.Data was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseRedisData + }{ + Ctx: ctx, + Req: req, + } + mock.lockData.Lock() + mock.calls.Data = append(mock.calls.Data, callInfo) + mock.lockData.Unlock() + return mock.DataFunc(ctx, req) +} + +// DataCalls gets all the calls that were made to Data. +// Check the length with: +// +// len(mockedDatabaseRedisRepo.DataCalls()) +func (mock *DatabaseRedisRepo) DataCalls() []struct { + Ctx context.Context + Req *request.DatabaseRedisData +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseRedisData + } + mock.lockData.RLock() + calls = mock.calls.Data + mock.lockData.RUnlock() + return calls +} + +// Databases calls DatabasesFunc. +func (mock *DatabaseRedisRepo) Databases(ctx context.Context, req *request.DatabaseRedisDatabases) (int, error) { + if mock.DatabasesFunc == nil { + panic("DatabaseRedisRepo.DatabasesFunc: method is nil but DatabaseRedisRepo.Databases was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseRedisDatabases + }{ + Ctx: ctx, + Req: req, + } + mock.lockDatabases.Lock() + mock.calls.Databases = append(mock.calls.Databases, callInfo) + mock.lockDatabases.Unlock() + return mock.DatabasesFunc(ctx, req) +} + +// DatabasesCalls gets all the calls that were made to Databases. +// Check the length with: +// +// len(mockedDatabaseRedisRepo.DatabasesCalls()) +func (mock *DatabaseRedisRepo) DatabasesCalls() []struct { + Ctx context.Context + Req *request.DatabaseRedisDatabases +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseRedisDatabases + } + mock.lockDatabases.RLock() + calls = mock.calls.Databases + mock.lockDatabases.RUnlock() + return calls +} + +// KeyDelete calls KeyDeleteFunc. +func (mock *DatabaseRedisRepo) KeyDelete(ctx context.Context, req *request.DatabaseRedisKeyDelete) error { + if mock.KeyDeleteFunc == nil { + panic("DatabaseRedisRepo.KeyDeleteFunc: method is nil but DatabaseRedisRepo.KeyDelete was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseRedisKeyDelete + }{ + Ctx: ctx, + Req: req, + } + mock.lockKeyDelete.Lock() + mock.calls.KeyDelete = append(mock.calls.KeyDelete, callInfo) + mock.lockKeyDelete.Unlock() + return mock.KeyDeleteFunc(ctx, req) +} + +// KeyDeleteCalls gets all the calls that were made to KeyDelete. +// Check the length with: +// +// len(mockedDatabaseRedisRepo.KeyDeleteCalls()) +func (mock *DatabaseRedisRepo) KeyDeleteCalls() []struct { + Ctx context.Context + Req *request.DatabaseRedisKeyDelete +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseRedisKeyDelete + } + mock.lockKeyDelete.RLock() + calls = mock.calls.KeyDelete + mock.lockKeyDelete.RUnlock() + return calls +} + +// KeyGet calls KeyGetFunc. +func (mock *DatabaseRedisRepo) KeyGet(ctx context.Context, req *request.DatabaseRedisKeyGet) (*db.RedisKV, error) { + if mock.KeyGetFunc == nil { + panic("DatabaseRedisRepo.KeyGetFunc: method is nil but DatabaseRedisRepo.KeyGet was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseRedisKeyGet + }{ + Ctx: ctx, + Req: req, + } + mock.lockKeyGet.Lock() + mock.calls.KeyGet = append(mock.calls.KeyGet, callInfo) + mock.lockKeyGet.Unlock() + return mock.KeyGetFunc(ctx, req) +} + +// KeyGetCalls gets all the calls that were made to KeyGet. +// Check the length with: +// +// len(mockedDatabaseRedisRepo.KeyGetCalls()) +func (mock *DatabaseRedisRepo) KeyGetCalls() []struct { + Ctx context.Context + Req *request.DatabaseRedisKeyGet +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseRedisKeyGet + } + mock.lockKeyGet.RLock() + calls = mock.calls.KeyGet + mock.lockKeyGet.RUnlock() + return calls +} + +// KeyRename calls KeyRenameFunc. +func (mock *DatabaseRedisRepo) KeyRename(ctx context.Context, req *request.DatabaseRedisKeyRename) error { + if mock.KeyRenameFunc == nil { + panic("DatabaseRedisRepo.KeyRenameFunc: method is nil but DatabaseRedisRepo.KeyRename was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseRedisKeyRename + }{ + Ctx: ctx, + Req: req, + } + mock.lockKeyRename.Lock() + mock.calls.KeyRename = append(mock.calls.KeyRename, callInfo) + mock.lockKeyRename.Unlock() + return mock.KeyRenameFunc(ctx, req) +} + +// KeyRenameCalls gets all the calls that were made to KeyRename. +// Check the length with: +// +// len(mockedDatabaseRedisRepo.KeyRenameCalls()) +func (mock *DatabaseRedisRepo) KeyRenameCalls() []struct { + Ctx context.Context + Req *request.DatabaseRedisKeyRename +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseRedisKeyRename + } + mock.lockKeyRename.RLock() + calls = mock.calls.KeyRename + mock.lockKeyRename.RUnlock() + return calls +} + +// KeySet calls KeySetFunc. +func (mock *DatabaseRedisRepo) KeySet(ctx context.Context, req *request.DatabaseRedisKeySet) error { + if mock.KeySetFunc == nil { + panic("DatabaseRedisRepo.KeySetFunc: method is nil but DatabaseRedisRepo.KeySet was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseRedisKeySet + }{ + Ctx: ctx, + Req: req, + } + mock.lockKeySet.Lock() + mock.calls.KeySet = append(mock.calls.KeySet, callInfo) + mock.lockKeySet.Unlock() + return mock.KeySetFunc(ctx, req) +} + +// KeySetCalls gets all the calls that were made to KeySet. +// Check the length with: +// +// len(mockedDatabaseRedisRepo.KeySetCalls()) +func (mock *DatabaseRedisRepo) KeySetCalls() []struct { + Ctx context.Context + Req *request.DatabaseRedisKeySet +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseRedisKeySet + } + mock.lockKeySet.RLock() + calls = mock.calls.KeySet + mock.lockKeySet.RUnlock() + return calls +} + +// KeyTTL calls KeyTTLFunc. +func (mock *DatabaseRedisRepo) KeyTTL(ctx context.Context, req *request.DatabaseRedisKeyTTL) error { + if mock.KeyTTLFunc == nil { + panic("DatabaseRedisRepo.KeyTTLFunc: method is nil but DatabaseRedisRepo.KeyTTL was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseRedisKeyTTL + }{ + Ctx: ctx, + Req: req, + } + mock.lockKeyTTL.Lock() + mock.calls.KeyTTL = append(mock.calls.KeyTTL, callInfo) + mock.lockKeyTTL.Unlock() + return mock.KeyTTLFunc(ctx, req) +} + +// KeyTTLCalls gets all the calls that were made to KeyTTL. +// Check the length with: +// +// len(mockedDatabaseRedisRepo.KeyTTLCalls()) +func (mock *DatabaseRedisRepo) KeyTTLCalls() []struct { + Ctx context.Context + Req *request.DatabaseRedisKeyTTL +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseRedisKeyTTL + } + mock.lockKeyTTL.RLock() + calls = mock.calls.KeyTTL + mock.lockKeyTTL.RUnlock() + return calls +} diff --git a/internal/mocks/biz/DatabaseRepo.go b/internal/mocks/biz/DatabaseRepo.go new file mode 100644 index 000000000..b7450f878 --- /dev/null +++ b/internal/mocks/biz/DatabaseRepo.go @@ -0,0 +1,229 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "context" + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/pkg/db" +) + +// Ensure that DatabaseRepo does implement biz.DatabaseRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.DatabaseRepo = &DatabaseRepo{} + +// DatabaseRepo is a mock implementation of biz.DatabaseRepo. +// +// func TestSomethingThatUsesDatabaseRepo(t *testing.T) { +// +// // make and configure a mocked biz.DatabaseRepo +// mockedDatabaseRepo := &DatabaseRepo{ +// DatabasesOfFunc: func(ctx context.Context, server *biz.DatabaseServer) ([]*biz.Database, error) { +// panic("mock out the DatabasesOf method") +// }, +// ListServersFunc: func(typ string) ([]*biz.DatabaseServer, error) { +// panic("mock out the ListServers method") +// }, +// MongoFunc: func(ctx context.Context, server *biz.DatabaseServer) (*db.MongoDB, error) { +// panic("mock out the Mongo method") +// }, +// OperatorFunc: func(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) { +// panic("mock out the Operator method") +// }, +// } +// +// // use mockedDatabaseRepo in code that requires biz.DatabaseRepo +// // and then make assertions. +// +// } +type DatabaseRepo struct { + // DatabasesOfFunc mocks the DatabasesOf method. + DatabasesOfFunc func(ctx context.Context, server *biz.DatabaseServer) ([]*biz.Database, error) + + // ListServersFunc mocks the ListServers method. + ListServersFunc func(typ string) ([]*biz.DatabaseServer, error) + + // MongoFunc mocks the Mongo method. + MongoFunc func(ctx context.Context, server *biz.DatabaseServer) (*db.MongoDB, error) + + // OperatorFunc mocks the Operator method. + OperatorFunc func(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) + + // calls tracks calls to the methods. + calls struct { + // DatabasesOf holds details about calls to the DatabasesOf method. + DatabasesOf []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Server is the server argument value. + Server *biz.DatabaseServer + } + // ListServers holds details about calls to the ListServers method. + ListServers []struct { + // Typ is the typ argument value. + Typ string + } + // Mongo holds details about calls to the Mongo method. + Mongo []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Server is the server argument value. + Server *biz.DatabaseServer + } + // Operator holds details about calls to the Operator method. + Operator []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Server is the server argument value. + Server *biz.DatabaseServer + } + } + lockDatabasesOf sync.RWMutex + lockListServers sync.RWMutex + lockMongo sync.RWMutex + lockOperator sync.RWMutex +} + +// DatabasesOf calls DatabasesOfFunc. +func (mock *DatabaseRepo) DatabasesOf(ctx context.Context, server *biz.DatabaseServer) ([]*biz.Database, error) { + if mock.DatabasesOfFunc == nil { + panic("DatabaseRepo.DatabasesOfFunc: method is nil but DatabaseRepo.DatabasesOf was just called") + } + callInfo := struct { + Ctx context.Context + Server *biz.DatabaseServer + }{ + Ctx: ctx, + Server: server, + } + mock.lockDatabasesOf.Lock() + mock.calls.DatabasesOf = append(mock.calls.DatabasesOf, callInfo) + mock.lockDatabasesOf.Unlock() + return mock.DatabasesOfFunc(ctx, server) +} + +// DatabasesOfCalls gets all the calls that were made to DatabasesOf. +// Check the length with: +// +// len(mockedDatabaseRepo.DatabasesOfCalls()) +func (mock *DatabaseRepo) DatabasesOfCalls() []struct { + Ctx context.Context + Server *biz.DatabaseServer +} { + var calls []struct { + Ctx context.Context + Server *biz.DatabaseServer + } + mock.lockDatabasesOf.RLock() + calls = mock.calls.DatabasesOf + mock.lockDatabasesOf.RUnlock() + return calls +} + +// ListServers calls ListServersFunc. +func (mock *DatabaseRepo) ListServers(typ string) ([]*biz.DatabaseServer, error) { + if mock.ListServersFunc == nil { + panic("DatabaseRepo.ListServersFunc: method is nil but DatabaseRepo.ListServers was just called") + } + callInfo := struct { + Typ string + }{ + Typ: typ, + } + mock.lockListServers.Lock() + mock.calls.ListServers = append(mock.calls.ListServers, callInfo) + mock.lockListServers.Unlock() + return mock.ListServersFunc(typ) +} + +// ListServersCalls gets all the calls that were made to ListServers. +// Check the length with: +// +// len(mockedDatabaseRepo.ListServersCalls()) +func (mock *DatabaseRepo) ListServersCalls() []struct { + Typ string +} { + var calls []struct { + Typ string + } + mock.lockListServers.RLock() + calls = mock.calls.ListServers + mock.lockListServers.RUnlock() + return calls +} + +// Mongo calls MongoFunc. +func (mock *DatabaseRepo) Mongo(ctx context.Context, server *biz.DatabaseServer) (*db.MongoDB, error) { + if mock.MongoFunc == nil { + panic("DatabaseRepo.MongoFunc: method is nil but DatabaseRepo.Mongo was just called") + } + callInfo := struct { + Ctx context.Context + Server *biz.DatabaseServer + }{ + Ctx: ctx, + Server: server, + } + mock.lockMongo.Lock() + mock.calls.Mongo = append(mock.calls.Mongo, callInfo) + mock.lockMongo.Unlock() + return mock.MongoFunc(ctx, server) +} + +// MongoCalls gets all the calls that were made to Mongo. +// Check the length with: +// +// len(mockedDatabaseRepo.MongoCalls()) +func (mock *DatabaseRepo) MongoCalls() []struct { + Ctx context.Context + Server *biz.DatabaseServer +} { + var calls []struct { + Ctx context.Context + Server *biz.DatabaseServer + } + mock.lockMongo.RLock() + calls = mock.calls.Mongo + mock.lockMongo.RUnlock() + return calls +} + +// Operator calls OperatorFunc. +func (mock *DatabaseRepo) Operator(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) { + if mock.OperatorFunc == nil { + panic("DatabaseRepo.OperatorFunc: method is nil but DatabaseRepo.Operator was just called") + } + callInfo := struct { + Ctx context.Context + Server *biz.DatabaseServer + }{ + Ctx: ctx, + Server: server, + } + mock.lockOperator.Lock() + mock.calls.Operator = append(mock.calls.Operator, callInfo) + mock.lockOperator.Unlock() + return mock.OperatorFunc(ctx, server) +} + +// OperatorCalls gets all the calls that were made to Operator. +// Check the length with: +// +// len(mockedDatabaseRepo.OperatorCalls()) +func (mock *DatabaseRepo) OperatorCalls() []struct { + Ctx context.Context + Server *biz.DatabaseServer +} { + var calls []struct { + Ctx context.Context + Server *biz.DatabaseServer + } + mock.lockOperator.RLock() + calls = mock.calls.Operator + mock.lockOperator.RUnlock() + return calls +} diff --git a/internal/mocks/biz/DatabaseServerRepo.go b/internal/mocks/biz/DatabaseServerRepo.go new file mode 100644 index 000000000..bbad85d37 --- /dev/null +++ b/internal/mocks/biz/DatabaseServerRepo.go @@ -0,0 +1,743 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "context" + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/db" +) + +// Ensure that DatabaseServerRepo does implement biz.DatabaseServerRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.DatabaseServerRepo = &DatabaseServerRepo{} + +// DatabaseServerRepo is a mock implementation of biz.DatabaseServerRepo. +// +// func TestSomethingThatUsesDatabaseServerRepo(t *testing.T) { +// +// // make and configure a mocked biz.DatabaseServerRepo +// mockedDatabaseServerRepo := &DatabaseServerRepo{ +// CheckServerFunc: func(ctx context.Context, server *biz.DatabaseServer) bool { +// panic("mock out the CheckServer method") +// }, +// ClearUsersFunc: func(id uint) error { +// panic("mock out the ClearUsers method") +// }, +// CountFunc: func() (int64, error) { +// panic("mock out the Count method") +// }, +// CreateFunc: func(server *biz.DatabaseServer) error { +// panic("mock out the Create method") +// }, +// CreateUserFunc: func(user *biz.DatabaseUser) error { +// panic("mock out the CreateUser method") +// }, +// DeleteFunc: func(id uint) error { +// panic("mock out the Delete method") +// }, +// GetFunc: func(ctx context.Context, id uint) (*biz.DatabaseServer, error) { +// panic("mock out the Get method") +// }, +// GetByNameFunc: func(ctx context.Context, name string) (*biz.DatabaseServer, error) { +// panic("mock out the GetByName method") +// }, +// ListFunc: func(ctx context.Context, page uint, limit uint, typ string) ([]*biz.DatabaseServer, int64, error) { +// panic("mock out the List method") +// }, +// ListUsersFunc: func(serverID uint) ([]*biz.DatabaseUser, error) { +// panic("mock out the ListUsers method") +// }, +// OperatorFunc: func(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) { +// panic("mock out the Operator method") +// }, +// SaveFunc: func(server *biz.DatabaseServer) error { +// panic("mock out the Save method") +// }, +// UpdatePasswordFunc: func(name string, password string) error { +// panic("mock out the UpdatePassword method") +// }, +// UpdatePortFunc: func(name string, port uint) error { +// panic("mock out the UpdatePort method") +// }, +// UpdateRemarkFunc: func(req *request.DatabaseServerUpdateRemark) error { +// panic("mock out the UpdateRemark method") +// }, +// } +// +// // use mockedDatabaseServerRepo in code that requires biz.DatabaseServerRepo +// // and then make assertions. +// +// } +type DatabaseServerRepo struct { + // CheckServerFunc mocks the CheckServer method. + CheckServerFunc func(ctx context.Context, server *biz.DatabaseServer) bool + + // ClearUsersFunc mocks the ClearUsers method. + ClearUsersFunc func(id uint) error + + // CountFunc mocks the Count method. + CountFunc func() (int64, error) + + // CreateFunc mocks the Create method. + CreateFunc func(server *biz.DatabaseServer) error + + // CreateUserFunc mocks the CreateUser method. + CreateUserFunc func(user *biz.DatabaseUser) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) error + + // GetFunc mocks the Get method. + GetFunc func(ctx context.Context, id uint) (*biz.DatabaseServer, error) + + // GetByNameFunc mocks the GetByName method. + GetByNameFunc func(ctx context.Context, name string) (*biz.DatabaseServer, error) + + // ListFunc mocks the List method. + ListFunc func(ctx context.Context, page uint, limit uint, typ string) ([]*biz.DatabaseServer, int64, error) + + // ListUsersFunc mocks the ListUsers method. + ListUsersFunc func(serverID uint) ([]*biz.DatabaseUser, error) + + // OperatorFunc mocks the Operator method. + OperatorFunc func(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) + + // SaveFunc mocks the Save method. + SaveFunc func(server *biz.DatabaseServer) error + + // UpdatePasswordFunc mocks the UpdatePassword method. + UpdatePasswordFunc func(name string, password string) error + + // UpdatePortFunc mocks the UpdatePort method. + UpdatePortFunc func(name string, port uint) error + + // UpdateRemarkFunc mocks the UpdateRemark method. + UpdateRemarkFunc func(req *request.DatabaseServerUpdateRemark) error + + // calls tracks calls to the methods. + calls struct { + // CheckServer holds details about calls to the CheckServer method. + CheckServer []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Server is the server argument value. + Server *biz.DatabaseServer + } + // ClearUsers holds details about calls to the ClearUsers method. + ClearUsers []struct { + // ID is the id argument value. + ID uint + } + // Count holds details about calls to the Count method. + Count []struct { + } + // Create holds details about calls to the Create method. + Create []struct { + // Server is the server argument value. + Server *biz.DatabaseServer + } + // CreateUser holds details about calls to the CreateUser method. + CreateUser []struct { + // User is the user argument value. + User *biz.DatabaseUser + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // Get holds details about calls to the Get method. + Get []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // ID is the id argument value. + ID uint + } + // GetByName holds details about calls to the GetByName method. + GetByName []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Name is the name argument value. + Name string + } + // List holds details about calls to the List method. + List []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + // Typ is the typ argument value. + Typ string + } + // ListUsers holds details about calls to the ListUsers method. + ListUsers []struct { + // ServerID is the serverID argument value. + ServerID uint + } + // Operator holds details about calls to the Operator method. + Operator []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Server is the server argument value. + Server *biz.DatabaseServer + } + // Save holds details about calls to the Save method. + Save []struct { + // Server is the server argument value. + Server *biz.DatabaseServer + } + // UpdatePassword holds details about calls to the UpdatePassword method. + UpdatePassword []struct { + // Name is the name argument value. + Name string + // Password is the password argument value. + Password string + } + // UpdatePort holds details about calls to the UpdatePort method. + UpdatePort []struct { + // Name is the name argument value. + Name string + // Port is the port argument value. + Port uint + } + // UpdateRemark holds details about calls to the UpdateRemark method. + UpdateRemark []struct { + // Req is the req argument value. + Req *request.DatabaseServerUpdateRemark + } + } + lockCheckServer sync.RWMutex + lockClearUsers sync.RWMutex + lockCount sync.RWMutex + lockCreate sync.RWMutex + lockCreateUser sync.RWMutex + lockDelete sync.RWMutex + lockGet sync.RWMutex + lockGetByName sync.RWMutex + lockList sync.RWMutex + lockListUsers sync.RWMutex + lockOperator sync.RWMutex + lockSave sync.RWMutex + lockUpdatePassword sync.RWMutex + lockUpdatePort sync.RWMutex + lockUpdateRemark sync.RWMutex +} + +// CheckServer calls CheckServerFunc. +func (mock *DatabaseServerRepo) CheckServer(ctx context.Context, server *biz.DatabaseServer) bool { + if mock.CheckServerFunc == nil { + panic("DatabaseServerRepo.CheckServerFunc: method is nil but DatabaseServerRepo.CheckServer was just called") + } + callInfo := struct { + Ctx context.Context + Server *biz.DatabaseServer + }{ + Ctx: ctx, + Server: server, + } + mock.lockCheckServer.Lock() + mock.calls.CheckServer = append(mock.calls.CheckServer, callInfo) + mock.lockCheckServer.Unlock() + return mock.CheckServerFunc(ctx, server) +} + +// CheckServerCalls gets all the calls that were made to CheckServer. +// Check the length with: +// +// len(mockedDatabaseServerRepo.CheckServerCalls()) +func (mock *DatabaseServerRepo) CheckServerCalls() []struct { + Ctx context.Context + Server *biz.DatabaseServer +} { + var calls []struct { + Ctx context.Context + Server *biz.DatabaseServer + } + mock.lockCheckServer.RLock() + calls = mock.calls.CheckServer + mock.lockCheckServer.RUnlock() + return calls +} + +// ClearUsers calls ClearUsersFunc. +func (mock *DatabaseServerRepo) ClearUsers(id uint) error { + if mock.ClearUsersFunc == nil { + panic("DatabaseServerRepo.ClearUsersFunc: method is nil but DatabaseServerRepo.ClearUsers was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockClearUsers.Lock() + mock.calls.ClearUsers = append(mock.calls.ClearUsers, callInfo) + mock.lockClearUsers.Unlock() + return mock.ClearUsersFunc(id) +} + +// ClearUsersCalls gets all the calls that were made to ClearUsers. +// Check the length with: +// +// len(mockedDatabaseServerRepo.ClearUsersCalls()) +func (mock *DatabaseServerRepo) ClearUsersCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockClearUsers.RLock() + calls = mock.calls.ClearUsers + mock.lockClearUsers.RUnlock() + return calls +} + +// Count calls CountFunc. +func (mock *DatabaseServerRepo) Count() (int64, error) { + if mock.CountFunc == nil { + panic("DatabaseServerRepo.CountFunc: method is nil but DatabaseServerRepo.Count was just called") + } + callInfo := struct { + }{} + mock.lockCount.Lock() + mock.calls.Count = append(mock.calls.Count, callInfo) + mock.lockCount.Unlock() + return mock.CountFunc() +} + +// CountCalls gets all the calls that were made to Count. +// Check the length with: +// +// len(mockedDatabaseServerRepo.CountCalls()) +func (mock *DatabaseServerRepo) CountCalls() []struct { +} { + var calls []struct { + } + mock.lockCount.RLock() + calls = mock.calls.Count + mock.lockCount.RUnlock() + return calls +} + +// Create calls CreateFunc. +func (mock *DatabaseServerRepo) Create(server *biz.DatabaseServer) error { + if mock.CreateFunc == nil { + panic("DatabaseServerRepo.CreateFunc: method is nil but DatabaseServerRepo.Create was just called") + } + callInfo := struct { + Server *biz.DatabaseServer + }{ + Server: server, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(server) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedDatabaseServerRepo.CreateCalls()) +func (mock *DatabaseServerRepo) CreateCalls() []struct { + Server *biz.DatabaseServer +} { + var calls []struct { + Server *biz.DatabaseServer + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// CreateUser calls CreateUserFunc. +func (mock *DatabaseServerRepo) CreateUser(user *biz.DatabaseUser) error { + if mock.CreateUserFunc == nil { + panic("DatabaseServerRepo.CreateUserFunc: method is nil but DatabaseServerRepo.CreateUser was just called") + } + callInfo := struct { + User *biz.DatabaseUser + }{ + User: user, + } + mock.lockCreateUser.Lock() + mock.calls.CreateUser = append(mock.calls.CreateUser, callInfo) + mock.lockCreateUser.Unlock() + return mock.CreateUserFunc(user) +} + +// CreateUserCalls gets all the calls that were made to CreateUser. +// Check the length with: +// +// len(mockedDatabaseServerRepo.CreateUserCalls()) +func (mock *DatabaseServerRepo) CreateUserCalls() []struct { + User *biz.DatabaseUser +} { + var calls []struct { + User *biz.DatabaseUser + } + mock.lockCreateUser.RLock() + calls = mock.calls.CreateUser + mock.lockCreateUser.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *DatabaseServerRepo) Delete(id uint) error { + if mock.DeleteFunc == nil { + panic("DatabaseServerRepo.DeleteFunc: method is nil but DatabaseServerRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedDatabaseServerRepo.DeleteCalls()) +func (mock *DatabaseServerRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *DatabaseServerRepo) Get(ctx context.Context, id uint) (*biz.DatabaseServer, error) { + if mock.GetFunc == nil { + panic("DatabaseServerRepo.GetFunc: method is nil but DatabaseServerRepo.Get was just called") + } + callInfo := struct { + Ctx context.Context + ID uint + }{ + Ctx: ctx, + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(ctx, id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedDatabaseServerRepo.GetCalls()) +func (mock *DatabaseServerRepo) GetCalls() []struct { + Ctx context.Context + ID uint +} { + var calls []struct { + Ctx context.Context + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// GetByName calls GetByNameFunc. +func (mock *DatabaseServerRepo) GetByName(ctx context.Context, name string) (*biz.DatabaseServer, error) { + if mock.GetByNameFunc == nil { + panic("DatabaseServerRepo.GetByNameFunc: method is nil but DatabaseServerRepo.GetByName was just called") + } + callInfo := struct { + Ctx context.Context + Name string + }{ + Ctx: ctx, + Name: name, + } + mock.lockGetByName.Lock() + mock.calls.GetByName = append(mock.calls.GetByName, callInfo) + mock.lockGetByName.Unlock() + return mock.GetByNameFunc(ctx, name) +} + +// GetByNameCalls gets all the calls that were made to GetByName. +// Check the length with: +// +// len(mockedDatabaseServerRepo.GetByNameCalls()) +func (mock *DatabaseServerRepo) GetByNameCalls() []struct { + Ctx context.Context + Name string +} { + var calls []struct { + Ctx context.Context + Name string + } + mock.lockGetByName.RLock() + calls = mock.calls.GetByName + mock.lockGetByName.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *DatabaseServerRepo) List(ctx context.Context, page uint, limit uint, typ string) ([]*biz.DatabaseServer, int64, error) { + if mock.ListFunc == nil { + panic("DatabaseServerRepo.ListFunc: method is nil but DatabaseServerRepo.List was just called") + } + callInfo := struct { + Ctx context.Context + Page uint + Limit uint + Typ string + }{ + Ctx: ctx, + Page: page, + Limit: limit, + Typ: typ, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(ctx, page, limit, typ) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedDatabaseServerRepo.ListCalls()) +func (mock *DatabaseServerRepo) ListCalls() []struct { + Ctx context.Context + Page uint + Limit uint + Typ string +} { + var calls []struct { + Ctx context.Context + Page uint + Limit uint + Typ string + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// ListUsers calls ListUsersFunc. +func (mock *DatabaseServerRepo) ListUsers(serverID uint) ([]*biz.DatabaseUser, error) { + if mock.ListUsersFunc == nil { + panic("DatabaseServerRepo.ListUsersFunc: method is nil but DatabaseServerRepo.ListUsers was just called") + } + callInfo := struct { + ServerID uint + }{ + ServerID: serverID, + } + mock.lockListUsers.Lock() + mock.calls.ListUsers = append(mock.calls.ListUsers, callInfo) + mock.lockListUsers.Unlock() + return mock.ListUsersFunc(serverID) +} + +// ListUsersCalls gets all the calls that were made to ListUsers. +// Check the length with: +// +// len(mockedDatabaseServerRepo.ListUsersCalls()) +func (mock *DatabaseServerRepo) ListUsersCalls() []struct { + ServerID uint +} { + var calls []struct { + ServerID uint + } + mock.lockListUsers.RLock() + calls = mock.calls.ListUsers + mock.lockListUsers.RUnlock() + return calls +} + +// Operator calls OperatorFunc. +func (mock *DatabaseServerRepo) Operator(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) { + if mock.OperatorFunc == nil { + panic("DatabaseServerRepo.OperatorFunc: method is nil but DatabaseServerRepo.Operator was just called") + } + callInfo := struct { + Ctx context.Context + Server *biz.DatabaseServer + }{ + Ctx: ctx, + Server: server, + } + mock.lockOperator.Lock() + mock.calls.Operator = append(mock.calls.Operator, callInfo) + mock.lockOperator.Unlock() + return mock.OperatorFunc(ctx, server) +} + +// OperatorCalls gets all the calls that were made to Operator. +// Check the length with: +// +// len(mockedDatabaseServerRepo.OperatorCalls()) +func (mock *DatabaseServerRepo) OperatorCalls() []struct { + Ctx context.Context + Server *biz.DatabaseServer +} { + var calls []struct { + Ctx context.Context + Server *biz.DatabaseServer + } + mock.lockOperator.RLock() + calls = mock.calls.Operator + mock.lockOperator.RUnlock() + return calls +} + +// Save calls SaveFunc. +func (mock *DatabaseServerRepo) Save(server *biz.DatabaseServer) error { + if mock.SaveFunc == nil { + panic("DatabaseServerRepo.SaveFunc: method is nil but DatabaseServerRepo.Save was just called") + } + callInfo := struct { + Server *biz.DatabaseServer + }{ + Server: server, + } + mock.lockSave.Lock() + mock.calls.Save = append(mock.calls.Save, callInfo) + mock.lockSave.Unlock() + return mock.SaveFunc(server) +} + +// SaveCalls gets all the calls that were made to Save. +// Check the length with: +// +// len(mockedDatabaseServerRepo.SaveCalls()) +func (mock *DatabaseServerRepo) SaveCalls() []struct { + Server *biz.DatabaseServer +} { + var calls []struct { + Server *biz.DatabaseServer + } + mock.lockSave.RLock() + calls = mock.calls.Save + mock.lockSave.RUnlock() + return calls +} + +// UpdatePassword calls UpdatePasswordFunc. +func (mock *DatabaseServerRepo) UpdatePassword(name string, password string) error { + if mock.UpdatePasswordFunc == nil { + panic("DatabaseServerRepo.UpdatePasswordFunc: method is nil but DatabaseServerRepo.UpdatePassword was just called") + } + callInfo := struct { + Name string + Password string + }{ + Name: name, + Password: password, + } + mock.lockUpdatePassword.Lock() + mock.calls.UpdatePassword = append(mock.calls.UpdatePassword, callInfo) + mock.lockUpdatePassword.Unlock() + return mock.UpdatePasswordFunc(name, password) +} + +// UpdatePasswordCalls gets all the calls that were made to UpdatePassword. +// Check the length with: +// +// len(mockedDatabaseServerRepo.UpdatePasswordCalls()) +func (mock *DatabaseServerRepo) UpdatePasswordCalls() []struct { + Name string + Password string +} { + var calls []struct { + Name string + Password string + } + mock.lockUpdatePassword.RLock() + calls = mock.calls.UpdatePassword + mock.lockUpdatePassword.RUnlock() + return calls +} + +// UpdatePort calls UpdatePortFunc. +func (mock *DatabaseServerRepo) UpdatePort(name string, port uint) error { + if mock.UpdatePortFunc == nil { + panic("DatabaseServerRepo.UpdatePortFunc: method is nil but DatabaseServerRepo.UpdatePort was just called") + } + callInfo := struct { + Name string + Port uint + }{ + Name: name, + Port: port, + } + mock.lockUpdatePort.Lock() + mock.calls.UpdatePort = append(mock.calls.UpdatePort, callInfo) + mock.lockUpdatePort.Unlock() + return mock.UpdatePortFunc(name, port) +} + +// UpdatePortCalls gets all the calls that were made to UpdatePort. +// Check the length with: +// +// len(mockedDatabaseServerRepo.UpdatePortCalls()) +func (mock *DatabaseServerRepo) UpdatePortCalls() []struct { + Name string + Port uint +} { + var calls []struct { + Name string + Port uint + } + mock.lockUpdatePort.RLock() + calls = mock.calls.UpdatePort + mock.lockUpdatePort.RUnlock() + return calls +} + +// UpdateRemark calls UpdateRemarkFunc. +func (mock *DatabaseServerRepo) UpdateRemark(req *request.DatabaseServerUpdateRemark) error { + if mock.UpdateRemarkFunc == nil { + panic("DatabaseServerRepo.UpdateRemarkFunc: method is nil but DatabaseServerRepo.UpdateRemark was just called") + } + callInfo := struct { + Req *request.DatabaseServerUpdateRemark + }{ + Req: req, + } + mock.lockUpdateRemark.Lock() + mock.calls.UpdateRemark = append(mock.calls.UpdateRemark, callInfo) + mock.lockUpdateRemark.Unlock() + return mock.UpdateRemarkFunc(req) +} + +// UpdateRemarkCalls gets all the calls that were made to UpdateRemark. +// Check the length with: +// +// len(mockedDatabaseServerRepo.UpdateRemarkCalls()) +func (mock *DatabaseServerRepo) UpdateRemarkCalls() []struct { + Req *request.DatabaseServerUpdateRemark +} { + var calls []struct { + Req *request.DatabaseServerUpdateRemark + } + mock.lockUpdateRemark.RLock() + calls = mock.calls.UpdateRemark + mock.lockUpdateRemark.RUnlock() + return calls +} diff --git a/internal/mocks/biz/DatabaseUserRepo.go b/internal/mocks/biz/DatabaseUserRepo.go new file mode 100644 index 000000000..0eceb7b09 --- /dev/null +++ b/internal/mocks/biz/DatabaseUserRepo.go @@ -0,0 +1,517 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "context" + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/db" +) + +// Ensure that DatabaseUserRepo does implement biz.DatabaseUserRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.DatabaseUserRepo = &DatabaseUserRepo{} + +// DatabaseUserRepo is a mock implementation of biz.DatabaseUserRepo. +// +// func TestSomethingThatUsesDatabaseUserRepo(t *testing.T) { +// +// // make and configure a mocked biz.DatabaseUserRepo +// mockedDatabaseUserRepo := &DatabaseUserRepo{ +// CountFunc: func() (int64, error) { +// panic("mock out the Count method") +// }, +// DeleteByIDFunc: func(id uint) error { +// panic("mock out the DeleteByID method") +// }, +// DeleteByServerNamesFunc: func(serverID uint, names []string) error { +// panic("mock out the DeleteByServerNames method") +// }, +// GetFunc: func(ctx context.Context, id uint) (*biz.DatabaseUser, error) { +// panic("mock out the Get method") +// }, +// ListFunc: func(ctx context.Context, page uint, limit uint, typ string) ([]*biz.DatabaseUser, int64, error) { +// panic("mock out the List method") +// }, +// ListByNamesFunc: func(serverID uint, names []string) ([]*biz.DatabaseUser, error) { +// panic("mock out the ListByNames method") +// }, +// OperatorFunc: func(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) { +// panic("mock out the Operator method") +// }, +// SaveFunc: func(user *biz.DatabaseUser) error { +// panic("mock out the Save method") +// }, +// UpdateRemarkFunc: func(ctx context.Context, req *request.DatabaseUserUpdateRemark) error { +// panic("mock out the UpdateRemark method") +// }, +// UpsertFunc: func(user *biz.DatabaseUser) error { +// panic("mock out the Upsert method") +// }, +// } +// +// // use mockedDatabaseUserRepo in code that requires biz.DatabaseUserRepo +// // and then make assertions. +// +// } +type DatabaseUserRepo struct { + // CountFunc mocks the Count method. + CountFunc func() (int64, error) + + // DeleteByIDFunc mocks the DeleteByID method. + DeleteByIDFunc func(id uint) error + + // DeleteByServerNamesFunc mocks the DeleteByServerNames method. + DeleteByServerNamesFunc func(serverID uint, names []string) error + + // GetFunc mocks the Get method. + GetFunc func(ctx context.Context, id uint) (*biz.DatabaseUser, error) + + // ListFunc mocks the List method. + ListFunc func(ctx context.Context, page uint, limit uint, typ string) ([]*biz.DatabaseUser, int64, error) + + // ListByNamesFunc mocks the ListByNames method. + ListByNamesFunc func(serverID uint, names []string) ([]*biz.DatabaseUser, error) + + // OperatorFunc mocks the Operator method. + OperatorFunc func(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) + + // SaveFunc mocks the Save method. + SaveFunc func(user *biz.DatabaseUser) error + + // UpdateRemarkFunc mocks the UpdateRemark method. + UpdateRemarkFunc func(ctx context.Context, req *request.DatabaseUserUpdateRemark) error + + // UpsertFunc mocks the Upsert method. + UpsertFunc func(user *biz.DatabaseUser) error + + // calls tracks calls to the methods. + calls struct { + // Count holds details about calls to the Count method. + Count []struct { + } + // DeleteByID holds details about calls to the DeleteByID method. + DeleteByID []struct { + // ID is the id argument value. + ID uint + } + // DeleteByServerNames holds details about calls to the DeleteByServerNames method. + DeleteByServerNames []struct { + // ServerID is the serverID argument value. + ServerID uint + // Names is the names argument value. + Names []string + } + // Get holds details about calls to the Get method. + Get []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // ID is the id argument value. + ID uint + } + // List holds details about calls to the List method. + List []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + // Typ is the typ argument value. + Typ string + } + // ListByNames holds details about calls to the ListByNames method. + ListByNames []struct { + // ServerID is the serverID argument value. + ServerID uint + // Names is the names argument value. + Names []string + } + // Operator holds details about calls to the Operator method. + Operator []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Server is the server argument value. + Server *biz.DatabaseServer + } + // Save holds details about calls to the Save method. + Save []struct { + // User is the user argument value. + User *biz.DatabaseUser + } + // UpdateRemark holds details about calls to the UpdateRemark method. + UpdateRemark []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Req is the req argument value. + Req *request.DatabaseUserUpdateRemark + } + // Upsert holds details about calls to the Upsert method. + Upsert []struct { + // User is the user argument value. + User *biz.DatabaseUser + } + } + lockCount sync.RWMutex + lockDeleteByID sync.RWMutex + lockDeleteByServerNames sync.RWMutex + lockGet sync.RWMutex + lockList sync.RWMutex + lockListByNames sync.RWMutex + lockOperator sync.RWMutex + lockSave sync.RWMutex + lockUpdateRemark sync.RWMutex + lockUpsert sync.RWMutex +} + +// Count calls CountFunc. +func (mock *DatabaseUserRepo) Count() (int64, error) { + if mock.CountFunc == nil { + panic("DatabaseUserRepo.CountFunc: method is nil but DatabaseUserRepo.Count was just called") + } + callInfo := struct { + }{} + mock.lockCount.Lock() + mock.calls.Count = append(mock.calls.Count, callInfo) + mock.lockCount.Unlock() + return mock.CountFunc() +} + +// CountCalls gets all the calls that were made to Count. +// Check the length with: +// +// len(mockedDatabaseUserRepo.CountCalls()) +func (mock *DatabaseUserRepo) CountCalls() []struct { +} { + var calls []struct { + } + mock.lockCount.RLock() + calls = mock.calls.Count + mock.lockCount.RUnlock() + return calls +} + +// DeleteByID calls DeleteByIDFunc. +func (mock *DatabaseUserRepo) DeleteByID(id uint) error { + if mock.DeleteByIDFunc == nil { + panic("DatabaseUserRepo.DeleteByIDFunc: method is nil but DatabaseUserRepo.DeleteByID was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDeleteByID.Lock() + mock.calls.DeleteByID = append(mock.calls.DeleteByID, callInfo) + mock.lockDeleteByID.Unlock() + return mock.DeleteByIDFunc(id) +} + +// DeleteByIDCalls gets all the calls that were made to DeleteByID. +// Check the length with: +// +// len(mockedDatabaseUserRepo.DeleteByIDCalls()) +func (mock *DatabaseUserRepo) DeleteByIDCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDeleteByID.RLock() + calls = mock.calls.DeleteByID + mock.lockDeleteByID.RUnlock() + return calls +} + +// DeleteByServerNames calls DeleteByServerNamesFunc. +func (mock *DatabaseUserRepo) DeleteByServerNames(serverID uint, names []string) error { + if mock.DeleteByServerNamesFunc == nil { + panic("DatabaseUserRepo.DeleteByServerNamesFunc: method is nil but DatabaseUserRepo.DeleteByServerNames was just called") + } + callInfo := struct { + ServerID uint + Names []string + }{ + ServerID: serverID, + Names: names, + } + mock.lockDeleteByServerNames.Lock() + mock.calls.DeleteByServerNames = append(mock.calls.DeleteByServerNames, callInfo) + mock.lockDeleteByServerNames.Unlock() + return mock.DeleteByServerNamesFunc(serverID, names) +} + +// DeleteByServerNamesCalls gets all the calls that were made to DeleteByServerNames. +// Check the length with: +// +// len(mockedDatabaseUserRepo.DeleteByServerNamesCalls()) +func (mock *DatabaseUserRepo) DeleteByServerNamesCalls() []struct { + ServerID uint + Names []string +} { + var calls []struct { + ServerID uint + Names []string + } + mock.lockDeleteByServerNames.RLock() + calls = mock.calls.DeleteByServerNames + mock.lockDeleteByServerNames.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *DatabaseUserRepo) Get(ctx context.Context, id uint) (*biz.DatabaseUser, error) { + if mock.GetFunc == nil { + panic("DatabaseUserRepo.GetFunc: method is nil but DatabaseUserRepo.Get was just called") + } + callInfo := struct { + Ctx context.Context + ID uint + }{ + Ctx: ctx, + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(ctx, id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedDatabaseUserRepo.GetCalls()) +func (mock *DatabaseUserRepo) GetCalls() []struct { + Ctx context.Context + ID uint +} { + var calls []struct { + Ctx context.Context + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *DatabaseUserRepo) List(ctx context.Context, page uint, limit uint, typ string) ([]*biz.DatabaseUser, int64, error) { + if mock.ListFunc == nil { + panic("DatabaseUserRepo.ListFunc: method is nil but DatabaseUserRepo.List was just called") + } + callInfo := struct { + Ctx context.Context + Page uint + Limit uint + Typ string + }{ + Ctx: ctx, + Page: page, + Limit: limit, + Typ: typ, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(ctx, page, limit, typ) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedDatabaseUserRepo.ListCalls()) +func (mock *DatabaseUserRepo) ListCalls() []struct { + Ctx context.Context + Page uint + Limit uint + Typ string +} { + var calls []struct { + Ctx context.Context + Page uint + Limit uint + Typ string + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// ListByNames calls ListByNamesFunc. +func (mock *DatabaseUserRepo) ListByNames(serverID uint, names []string) ([]*biz.DatabaseUser, error) { + if mock.ListByNamesFunc == nil { + panic("DatabaseUserRepo.ListByNamesFunc: method is nil but DatabaseUserRepo.ListByNames was just called") + } + callInfo := struct { + ServerID uint + Names []string + }{ + ServerID: serverID, + Names: names, + } + mock.lockListByNames.Lock() + mock.calls.ListByNames = append(mock.calls.ListByNames, callInfo) + mock.lockListByNames.Unlock() + return mock.ListByNamesFunc(serverID, names) +} + +// ListByNamesCalls gets all the calls that were made to ListByNames. +// Check the length with: +// +// len(mockedDatabaseUserRepo.ListByNamesCalls()) +func (mock *DatabaseUserRepo) ListByNamesCalls() []struct { + ServerID uint + Names []string +} { + var calls []struct { + ServerID uint + Names []string + } + mock.lockListByNames.RLock() + calls = mock.calls.ListByNames + mock.lockListByNames.RUnlock() + return calls +} + +// Operator calls OperatorFunc. +func (mock *DatabaseUserRepo) Operator(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) { + if mock.OperatorFunc == nil { + panic("DatabaseUserRepo.OperatorFunc: method is nil but DatabaseUserRepo.Operator was just called") + } + callInfo := struct { + Ctx context.Context + Server *biz.DatabaseServer + }{ + Ctx: ctx, + Server: server, + } + mock.lockOperator.Lock() + mock.calls.Operator = append(mock.calls.Operator, callInfo) + mock.lockOperator.Unlock() + return mock.OperatorFunc(ctx, server) +} + +// OperatorCalls gets all the calls that were made to Operator. +// Check the length with: +// +// len(mockedDatabaseUserRepo.OperatorCalls()) +func (mock *DatabaseUserRepo) OperatorCalls() []struct { + Ctx context.Context + Server *biz.DatabaseServer +} { + var calls []struct { + Ctx context.Context + Server *biz.DatabaseServer + } + mock.lockOperator.RLock() + calls = mock.calls.Operator + mock.lockOperator.RUnlock() + return calls +} + +// Save calls SaveFunc. +func (mock *DatabaseUserRepo) Save(user *biz.DatabaseUser) error { + if mock.SaveFunc == nil { + panic("DatabaseUserRepo.SaveFunc: method is nil but DatabaseUserRepo.Save was just called") + } + callInfo := struct { + User *biz.DatabaseUser + }{ + User: user, + } + mock.lockSave.Lock() + mock.calls.Save = append(mock.calls.Save, callInfo) + mock.lockSave.Unlock() + return mock.SaveFunc(user) +} + +// SaveCalls gets all the calls that were made to Save. +// Check the length with: +// +// len(mockedDatabaseUserRepo.SaveCalls()) +func (mock *DatabaseUserRepo) SaveCalls() []struct { + User *biz.DatabaseUser +} { + var calls []struct { + User *biz.DatabaseUser + } + mock.lockSave.RLock() + calls = mock.calls.Save + mock.lockSave.RUnlock() + return calls +} + +// UpdateRemark calls UpdateRemarkFunc. +func (mock *DatabaseUserRepo) UpdateRemark(ctx context.Context, req *request.DatabaseUserUpdateRemark) error { + if mock.UpdateRemarkFunc == nil { + panic("DatabaseUserRepo.UpdateRemarkFunc: method is nil but DatabaseUserRepo.UpdateRemark was just called") + } + callInfo := struct { + Ctx context.Context + Req *request.DatabaseUserUpdateRemark + }{ + Ctx: ctx, + Req: req, + } + mock.lockUpdateRemark.Lock() + mock.calls.UpdateRemark = append(mock.calls.UpdateRemark, callInfo) + mock.lockUpdateRemark.Unlock() + return mock.UpdateRemarkFunc(ctx, req) +} + +// UpdateRemarkCalls gets all the calls that were made to UpdateRemark. +// Check the length with: +// +// len(mockedDatabaseUserRepo.UpdateRemarkCalls()) +func (mock *DatabaseUserRepo) UpdateRemarkCalls() []struct { + Ctx context.Context + Req *request.DatabaseUserUpdateRemark +} { + var calls []struct { + Ctx context.Context + Req *request.DatabaseUserUpdateRemark + } + mock.lockUpdateRemark.RLock() + calls = mock.calls.UpdateRemark + mock.lockUpdateRemark.RUnlock() + return calls +} + +// Upsert calls UpsertFunc. +func (mock *DatabaseUserRepo) Upsert(user *biz.DatabaseUser) error { + if mock.UpsertFunc == nil { + panic("DatabaseUserRepo.UpsertFunc: method is nil but DatabaseUserRepo.Upsert was just called") + } + callInfo := struct { + User *biz.DatabaseUser + }{ + User: user, + } + mock.lockUpsert.Lock() + mock.calls.Upsert = append(mock.calls.Upsert, callInfo) + mock.lockUpsert.Unlock() + return mock.UpsertFunc(user) +} + +// UpsertCalls gets all the calls that were made to Upsert. +// Check the length with: +// +// len(mockedDatabaseUserRepo.UpsertCalls()) +func (mock *DatabaseUserRepo) UpsertCalls() []struct { + User *biz.DatabaseUser +} { + var calls []struct { + User *biz.DatabaseUser + } + mock.lockUpsert.RLock() + calls = mock.calls.Upsert + mock.lockUpsert.RUnlock() + return calls +} diff --git a/internal/mocks/biz/EnvironmentRepo.go b/internal/mocks/biz/EnvironmentRepo.go new file mode 100644 index 000000000..971cbd603 --- /dev/null +++ b/internal/mocks/biz/EnvironmentRepo.go @@ -0,0 +1,239 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that EnvironmentRepo does implement biz.EnvironmentRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.EnvironmentRepo = &EnvironmentRepo{} + +// EnvironmentRepo is a mock implementation of biz.EnvironmentRepo. +// +// func TestSomethingThatUsesEnvironmentRepo(t *testing.T) { +// +// // make and configure a mocked biz.EnvironmentRepo +// mockedEnvironmentRepo := &EnvironmentRepo{ +// ExecScriptFunc: func(cmd string) error { +// panic("mock out the ExecScript method") +// }, +// InstalledVersionFunc: func(typ string, slug string) string { +// panic("mock out the InstalledVersion method") +// }, +// IsInstalledFunc: func(typ string, slug string) bool { +// panic("mock out the IsInstalled method") +// }, +// ScriptCommandFunc: func(typ string, action string, slug string, version string) string { +// panic("mock out the ScriptCommand method") +// }, +// } +// +// // use mockedEnvironmentRepo in code that requires biz.EnvironmentRepo +// // and then make assertions. +// +// } +type EnvironmentRepo struct { + // ExecScriptFunc mocks the ExecScript method. + ExecScriptFunc func(cmd string) error + + // InstalledVersionFunc mocks the InstalledVersion method. + InstalledVersionFunc func(typ string, slug string) string + + // IsInstalledFunc mocks the IsInstalled method. + IsInstalledFunc func(typ string, slug string) bool + + // ScriptCommandFunc mocks the ScriptCommand method. + ScriptCommandFunc func(typ string, action string, slug string, version string) string + + // calls tracks calls to the methods. + calls struct { + // ExecScript holds details about calls to the ExecScript method. + ExecScript []struct { + // Cmd is the cmd argument value. + Cmd string + } + // InstalledVersion holds details about calls to the InstalledVersion method. + InstalledVersion []struct { + // Typ is the typ argument value. + Typ string + // Slug is the slug argument value. + Slug string + } + // IsInstalled holds details about calls to the IsInstalled method. + IsInstalled []struct { + // Typ is the typ argument value. + Typ string + // Slug is the slug argument value. + Slug string + } + // ScriptCommand holds details about calls to the ScriptCommand method. + ScriptCommand []struct { + // Typ is the typ argument value. + Typ string + // Action is the action argument value. + Action string + // Slug is the slug argument value. + Slug string + // Version is the version argument value. + Version string + } + } + lockExecScript sync.RWMutex + lockInstalledVersion sync.RWMutex + lockIsInstalled sync.RWMutex + lockScriptCommand sync.RWMutex +} + +// ExecScript calls ExecScriptFunc. +func (mock *EnvironmentRepo) ExecScript(cmd string) error { + if mock.ExecScriptFunc == nil { + panic("EnvironmentRepo.ExecScriptFunc: method is nil but EnvironmentRepo.ExecScript was just called") + } + callInfo := struct { + Cmd string + }{ + Cmd: cmd, + } + mock.lockExecScript.Lock() + mock.calls.ExecScript = append(mock.calls.ExecScript, callInfo) + mock.lockExecScript.Unlock() + return mock.ExecScriptFunc(cmd) +} + +// ExecScriptCalls gets all the calls that were made to ExecScript. +// Check the length with: +// +// len(mockedEnvironmentRepo.ExecScriptCalls()) +func (mock *EnvironmentRepo) ExecScriptCalls() []struct { + Cmd string +} { + var calls []struct { + Cmd string + } + mock.lockExecScript.RLock() + calls = mock.calls.ExecScript + mock.lockExecScript.RUnlock() + return calls +} + +// InstalledVersion calls InstalledVersionFunc. +func (mock *EnvironmentRepo) InstalledVersion(typ string, slug string) string { + if mock.InstalledVersionFunc == nil { + panic("EnvironmentRepo.InstalledVersionFunc: method is nil but EnvironmentRepo.InstalledVersion was just called") + } + callInfo := struct { + Typ string + Slug string + }{ + Typ: typ, + Slug: slug, + } + mock.lockInstalledVersion.Lock() + mock.calls.InstalledVersion = append(mock.calls.InstalledVersion, callInfo) + mock.lockInstalledVersion.Unlock() + return mock.InstalledVersionFunc(typ, slug) +} + +// InstalledVersionCalls gets all the calls that were made to InstalledVersion. +// Check the length with: +// +// len(mockedEnvironmentRepo.InstalledVersionCalls()) +func (mock *EnvironmentRepo) InstalledVersionCalls() []struct { + Typ string + Slug string +} { + var calls []struct { + Typ string + Slug string + } + mock.lockInstalledVersion.RLock() + calls = mock.calls.InstalledVersion + mock.lockInstalledVersion.RUnlock() + return calls +} + +// IsInstalled calls IsInstalledFunc. +func (mock *EnvironmentRepo) IsInstalled(typ string, slug string) bool { + if mock.IsInstalledFunc == nil { + panic("EnvironmentRepo.IsInstalledFunc: method is nil but EnvironmentRepo.IsInstalled was just called") + } + callInfo := struct { + Typ string + Slug string + }{ + Typ: typ, + Slug: slug, + } + mock.lockIsInstalled.Lock() + mock.calls.IsInstalled = append(mock.calls.IsInstalled, callInfo) + mock.lockIsInstalled.Unlock() + return mock.IsInstalledFunc(typ, slug) +} + +// IsInstalledCalls gets all the calls that were made to IsInstalled. +// Check the length with: +// +// len(mockedEnvironmentRepo.IsInstalledCalls()) +func (mock *EnvironmentRepo) IsInstalledCalls() []struct { + Typ string + Slug string +} { + var calls []struct { + Typ string + Slug string + } + mock.lockIsInstalled.RLock() + calls = mock.calls.IsInstalled + mock.lockIsInstalled.RUnlock() + return calls +} + +// ScriptCommand calls ScriptCommandFunc. +func (mock *EnvironmentRepo) ScriptCommand(typ string, action string, slug string, version string) string { + if mock.ScriptCommandFunc == nil { + panic("EnvironmentRepo.ScriptCommandFunc: method is nil but EnvironmentRepo.ScriptCommand was just called") + } + callInfo := struct { + Typ string + Action string + Slug string + Version string + }{ + Typ: typ, + Action: action, + Slug: slug, + Version: version, + } + mock.lockScriptCommand.Lock() + mock.calls.ScriptCommand = append(mock.calls.ScriptCommand, callInfo) + mock.lockScriptCommand.Unlock() + return mock.ScriptCommandFunc(typ, action, slug, version) +} + +// ScriptCommandCalls gets all the calls that were made to ScriptCommand. +// Check the length with: +// +// len(mockedEnvironmentRepo.ScriptCommandCalls()) +func (mock *EnvironmentRepo) ScriptCommandCalls() []struct { + Typ string + Action string + Slug string + Version string +} { + var calls []struct { + Typ string + Action string + Slug string + Version string + } + mock.lockScriptCommand.RLock() + calls = mock.calls.ScriptCommand + mock.lockScriptCommand.RUnlock() + return calls +} diff --git a/internal/mocks/biz/FileShareRepo.go b/internal/mocks/biz/FileShareRepo.go new file mode 100644 index 000000000..44194ff24 --- /dev/null +++ b/internal/mocks/biz/FileShareRepo.go @@ -0,0 +1,302 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + "time" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that FileShareRepo does implement biz.FileShareRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.FileShareRepo = &FileShareRepo{} + +// FileShareRepo is a mock implementation of biz.FileShareRepo. +// +// func TestSomethingThatUsesFileShareRepo(t *testing.T) { +// +// // make and configure a mocked biz.FileShareRepo +// mockedFileShareRepo := &FileShareRepo{ +// ClearExpiredFunc: func() (int64, error) { +// panic("mock out the ClearExpired method") +// }, +// ConsumeFunc: func(token string, count bool) (*biz.FileShare, error) { +// panic("mock out the Consume method") +// }, +// CreateFunc: func(path string, maxDownloads uint, expiredAt time.Time) (*biz.FileShare, error) { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(id uint) error { +// panic("mock out the Delete method") +// }, +// GetFunc: func(id uint) (*biz.FileShare, error) { +// panic("mock out the Get method") +// }, +// ListFunc: func() ([]*biz.FileShare, error) { +// panic("mock out the List method") +// }, +// } +// +// // use mockedFileShareRepo in code that requires biz.FileShareRepo +// // and then make assertions. +// +// } +type FileShareRepo struct { + // ClearExpiredFunc mocks the ClearExpired method. + ClearExpiredFunc func() (int64, error) + + // ConsumeFunc mocks the Consume method. + ConsumeFunc func(token string, count bool) (*biz.FileShare, error) + + // CreateFunc mocks the Create method. + CreateFunc func(path string, maxDownloads uint, expiredAt time.Time) (*biz.FileShare, error) + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) error + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*biz.FileShare, error) + + // ListFunc mocks the List method. + ListFunc func() ([]*biz.FileShare, error) + + // calls tracks calls to the methods. + calls struct { + // ClearExpired holds details about calls to the ClearExpired method. + ClearExpired []struct { + } + // Consume holds details about calls to the Consume method. + Consume []struct { + // Token is the token argument value. + Token string + // Count is the count argument value. + Count bool + } + // Create holds details about calls to the Create method. + Create []struct { + // Path is the path argument value. + Path string + // MaxDownloads is the maxDownloads argument value. + MaxDownloads uint + // ExpiredAt is the expiredAt argument value. + ExpiredAt time.Time + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // List holds details about calls to the List method. + List []struct { + } + } + lockClearExpired sync.RWMutex + lockConsume sync.RWMutex + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockGet sync.RWMutex + lockList sync.RWMutex +} + +// ClearExpired calls ClearExpiredFunc. +func (mock *FileShareRepo) ClearExpired() (int64, error) { + if mock.ClearExpiredFunc == nil { + panic("FileShareRepo.ClearExpiredFunc: method is nil but FileShareRepo.ClearExpired was just called") + } + callInfo := struct { + }{} + mock.lockClearExpired.Lock() + mock.calls.ClearExpired = append(mock.calls.ClearExpired, callInfo) + mock.lockClearExpired.Unlock() + return mock.ClearExpiredFunc() +} + +// ClearExpiredCalls gets all the calls that were made to ClearExpired. +// Check the length with: +// +// len(mockedFileShareRepo.ClearExpiredCalls()) +func (mock *FileShareRepo) ClearExpiredCalls() []struct { +} { + var calls []struct { + } + mock.lockClearExpired.RLock() + calls = mock.calls.ClearExpired + mock.lockClearExpired.RUnlock() + return calls +} + +// Consume calls ConsumeFunc. +func (mock *FileShareRepo) Consume(token string, count bool) (*biz.FileShare, error) { + if mock.ConsumeFunc == nil { + panic("FileShareRepo.ConsumeFunc: method is nil but FileShareRepo.Consume was just called") + } + callInfo := struct { + Token string + Count bool + }{ + Token: token, + Count: count, + } + mock.lockConsume.Lock() + mock.calls.Consume = append(mock.calls.Consume, callInfo) + mock.lockConsume.Unlock() + return mock.ConsumeFunc(token, count) +} + +// ConsumeCalls gets all the calls that were made to Consume. +// Check the length with: +// +// len(mockedFileShareRepo.ConsumeCalls()) +func (mock *FileShareRepo) ConsumeCalls() []struct { + Token string + Count bool +} { + var calls []struct { + Token string + Count bool + } + mock.lockConsume.RLock() + calls = mock.calls.Consume + mock.lockConsume.RUnlock() + return calls +} + +// Create calls CreateFunc. +func (mock *FileShareRepo) Create(path string, maxDownloads uint, expiredAt time.Time) (*biz.FileShare, error) { + if mock.CreateFunc == nil { + panic("FileShareRepo.CreateFunc: method is nil but FileShareRepo.Create was just called") + } + callInfo := struct { + Path string + MaxDownloads uint + ExpiredAt time.Time + }{ + Path: path, + MaxDownloads: maxDownloads, + ExpiredAt: expiredAt, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(path, maxDownloads, expiredAt) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedFileShareRepo.CreateCalls()) +func (mock *FileShareRepo) CreateCalls() []struct { + Path string + MaxDownloads uint + ExpiredAt time.Time +} { + var calls []struct { + Path string + MaxDownloads uint + ExpiredAt time.Time + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *FileShareRepo) Delete(id uint) error { + if mock.DeleteFunc == nil { + panic("FileShareRepo.DeleteFunc: method is nil but FileShareRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedFileShareRepo.DeleteCalls()) +func (mock *FileShareRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *FileShareRepo) Get(id uint) (*biz.FileShare, error) { + if mock.GetFunc == nil { + panic("FileShareRepo.GetFunc: method is nil but FileShareRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedFileShareRepo.GetCalls()) +func (mock *FileShareRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *FileShareRepo) List() ([]*biz.FileShare, error) { + if mock.ListFunc == nil { + panic("FileShareRepo.ListFunc: method is nil but FileShareRepo.List was just called") + } + callInfo := struct { + }{} + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc() +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedFileShareRepo.ListCalls()) +func (mock *FileShareRepo) ListCalls() []struct { +} { + var calls []struct { + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} diff --git a/internal/mocks/biz/LogRepo.go b/internal/mocks/biz/LogRepo.go new file mode 100644 index 000000000..c98181a7f --- /dev/null +++ b/internal/mocks/biz/LogRepo.go @@ -0,0 +1,133 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that LogRepo does implement biz.LogRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.LogRepo = &LogRepo{} + +// LogRepo is a mock implementation of biz.LogRepo. +// +// func TestSomethingThatUsesLogRepo(t *testing.T) { +// +// // make and configure a mocked biz.LogRepo +// mockedLogRepo := &LogRepo{ +// ListFunc: func(logType string, limit int, date string) ([]biz.LogEntry, error) { +// panic("mock out the List method") +// }, +// ListDatesFunc: func(logType string) ([]string, error) { +// panic("mock out the ListDates method") +// }, +// } +// +// // use mockedLogRepo in code that requires biz.LogRepo +// // and then make assertions. +// +// } +type LogRepo struct { + // ListFunc mocks the List method. + ListFunc func(logType string, limit int, date string) ([]biz.LogEntry, error) + + // ListDatesFunc mocks the ListDates method. + ListDatesFunc func(logType string) ([]string, error) + + // calls tracks calls to the methods. + calls struct { + // List holds details about calls to the List method. + List []struct { + // LogType is the logType argument value. + LogType string + // Limit is the limit argument value. + Limit int + // Date is the date argument value. + Date string + } + // ListDates holds details about calls to the ListDates method. + ListDates []struct { + // LogType is the logType argument value. + LogType string + } + } + lockList sync.RWMutex + lockListDates sync.RWMutex +} + +// List calls ListFunc. +func (mock *LogRepo) List(logType string, limit int, date string) ([]biz.LogEntry, error) { + if mock.ListFunc == nil { + panic("LogRepo.ListFunc: method is nil but LogRepo.List was just called") + } + callInfo := struct { + LogType string + Limit int + Date string + }{ + LogType: logType, + Limit: limit, + Date: date, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(logType, limit, date) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedLogRepo.ListCalls()) +func (mock *LogRepo) ListCalls() []struct { + LogType string + Limit int + Date string +} { + var calls []struct { + LogType string + Limit int + Date string + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// ListDates calls ListDatesFunc. +func (mock *LogRepo) ListDates(logType string) ([]string, error) { + if mock.ListDatesFunc == nil { + panic("LogRepo.ListDatesFunc: method is nil but LogRepo.ListDates was just called") + } + callInfo := struct { + LogType string + }{ + LogType: logType, + } + mock.lockListDates.Lock() + mock.calls.ListDates = append(mock.calls.ListDates, callInfo) + mock.lockListDates.Unlock() + return mock.ListDatesFunc(logType) +} + +// ListDatesCalls gets all the calls that were made to ListDates. +// Check the length with: +// +// len(mockedLogRepo.ListDatesCalls()) +func (mock *LogRepo) ListDatesCalls() []struct { + LogType string +} { + var calls []struct { + LogType string + } + mock.lockListDates.RLock() + calls = mock.calls.ListDates + mock.lockListDates.RUnlock() + return calls +} diff --git a/internal/mocks/biz/MigrationArchiveRepo.go b/internal/mocks/biz/MigrationArchiveRepo.go new file mode 100644 index 000000000..6261a0da1 --- /dev/null +++ b/internal/mocks/biz/MigrationArchiveRepo.go @@ -0,0 +1,283 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "context" + "sync" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that MigrationArchiveRepo does implement biz.MigrationArchiveRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.MigrationArchiveRepo = &MigrationArchiveRepo{} + +// MigrationArchiveRepo is a mock implementation of biz.MigrationArchiveRepo. +// +// func TestSomethingThatUsesMigrationArchiveRepo(t *testing.T) { +// +// // make and configure a mocked biz.MigrationArchiveRepo +// mockedMigrationArchiveRepo := &MigrationArchiveRepo{ +// CompressFunc: func(ctx context.Context, source string, archive string) error { +// panic("mock out the Compress method") +// }, +// CopyTreeFunc: func(ctx context.Context, source string, target string) error { +// panic("mock out the CopyTree method") +// }, +// ExtractFunc: func(ctx context.Context, archive string, target string) (string, error) { +// panic("mock out the Extract method") +// }, +// IsEmptyFunc: func(path string) bool { +// panic("mock out the IsEmpty method") +// }, +// TempDirFunc: func() (string, error) { +// panic("mock out the TempDir method") +// }, +// } +// +// // use mockedMigrationArchiveRepo in code that requires biz.MigrationArchiveRepo +// // and then make assertions. +// +// } +type MigrationArchiveRepo struct { + // CompressFunc mocks the Compress method. + CompressFunc func(ctx context.Context, source string, archive string) error + + // CopyTreeFunc mocks the CopyTree method. + CopyTreeFunc func(ctx context.Context, source string, target string) error + + // ExtractFunc mocks the Extract method. + ExtractFunc func(ctx context.Context, archive string, target string) (string, error) + + // IsEmptyFunc mocks the IsEmpty method. + IsEmptyFunc func(path string) bool + + // TempDirFunc mocks the TempDir method. + TempDirFunc func() (string, error) + + // calls tracks calls to the methods. + calls struct { + // Compress holds details about calls to the Compress method. + Compress []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Source is the source argument value. + Source string + // Archive is the archive argument value. + Archive string + } + // CopyTree holds details about calls to the CopyTree method. + CopyTree []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Source is the source argument value. + Source string + // Target is the target argument value. + Target string + } + // Extract holds details about calls to the Extract method. + Extract []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Archive is the archive argument value. + Archive string + // Target is the target argument value. + Target string + } + // IsEmpty holds details about calls to the IsEmpty method. + IsEmpty []struct { + // Path is the path argument value. + Path string + } + // TempDir holds details about calls to the TempDir method. + TempDir []struct { + } + } + lockCompress sync.RWMutex + lockCopyTree sync.RWMutex + lockExtract sync.RWMutex + lockIsEmpty sync.RWMutex + lockTempDir sync.RWMutex +} + +// Compress calls CompressFunc. +func (mock *MigrationArchiveRepo) Compress(ctx context.Context, source string, archive string) error { + if mock.CompressFunc == nil { + panic("MigrationArchiveRepo.CompressFunc: method is nil but MigrationArchiveRepo.Compress was just called") + } + callInfo := struct { + Ctx context.Context + Source string + Archive string + }{ + Ctx: ctx, + Source: source, + Archive: archive, + } + mock.lockCompress.Lock() + mock.calls.Compress = append(mock.calls.Compress, callInfo) + mock.lockCompress.Unlock() + return mock.CompressFunc(ctx, source, archive) +} + +// CompressCalls gets all the calls that were made to Compress. +// Check the length with: +// +// len(mockedMigrationArchiveRepo.CompressCalls()) +func (mock *MigrationArchiveRepo) CompressCalls() []struct { + Ctx context.Context + Source string + Archive string +} { + var calls []struct { + Ctx context.Context + Source string + Archive string + } + mock.lockCompress.RLock() + calls = mock.calls.Compress + mock.lockCompress.RUnlock() + return calls +} + +// CopyTree calls CopyTreeFunc. +func (mock *MigrationArchiveRepo) CopyTree(ctx context.Context, source string, target string) error { + if mock.CopyTreeFunc == nil { + panic("MigrationArchiveRepo.CopyTreeFunc: method is nil but MigrationArchiveRepo.CopyTree was just called") + } + callInfo := struct { + Ctx context.Context + Source string + Target string + }{ + Ctx: ctx, + Source: source, + Target: target, + } + mock.lockCopyTree.Lock() + mock.calls.CopyTree = append(mock.calls.CopyTree, callInfo) + mock.lockCopyTree.Unlock() + return mock.CopyTreeFunc(ctx, source, target) +} + +// CopyTreeCalls gets all the calls that were made to CopyTree. +// Check the length with: +// +// len(mockedMigrationArchiveRepo.CopyTreeCalls()) +func (mock *MigrationArchiveRepo) CopyTreeCalls() []struct { + Ctx context.Context + Source string + Target string +} { + var calls []struct { + Ctx context.Context + Source string + Target string + } + mock.lockCopyTree.RLock() + calls = mock.calls.CopyTree + mock.lockCopyTree.RUnlock() + return calls +} + +// Extract calls ExtractFunc. +func (mock *MigrationArchiveRepo) Extract(ctx context.Context, archive string, target string) (string, error) { + if mock.ExtractFunc == nil { + panic("MigrationArchiveRepo.ExtractFunc: method is nil but MigrationArchiveRepo.Extract was just called") + } + callInfo := struct { + Ctx context.Context + Archive string + Target string + }{ + Ctx: ctx, + Archive: archive, + Target: target, + } + mock.lockExtract.Lock() + mock.calls.Extract = append(mock.calls.Extract, callInfo) + mock.lockExtract.Unlock() + return mock.ExtractFunc(ctx, archive, target) +} + +// ExtractCalls gets all the calls that were made to Extract. +// Check the length with: +// +// len(mockedMigrationArchiveRepo.ExtractCalls()) +func (mock *MigrationArchiveRepo) ExtractCalls() []struct { + Ctx context.Context + Archive string + Target string +} { + var calls []struct { + Ctx context.Context + Archive string + Target string + } + mock.lockExtract.RLock() + calls = mock.calls.Extract + mock.lockExtract.RUnlock() + return calls +} + +// IsEmpty calls IsEmptyFunc. +func (mock *MigrationArchiveRepo) IsEmpty(path string) bool { + if mock.IsEmptyFunc == nil { + panic("MigrationArchiveRepo.IsEmptyFunc: method is nil but MigrationArchiveRepo.IsEmpty was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockIsEmpty.Lock() + mock.calls.IsEmpty = append(mock.calls.IsEmpty, callInfo) + mock.lockIsEmpty.Unlock() + return mock.IsEmptyFunc(path) +} + +// IsEmptyCalls gets all the calls that were made to IsEmpty. +// Check the length with: +// +// len(mockedMigrationArchiveRepo.IsEmptyCalls()) +func (mock *MigrationArchiveRepo) IsEmptyCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockIsEmpty.RLock() + calls = mock.calls.IsEmpty + mock.lockIsEmpty.RUnlock() + return calls +} + +// TempDir calls TempDirFunc. +func (mock *MigrationArchiveRepo) TempDir() (string, error) { + if mock.TempDirFunc == nil { + panic("MigrationArchiveRepo.TempDirFunc: method is nil but MigrationArchiveRepo.TempDir was just called") + } + callInfo := struct { + }{} + mock.lockTempDir.Lock() + mock.calls.TempDir = append(mock.calls.TempDir, callInfo) + mock.lockTempDir.Unlock() + return mock.TempDirFunc() +} + +// TempDirCalls gets all the calls that were made to TempDir. +// Check the length with: +// +// len(mockedMigrationArchiveRepo.TempDirCalls()) +func (mock *MigrationArchiveRepo) TempDirCalls() []struct { +} { + var calls []struct { + } + mock.lockTempDir.RLock() + calls = mock.calls.TempDir + mock.lockTempDir.RUnlock() + return calls +} diff --git a/internal/mocks/biz/MigrationRemoteRepo.go b/internal/mocks/biz/MigrationRemoteRepo.go new file mode 100644 index 000000000..87d7e0b76 --- /dev/null +++ b/internal/mocks/biz/MigrationRemoteRepo.go @@ -0,0 +1,228 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "context" + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that MigrationRemoteRepo does implement biz.MigrationRemoteRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.MigrationRemoteRepo = &MigrationRemoteRepo{} + +// MigrationRemoteRepo is a mock implementation of biz.MigrationRemoteRepo. +// +// func TestSomethingThatUsesMigrationRemoteRepo(t *testing.T) { +// +// // make and configure a mocked biz.MigrationRemoteRepo +// mockedMigrationRemoteRepo := &MigrationRemoteRepo{ +// ExecFunc: func(ctx context.Context, conn *request.ToolboxMigrationConnection, command string) error { +// panic("mock out the Exec method") +// }, +// RequestFunc: func(ctx context.Context, conn *request.ToolboxMigrationConnection, method string, path string, body any) ([]byte, error) { +// panic("mock out the Request method") +// }, +// UploadFunc: func(ctx context.Context, conn *request.ToolboxMigrationConnection, local string, remote string, progress types.MigrationProgress) error { +// panic("mock out the Upload method") +// }, +// } +// +// // use mockedMigrationRemoteRepo in code that requires biz.MigrationRemoteRepo +// // and then make assertions. +// +// } +type MigrationRemoteRepo struct { + // ExecFunc mocks the Exec method. + ExecFunc func(ctx context.Context, conn *request.ToolboxMigrationConnection, command string) error + + // RequestFunc mocks the Request method. + RequestFunc func(ctx context.Context, conn *request.ToolboxMigrationConnection, method string, path string, body any) ([]byte, error) + + // UploadFunc mocks the Upload method. + UploadFunc func(ctx context.Context, conn *request.ToolboxMigrationConnection, local string, remote string, progress types.MigrationProgress) error + + // calls tracks calls to the methods. + calls struct { + // Exec holds details about calls to the Exec method. + Exec []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Conn is the conn argument value. + Conn *request.ToolboxMigrationConnection + // Command is the command argument value. + Command string + } + // Request holds details about calls to the Request method. + Request []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Conn is the conn argument value. + Conn *request.ToolboxMigrationConnection + // Method is the method argument value. + Method string + // Path is the path argument value. + Path string + // Body is the body argument value. + Body any + } + // Upload holds details about calls to the Upload method. + Upload []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Conn is the conn argument value. + Conn *request.ToolboxMigrationConnection + // Local is the local argument value. + Local string + // Remote is the remote argument value. + Remote string + // Progress is the progress argument value. + Progress types.MigrationProgress + } + } + lockExec sync.RWMutex + lockRequest sync.RWMutex + lockUpload sync.RWMutex +} + +// Exec calls ExecFunc. +func (mock *MigrationRemoteRepo) Exec(ctx context.Context, conn *request.ToolboxMigrationConnection, command string) error { + if mock.ExecFunc == nil { + panic("MigrationRemoteRepo.ExecFunc: method is nil but MigrationRemoteRepo.Exec was just called") + } + callInfo := struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Command string + }{ + Ctx: ctx, + Conn: conn, + Command: command, + } + mock.lockExec.Lock() + mock.calls.Exec = append(mock.calls.Exec, callInfo) + mock.lockExec.Unlock() + return mock.ExecFunc(ctx, conn, command) +} + +// ExecCalls gets all the calls that were made to Exec. +// Check the length with: +// +// len(mockedMigrationRemoteRepo.ExecCalls()) +func (mock *MigrationRemoteRepo) ExecCalls() []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Command string +} { + var calls []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Command string + } + mock.lockExec.RLock() + calls = mock.calls.Exec + mock.lockExec.RUnlock() + return calls +} + +// Request calls RequestFunc. +func (mock *MigrationRemoteRepo) Request(ctx context.Context, conn *request.ToolboxMigrationConnection, method string, path string, body any) ([]byte, error) { + if mock.RequestFunc == nil { + panic("MigrationRemoteRepo.RequestFunc: method is nil but MigrationRemoteRepo.Request was just called") + } + callInfo := struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Method string + Path string + Body any + }{ + Ctx: ctx, + Conn: conn, + Method: method, + Path: path, + Body: body, + } + mock.lockRequest.Lock() + mock.calls.Request = append(mock.calls.Request, callInfo) + mock.lockRequest.Unlock() + return mock.RequestFunc(ctx, conn, method, path, body) +} + +// RequestCalls gets all the calls that were made to Request. +// Check the length with: +// +// len(mockedMigrationRemoteRepo.RequestCalls()) +func (mock *MigrationRemoteRepo) RequestCalls() []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Method string + Path string + Body any +} { + var calls []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Method string + Path string + Body any + } + mock.lockRequest.RLock() + calls = mock.calls.Request + mock.lockRequest.RUnlock() + return calls +} + +// Upload calls UploadFunc. +func (mock *MigrationRemoteRepo) Upload(ctx context.Context, conn *request.ToolboxMigrationConnection, local string, remote string, progress types.MigrationProgress) error { + if mock.UploadFunc == nil { + panic("MigrationRemoteRepo.UploadFunc: method is nil but MigrationRemoteRepo.Upload was just called") + } + callInfo := struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Local string + Remote string + Progress types.MigrationProgress + }{ + Ctx: ctx, + Conn: conn, + Local: local, + Remote: remote, + Progress: progress, + } + mock.lockUpload.Lock() + mock.calls.Upload = append(mock.calls.Upload, callInfo) + mock.lockUpload.Unlock() + return mock.UploadFunc(ctx, conn, local, remote, progress) +} + +// UploadCalls gets all the calls that were made to Upload. +// Check the length with: +// +// len(mockedMigrationRemoteRepo.UploadCalls()) +func (mock *MigrationRemoteRepo) UploadCalls() []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Local string + Remote string + Progress types.MigrationProgress +} { + var calls []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Local string + Remote string + Progress types.MigrationProgress + } + mock.lockUpload.RLock() + calls = mock.calls.Upload + mock.lockUpload.RUnlock() + return calls +} diff --git a/internal/mocks/biz/MigrationSourceRepo.go b/internal/mocks/biz/MigrationSourceRepo.go new file mode 100644 index 000000000..fe8b0fcea --- /dev/null +++ b/internal/mocks/biz/MigrationSourceRepo.go @@ -0,0 +1,378 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "context" + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that MigrationSourceRepo does implement biz.MigrationSourceRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.MigrationSourceRepo = &MigrationSourceRepo{} + +// MigrationSourceRepo is a mock implementation of biz.MigrationSourceRepo. +// +// func TestSomethingThatUsesMigrationSourceRepo(t *testing.T) { +// +// // make and configure a mocked biz.MigrationSourceRepo +// mockedMigrationSourceRepo := &MigrationSourceRepo{ +// BackupFunc: func(ctx context.Context, conn *request.ToolboxMigrationConnection, detail *types.MigrationDetail) (string, error) { +// panic("mock out the Backup method") +// }, +// DetailFunc: func(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem) (*types.MigrationDetail, error) { +// panic("mock out the Detail method") +// }, +// DownloadFunc: func(ctx context.Context, conn *request.ToolboxMigrationConnection, remote string, local string, progress types.MigrationProgress) error { +// panic("mock out the Download method") +// }, +// ItemsFunc: func(ctx context.Context, conn *request.ToolboxMigrationConnection) ([]types.MigrationItem, error) { +// panic("mock out the Items method") +// }, +// ProbeFunc: func(ctx context.Context, conn *request.ToolboxMigrationConnection) (*types.MigrationSource, error) { +// panic("mock out the Probe method") +// }, +// SetRunningFunc: func(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem, running bool) error { +// panic("mock out the SetRunning method") +// }, +// } +// +// // use mockedMigrationSourceRepo in code that requires biz.MigrationSourceRepo +// // and then make assertions. +// +// } +type MigrationSourceRepo struct { + // BackupFunc mocks the Backup method. + BackupFunc func(ctx context.Context, conn *request.ToolboxMigrationConnection, detail *types.MigrationDetail) (string, error) + + // DetailFunc mocks the Detail method. + DetailFunc func(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem) (*types.MigrationDetail, error) + + // DownloadFunc mocks the Download method. + DownloadFunc func(ctx context.Context, conn *request.ToolboxMigrationConnection, remote string, local string, progress types.MigrationProgress) error + + // ItemsFunc mocks the Items method. + ItemsFunc func(ctx context.Context, conn *request.ToolboxMigrationConnection) ([]types.MigrationItem, error) + + // ProbeFunc mocks the Probe method. + ProbeFunc func(ctx context.Context, conn *request.ToolboxMigrationConnection) (*types.MigrationSource, error) + + // SetRunningFunc mocks the SetRunning method. + SetRunningFunc func(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem, running bool) error + + // calls tracks calls to the methods. + calls struct { + // Backup holds details about calls to the Backup method. + Backup []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Conn is the conn argument value. + Conn *request.ToolboxMigrationConnection + // Detail is the detail argument value. + Detail *types.MigrationDetail + } + // Detail holds details about calls to the Detail method. + Detail []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Conn is the conn argument value. + Conn *request.ToolboxMigrationConnection + // Item is the item argument value. + Item types.MigrationItem + } + // Download holds details about calls to the Download method. + Download []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Conn is the conn argument value. + Conn *request.ToolboxMigrationConnection + // Remote is the remote argument value. + Remote string + // Local is the local argument value. + Local string + // Progress is the progress argument value. + Progress types.MigrationProgress + } + // Items holds details about calls to the Items method. + Items []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Conn is the conn argument value. + Conn *request.ToolboxMigrationConnection + } + // Probe holds details about calls to the Probe method. + Probe []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Conn is the conn argument value. + Conn *request.ToolboxMigrationConnection + } + // SetRunning holds details about calls to the SetRunning method. + SetRunning []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Conn is the conn argument value. + Conn *request.ToolboxMigrationConnection + // Item is the item argument value. + Item types.MigrationItem + // Running is the running argument value. + Running bool + } + } + lockBackup sync.RWMutex + lockDetail sync.RWMutex + lockDownload sync.RWMutex + lockItems sync.RWMutex + lockProbe sync.RWMutex + lockSetRunning sync.RWMutex +} + +// Backup calls BackupFunc. +func (mock *MigrationSourceRepo) Backup(ctx context.Context, conn *request.ToolboxMigrationConnection, detail *types.MigrationDetail) (string, error) { + if mock.BackupFunc == nil { + panic("MigrationSourceRepo.BackupFunc: method is nil but MigrationSourceRepo.Backup was just called") + } + callInfo := struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Detail *types.MigrationDetail + }{ + Ctx: ctx, + Conn: conn, + Detail: detail, + } + mock.lockBackup.Lock() + mock.calls.Backup = append(mock.calls.Backup, callInfo) + mock.lockBackup.Unlock() + return mock.BackupFunc(ctx, conn, detail) +} + +// BackupCalls gets all the calls that were made to Backup. +// Check the length with: +// +// len(mockedMigrationSourceRepo.BackupCalls()) +func (mock *MigrationSourceRepo) BackupCalls() []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Detail *types.MigrationDetail +} { + var calls []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Detail *types.MigrationDetail + } + mock.lockBackup.RLock() + calls = mock.calls.Backup + mock.lockBackup.RUnlock() + return calls +} + +// Detail calls DetailFunc. +func (mock *MigrationSourceRepo) Detail(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem) (*types.MigrationDetail, error) { + if mock.DetailFunc == nil { + panic("MigrationSourceRepo.DetailFunc: method is nil but MigrationSourceRepo.Detail was just called") + } + callInfo := struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Item types.MigrationItem + }{ + Ctx: ctx, + Conn: conn, + Item: item, + } + mock.lockDetail.Lock() + mock.calls.Detail = append(mock.calls.Detail, callInfo) + mock.lockDetail.Unlock() + return mock.DetailFunc(ctx, conn, item) +} + +// DetailCalls gets all the calls that were made to Detail. +// Check the length with: +// +// len(mockedMigrationSourceRepo.DetailCalls()) +func (mock *MigrationSourceRepo) DetailCalls() []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Item types.MigrationItem +} { + var calls []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Item types.MigrationItem + } + mock.lockDetail.RLock() + calls = mock.calls.Detail + mock.lockDetail.RUnlock() + return calls +} + +// Download calls DownloadFunc. +func (mock *MigrationSourceRepo) Download(ctx context.Context, conn *request.ToolboxMigrationConnection, remote string, local string, progress types.MigrationProgress) error { + if mock.DownloadFunc == nil { + panic("MigrationSourceRepo.DownloadFunc: method is nil but MigrationSourceRepo.Download was just called") + } + callInfo := struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Remote string + Local string + Progress types.MigrationProgress + }{ + Ctx: ctx, + Conn: conn, + Remote: remote, + Local: local, + Progress: progress, + } + mock.lockDownload.Lock() + mock.calls.Download = append(mock.calls.Download, callInfo) + mock.lockDownload.Unlock() + return mock.DownloadFunc(ctx, conn, remote, local, progress) +} + +// DownloadCalls gets all the calls that were made to Download. +// Check the length with: +// +// len(mockedMigrationSourceRepo.DownloadCalls()) +func (mock *MigrationSourceRepo) DownloadCalls() []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Remote string + Local string + Progress types.MigrationProgress +} { + var calls []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Remote string + Local string + Progress types.MigrationProgress + } + mock.lockDownload.RLock() + calls = mock.calls.Download + mock.lockDownload.RUnlock() + return calls +} + +// Items calls ItemsFunc. +func (mock *MigrationSourceRepo) Items(ctx context.Context, conn *request.ToolboxMigrationConnection) ([]types.MigrationItem, error) { + if mock.ItemsFunc == nil { + panic("MigrationSourceRepo.ItemsFunc: method is nil but MigrationSourceRepo.Items was just called") + } + callInfo := struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + }{ + Ctx: ctx, + Conn: conn, + } + mock.lockItems.Lock() + mock.calls.Items = append(mock.calls.Items, callInfo) + mock.lockItems.Unlock() + return mock.ItemsFunc(ctx, conn) +} + +// ItemsCalls gets all the calls that were made to Items. +// Check the length with: +// +// len(mockedMigrationSourceRepo.ItemsCalls()) +func (mock *MigrationSourceRepo) ItemsCalls() []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection +} { + var calls []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + } + mock.lockItems.RLock() + calls = mock.calls.Items + mock.lockItems.RUnlock() + return calls +} + +// Probe calls ProbeFunc. +func (mock *MigrationSourceRepo) Probe(ctx context.Context, conn *request.ToolboxMigrationConnection) (*types.MigrationSource, error) { + if mock.ProbeFunc == nil { + panic("MigrationSourceRepo.ProbeFunc: method is nil but MigrationSourceRepo.Probe was just called") + } + callInfo := struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + }{ + Ctx: ctx, + Conn: conn, + } + mock.lockProbe.Lock() + mock.calls.Probe = append(mock.calls.Probe, callInfo) + mock.lockProbe.Unlock() + return mock.ProbeFunc(ctx, conn) +} + +// ProbeCalls gets all the calls that were made to Probe. +// Check the length with: +// +// len(mockedMigrationSourceRepo.ProbeCalls()) +func (mock *MigrationSourceRepo) ProbeCalls() []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection +} { + var calls []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + } + mock.lockProbe.RLock() + calls = mock.calls.Probe + mock.lockProbe.RUnlock() + return calls +} + +// SetRunning calls SetRunningFunc. +func (mock *MigrationSourceRepo) SetRunning(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem, running bool) error { + if mock.SetRunningFunc == nil { + panic("MigrationSourceRepo.SetRunningFunc: method is nil but MigrationSourceRepo.SetRunning was just called") + } + callInfo := struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Item types.MigrationItem + Running bool + }{ + Ctx: ctx, + Conn: conn, + Item: item, + Running: running, + } + mock.lockSetRunning.Lock() + mock.calls.SetRunning = append(mock.calls.SetRunning, callInfo) + mock.lockSetRunning.Unlock() + return mock.SetRunningFunc(ctx, conn, item, running) +} + +// SetRunningCalls gets all the calls that were made to SetRunning. +// Check the length with: +// +// len(mockedMigrationSourceRepo.SetRunningCalls()) +func (mock *MigrationSourceRepo) SetRunningCalls() []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Item types.MigrationItem + Running bool +} { + var calls []struct { + Ctx context.Context + Conn *request.ToolboxMigrationConnection + Item types.MigrationItem + Running bool + } + mock.lockSetRunning.RLock() + calls = mock.calls.SetRunning + mock.lockSetRunning.RUnlock() + return calls +} diff --git a/internal/mocks/biz/MonitorRepo.go b/internal/mocks/biz/MonitorRepo.go new file mode 100644 index 000000000..b71501f09 --- /dev/null +++ b/internal/mocks/biz/MonitorRepo.go @@ -0,0 +1,246 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + "time" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that MonitorRepo does implement biz.MonitorRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.MonitorRepo = &MonitorRepo{} + +// MonitorRepo is a mock implementation of biz.MonitorRepo. +// +// func TestSomethingThatUsesMonitorRepo(t *testing.T) { +// +// // make and configure a mocked biz.MonitorRepo +// mockedMonitorRepo := &MonitorRepo{ +// ClearFunc: func() error { +// panic("mock out the Clear method") +// }, +// ClearBeforeFunc: func(t time.Time) error { +// panic("mock out the ClearBefore method") +// }, +// CreateFunc: func(monitor *biz.Monitor) error { +// panic("mock out the Create method") +// }, +// ListFunc: func(start time.Time, end time.Time) ([]*biz.Monitor, error) { +// panic("mock out the List method") +// }, +// VacuumDBFunc: func() error { +// panic("mock out the VacuumDB method") +// }, +// } +// +// // use mockedMonitorRepo in code that requires biz.MonitorRepo +// // and then make assertions. +// +// } +type MonitorRepo struct { + // ClearFunc mocks the Clear method. + ClearFunc func() error + + // ClearBeforeFunc mocks the ClearBefore method. + ClearBeforeFunc func(t time.Time) error + + // CreateFunc mocks the Create method. + CreateFunc func(monitor *biz.Monitor) error + + // ListFunc mocks the List method. + ListFunc func(start time.Time, end time.Time) ([]*biz.Monitor, error) + + // VacuumDBFunc mocks the VacuumDB method. + VacuumDBFunc func() error + + // calls tracks calls to the methods. + calls struct { + // Clear holds details about calls to the Clear method. + Clear []struct { + } + // ClearBefore holds details about calls to the ClearBefore method. + ClearBefore []struct { + // T is the t argument value. + T time.Time + } + // Create holds details about calls to the Create method. + Create []struct { + // Monitor is the monitor argument value. + Monitor *biz.Monitor + } + // List holds details about calls to the List method. + List []struct { + // Start is the start argument value. + Start time.Time + // End is the end argument value. + End time.Time + } + // VacuumDB holds details about calls to the VacuumDB method. + VacuumDB []struct { + } + } + lockClear sync.RWMutex + lockClearBefore sync.RWMutex + lockCreate sync.RWMutex + lockList sync.RWMutex + lockVacuumDB sync.RWMutex +} + +// Clear calls ClearFunc. +func (mock *MonitorRepo) Clear() error { + if mock.ClearFunc == nil { + panic("MonitorRepo.ClearFunc: method is nil but MonitorRepo.Clear was just called") + } + callInfo := struct { + }{} + mock.lockClear.Lock() + mock.calls.Clear = append(mock.calls.Clear, callInfo) + mock.lockClear.Unlock() + return mock.ClearFunc() +} + +// ClearCalls gets all the calls that were made to Clear. +// Check the length with: +// +// len(mockedMonitorRepo.ClearCalls()) +func (mock *MonitorRepo) ClearCalls() []struct { +} { + var calls []struct { + } + mock.lockClear.RLock() + calls = mock.calls.Clear + mock.lockClear.RUnlock() + return calls +} + +// ClearBefore calls ClearBeforeFunc. +func (mock *MonitorRepo) ClearBefore(t time.Time) error { + if mock.ClearBeforeFunc == nil { + panic("MonitorRepo.ClearBeforeFunc: method is nil but MonitorRepo.ClearBefore was just called") + } + callInfo := struct { + T time.Time + }{ + T: t, + } + mock.lockClearBefore.Lock() + mock.calls.ClearBefore = append(mock.calls.ClearBefore, callInfo) + mock.lockClearBefore.Unlock() + return mock.ClearBeforeFunc(t) +} + +// ClearBeforeCalls gets all the calls that were made to ClearBefore. +// Check the length with: +// +// len(mockedMonitorRepo.ClearBeforeCalls()) +func (mock *MonitorRepo) ClearBeforeCalls() []struct { + T time.Time +} { + var calls []struct { + T time.Time + } + mock.lockClearBefore.RLock() + calls = mock.calls.ClearBefore + mock.lockClearBefore.RUnlock() + return calls +} + +// Create calls CreateFunc. +func (mock *MonitorRepo) Create(monitor *biz.Monitor) error { + if mock.CreateFunc == nil { + panic("MonitorRepo.CreateFunc: method is nil but MonitorRepo.Create was just called") + } + callInfo := struct { + Monitor *biz.Monitor + }{ + Monitor: monitor, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(monitor) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedMonitorRepo.CreateCalls()) +func (mock *MonitorRepo) CreateCalls() []struct { + Monitor *biz.Monitor +} { + var calls []struct { + Monitor *biz.Monitor + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *MonitorRepo) List(start time.Time, end time.Time) ([]*biz.Monitor, error) { + if mock.ListFunc == nil { + panic("MonitorRepo.ListFunc: method is nil but MonitorRepo.List was just called") + } + callInfo := struct { + Start time.Time + End time.Time + }{ + Start: start, + End: end, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(start, end) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedMonitorRepo.ListCalls()) +func (mock *MonitorRepo) ListCalls() []struct { + Start time.Time + End time.Time +} { + var calls []struct { + Start time.Time + End time.Time + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// VacuumDB calls VacuumDBFunc. +func (mock *MonitorRepo) VacuumDB() error { + if mock.VacuumDBFunc == nil { + panic("MonitorRepo.VacuumDBFunc: method is nil but MonitorRepo.VacuumDB was just called") + } + callInfo := struct { + }{} + mock.lockVacuumDB.Lock() + mock.calls.VacuumDB = append(mock.calls.VacuumDB, callInfo) + mock.lockVacuumDB.Unlock() + return mock.VacuumDBFunc() +} + +// VacuumDBCalls gets all the calls that were made to VacuumDB. +// Check the length with: +// +// len(mockedMonitorRepo.VacuumDBCalls()) +func (mock *MonitorRepo) VacuumDBCalls() []struct { +} { + var calls []struct { + } + mock.lockVacuumDB.RLock() + calls = mock.calls.VacuumDB + mock.lockVacuumDB.RUnlock() + return calls +} diff --git a/internal/mocks/biz/NotifyChannelRepo.go b/internal/mocks/biz/NotifyChannelRepo.go new file mode 100644 index 000000000..12a04291e --- /dev/null +++ b/internal/mocks/biz/NotifyChannelRepo.go @@ -0,0 +1,340 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that NotifyChannelRepo does implement biz.NotifyChannelRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.NotifyChannelRepo = &NotifyChannelRepo{} + +// NotifyChannelRepo is a mock implementation of biz.NotifyChannelRepo. +// +// func TestSomethingThatUsesNotifyChannelRepo(t *testing.T) { +// +// // make and configure a mocked biz.NotifyChannelRepo +// mockedNotifyChannelRepo := &NotifyChannelRepo{ +// AllFunc: func() ([]*biz.NotifyChannel, error) { +// panic("mock out the All method") +// }, +// CreateFunc: func(channel *biz.NotifyChannel) error { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(id uint) error { +// panic("mock out the Delete method") +// }, +// GetFunc: func(id uint) (*biz.NotifyChannel, error) { +// panic("mock out the Get method") +// }, +// GetByIDsFunc: func(ids []uint) ([]*biz.NotifyChannel, error) { +// panic("mock out the GetByIDs method") +// }, +// ListFunc: func(page uint, limit uint) ([]*biz.NotifyChannel, int64, error) { +// panic("mock out the List method") +// }, +// UpdateFunc: func(channel *biz.NotifyChannel) error { +// panic("mock out the Update method") +// }, +// } +// +// // use mockedNotifyChannelRepo in code that requires biz.NotifyChannelRepo +// // and then make assertions. +// +// } +type NotifyChannelRepo struct { + // AllFunc mocks the All method. + AllFunc func() ([]*biz.NotifyChannel, error) + + // CreateFunc mocks the Create method. + CreateFunc func(channel *biz.NotifyChannel) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) error + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*biz.NotifyChannel, error) + + // GetByIDsFunc mocks the GetByIDs method. + GetByIDsFunc func(ids []uint) ([]*biz.NotifyChannel, error) + + // ListFunc mocks the List method. + ListFunc func(page uint, limit uint) ([]*biz.NotifyChannel, int64, error) + + // UpdateFunc mocks the Update method. + UpdateFunc func(channel *biz.NotifyChannel) error + + // calls tracks calls to the methods. + calls struct { + // All holds details about calls to the All method. + All []struct { + } + // Create holds details about calls to the Create method. + Create []struct { + // Channel is the channel argument value. + Channel *biz.NotifyChannel + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // GetByIDs holds details about calls to the GetByIDs method. + GetByIDs []struct { + // Ids is the ids argument value. + Ids []uint + } + // List holds details about calls to the List method. + List []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // Update holds details about calls to the Update method. + Update []struct { + // Channel is the channel argument value. + Channel *biz.NotifyChannel + } + } + lockAll sync.RWMutex + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockGet sync.RWMutex + lockGetByIDs sync.RWMutex + lockList sync.RWMutex + lockUpdate sync.RWMutex +} + +// All calls AllFunc. +func (mock *NotifyChannelRepo) All() ([]*biz.NotifyChannel, error) { + if mock.AllFunc == nil { + panic("NotifyChannelRepo.AllFunc: method is nil but NotifyChannelRepo.All was just called") + } + callInfo := struct { + }{} + mock.lockAll.Lock() + mock.calls.All = append(mock.calls.All, callInfo) + mock.lockAll.Unlock() + return mock.AllFunc() +} + +// AllCalls gets all the calls that were made to All. +// Check the length with: +// +// len(mockedNotifyChannelRepo.AllCalls()) +func (mock *NotifyChannelRepo) AllCalls() []struct { +} { + var calls []struct { + } + mock.lockAll.RLock() + calls = mock.calls.All + mock.lockAll.RUnlock() + return calls +} + +// Create calls CreateFunc. +func (mock *NotifyChannelRepo) Create(channel *biz.NotifyChannel) error { + if mock.CreateFunc == nil { + panic("NotifyChannelRepo.CreateFunc: method is nil but NotifyChannelRepo.Create was just called") + } + callInfo := struct { + Channel *biz.NotifyChannel + }{ + Channel: channel, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(channel) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedNotifyChannelRepo.CreateCalls()) +func (mock *NotifyChannelRepo) CreateCalls() []struct { + Channel *biz.NotifyChannel +} { + var calls []struct { + Channel *biz.NotifyChannel + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *NotifyChannelRepo) Delete(id uint) error { + if mock.DeleteFunc == nil { + panic("NotifyChannelRepo.DeleteFunc: method is nil but NotifyChannelRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedNotifyChannelRepo.DeleteCalls()) +func (mock *NotifyChannelRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *NotifyChannelRepo) Get(id uint) (*biz.NotifyChannel, error) { + if mock.GetFunc == nil { + panic("NotifyChannelRepo.GetFunc: method is nil but NotifyChannelRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedNotifyChannelRepo.GetCalls()) +func (mock *NotifyChannelRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// GetByIDs calls GetByIDsFunc. +func (mock *NotifyChannelRepo) GetByIDs(ids []uint) ([]*biz.NotifyChannel, error) { + if mock.GetByIDsFunc == nil { + panic("NotifyChannelRepo.GetByIDsFunc: method is nil but NotifyChannelRepo.GetByIDs was just called") + } + callInfo := struct { + Ids []uint + }{ + Ids: ids, + } + mock.lockGetByIDs.Lock() + mock.calls.GetByIDs = append(mock.calls.GetByIDs, callInfo) + mock.lockGetByIDs.Unlock() + return mock.GetByIDsFunc(ids) +} + +// GetByIDsCalls gets all the calls that were made to GetByIDs. +// Check the length with: +// +// len(mockedNotifyChannelRepo.GetByIDsCalls()) +func (mock *NotifyChannelRepo) GetByIDsCalls() []struct { + Ids []uint +} { + var calls []struct { + Ids []uint + } + mock.lockGetByIDs.RLock() + calls = mock.calls.GetByIDs + mock.lockGetByIDs.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *NotifyChannelRepo) List(page uint, limit uint) ([]*biz.NotifyChannel, int64, error) { + if mock.ListFunc == nil { + panic("NotifyChannelRepo.ListFunc: method is nil but NotifyChannelRepo.List was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedNotifyChannelRepo.ListCalls()) +func (mock *NotifyChannelRepo) ListCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// Update calls UpdateFunc. +func (mock *NotifyChannelRepo) Update(channel *biz.NotifyChannel) error { + if mock.UpdateFunc == nil { + panic("NotifyChannelRepo.UpdateFunc: method is nil but NotifyChannelRepo.Update was just called") + } + callInfo := struct { + Channel *biz.NotifyChannel + }{ + Channel: channel, + } + mock.lockUpdate.Lock() + mock.calls.Update = append(mock.calls.Update, callInfo) + mock.lockUpdate.Unlock() + return mock.UpdateFunc(channel) +} + +// UpdateCalls gets all the calls that were made to Update. +// Check the length with: +// +// len(mockedNotifyChannelRepo.UpdateCalls()) +func (mock *NotifyChannelRepo) UpdateCalls() []struct { + Channel *biz.NotifyChannel +} { + var calls []struct { + Channel *biz.NotifyChannel + } + mock.lockUpdate.RLock() + calls = mock.calls.Update + mock.lockUpdate.RUnlock() + return calls +} diff --git a/internal/mocks/biz/ProjectRepo.go b/internal/mocks/biz/ProjectRepo.go new file mode 100644 index 000000000..6eda1f7f6 --- /dev/null +++ b/internal/mocks/biz/ProjectRepo.go @@ -0,0 +1,542 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that ProjectRepo does implement biz.ProjectRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.ProjectRepo = &ProjectRepo{} + +// ProjectRepo is a mock implementation of biz.ProjectRepo. +// +// func TestSomethingThatUsesProjectRepo(t *testing.T) { +// +// // make and configure a mocked biz.ProjectRepo +// mockedProjectRepo := &ProjectRepo{ +// CountFunc: func() (int64, error) { +// panic("mock out the Count method") +// }, +// CreateFunc: func(project *biz.Project, req *request.ProjectCreate) error { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(project *biz.Project) error { +// panic("mock out the Delete method") +// }, +// GetEntityFunc: func(id uint) (*biz.Project, error) { +// panic("mock out the GetEntity method") +// }, +// ListFunc: func(typ types.ProjectType, page uint, limit uint) ([]*biz.Project, int64, error) { +// panic("mock out the List method") +// }, +// NameExistsFunc: func(name string) (bool, error) { +// panic("mock out the NameExists method") +// }, +// ParseDetailFunc: func(project *biz.Project) (*types.ProjectDetail, error) { +// panic("mock out the ParseDetail method") +// }, +// RemoveUnitFileFunc: func(name string) error { +// panic("mock out the RemoveUnitFile method") +// }, +// RenameUnitFileFunc: func(oldName string, newName string) error { +// panic("mock out the RenameUnitFile method") +// }, +// SaveFunc: func(project *biz.Project) error { +// panic("mock out the Save method") +// }, +// UpdateUnitFileFunc: func(name string, req *request.ProjectUpdate) error { +// panic("mock out the UpdateUnitFile method") +// }, +// } +// +// // use mockedProjectRepo in code that requires biz.ProjectRepo +// // and then make assertions. +// +// } +type ProjectRepo struct { + // CountFunc mocks the Count method. + CountFunc func() (int64, error) + + // CreateFunc mocks the Create method. + CreateFunc func(project *biz.Project, req *request.ProjectCreate) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(project *biz.Project) error + + // GetEntityFunc mocks the GetEntity method. + GetEntityFunc func(id uint) (*biz.Project, error) + + // ListFunc mocks the List method. + ListFunc func(typ types.ProjectType, page uint, limit uint) ([]*biz.Project, int64, error) + + // NameExistsFunc mocks the NameExists method. + NameExistsFunc func(name string) (bool, error) + + // ParseDetailFunc mocks the ParseDetail method. + ParseDetailFunc func(project *biz.Project) (*types.ProjectDetail, error) + + // RemoveUnitFileFunc mocks the RemoveUnitFile method. + RemoveUnitFileFunc func(name string) error + + // RenameUnitFileFunc mocks the RenameUnitFile method. + RenameUnitFileFunc func(oldName string, newName string) error + + // SaveFunc mocks the Save method. + SaveFunc func(project *biz.Project) error + + // UpdateUnitFileFunc mocks the UpdateUnitFile method. + UpdateUnitFileFunc func(name string, req *request.ProjectUpdate) error + + // calls tracks calls to the methods. + calls struct { + // Count holds details about calls to the Count method. + Count []struct { + } + // Create holds details about calls to the Create method. + Create []struct { + // Project is the project argument value. + Project *biz.Project + // Req is the req argument value. + Req *request.ProjectCreate + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // Project is the project argument value. + Project *biz.Project + } + // GetEntity holds details about calls to the GetEntity method. + GetEntity []struct { + // ID is the id argument value. + ID uint + } + // List holds details about calls to the List method. + List []struct { + // Typ is the typ argument value. + Typ types.ProjectType + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // NameExists holds details about calls to the NameExists method. + NameExists []struct { + // Name is the name argument value. + Name string + } + // ParseDetail holds details about calls to the ParseDetail method. + ParseDetail []struct { + // Project is the project argument value. + Project *biz.Project + } + // RemoveUnitFile holds details about calls to the RemoveUnitFile method. + RemoveUnitFile []struct { + // Name is the name argument value. + Name string + } + // RenameUnitFile holds details about calls to the RenameUnitFile method. + RenameUnitFile []struct { + // OldName is the oldName argument value. + OldName string + // NewName is the newName argument value. + NewName string + } + // Save holds details about calls to the Save method. + Save []struct { + // Project is the project argument value. + Project *biz.Project + } + // UpdateUnitFile holds details about calls to the UpdateUnitFile method. + UpdateUnitFile []struct { + // Name is the name argument value. + Name string + // Req is the req argument value. + Req *request.ProjectUpdate + } + } + lockCount sync.RWMutex + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockGetEntity sync.RWMutex + lockList sync.RWMutex + lockNameExists sync.RWMutex + lockParseDetail sync.RWMutex + lockRemoveUnitFile sync.RWMutex + lockRenameUnitFile sync.RWMutex + lockSave sync.RWMutex + lockUpdateUnitFile sync.RWMutex +} + +// Count calls CountFunc. +func (mock *ProjectRepo) Count() (int64, error) { + if mock.CountFunc == nil { + panic("ProjectRepo.CountFunc: method is nil but ProjectRepo.Count was just called") + } + callInfo := struct { + }{} + mock.lockCount.Lock() + mock.calls.Count = append(mock.calls.Count, callInfo) + mock.lockCount.Unlock() + return mock.CountFunc() +} + +// CountCalls gets all the calls that were made to Count. +// Check the length with: +// +// len(mockedProjectRepo.CountCalls()) +func (mock *ProjectRepo) CountCalls() []struct { +} { + var calls []struct { + } + mock.lockCount.RLock() + calls = mock.calls.Count + mock.lockCount.RUnlock() + return calls +} + +// Create calls CreateFunc. +func (mock *ProjectRepo) Create(project *biz.Project, req *request.ProjectCreate) error { + if mock.CreateFunc == nil { + panic("ProjectRepo.CreateFunc: method is nil but ProjectRepo.Create was just called") + } + callInfo := struct { + Project *biz.Project + Req *request.ProjectCreate + }{ + Project: project, + Req: req, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(project, req) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedProjectRepo.CreateCalls()) +func (mock *ProjectRepo) CreateCalls() []struct { + Project *biz.Project + Req *request.ProjectCreate +} { + var calls []struct { + Project *biz.Project + Req *request.ProjectCreate + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *ProjectRepo) Delete(project *biz.Project) error { + if mock.DeleteFunc == nil { + panic("ProjectRepo.DeleteFunc: method is nil but ProjectRepo.Delete was just called") + } + callInfo := struct { + Project *biz.Project + }{ + Project: project, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(project) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedProjectRepo.DeleteCalls()) +func (mock *ProjectRepo) DeleteCalls() []struct { + Project *biz.Project +} { + var calls []struct { + Project *biz.Project + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// GetEntity calls GetEntityFunc. +func (mock *ProjectRepo) GetEntity(id uint) (*biz.Project, error) { + if mock.GetEntityFunc == nil { + panic("ProjectRepo.GetEntityFunc: method is nil but ProjectRepo.GetEntity was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGetEntity.Lock() + mock.calls.GetEntity = append(mock.calls.GetEntity, callInfo) + mock.lockGetEntity.Unlock() + return mock.GetEntityFunc(id) +} + +// GetEntityCalls gets all the calls that were made to GetEntity. +// Check the length with: +// +// len(mockedProjectRepo.GetEntityCalls()) +func (mock *ProjectRepo) GetEntityCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGetEntity.RLock() + calls = mock.calls.GetEntity + mock.lockGetEntity.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *ProjectRepo) List(typ types.ProjectType, page uint, limit uint) ([]*biz.Project, int64, error) { + if mock.ListFunc == nil { + panic("ProjectRepo.ListFunc: method is nil but ProjectRepo.List was just called") + } + callInfo := struct { + Typ types.ProjectType + Page uint + Limit uint + }{ + Typ: typ, + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(typ, page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedProjectRepo.ListCalls()) +func (mock *ProjectRepo) ListCalls() []struct { + Typ types.ProjectType + Page uint + Limit uint +} { + var calls []struct { + Typ types.ProjectType + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// NameExists calls NameExistsFunc. +func (mock *ProjectRepo) NameExists(name string) (bool, error) { + if mock.NameExistsFunc == nil { + panic("ProjectRepo.NameExistsFunc: method is nil but ProjectRepo.NameExists was just called") + } + callInfo := struct { + Name string + }{ + Name: name, + } + mock.lockNameExists.Lock() + mock.calls.NameExists = append(mock.calls.NameExists, callInfo) + mock.lockNameExists.Unlock() + return mock.NameExistsFunc(name) +} + +// NameExistsCalls gets all the calls that were made to NameExists. +// Check the length with: +// +// len(mockedProjectRepo.NameExistsCalls()) +func (mock *ProjectRepo) NameExistsCalls() []struct { + Name string +} { + var calls []struct { + Name string + } + mock.lockNameExists.RLock() + calls = mock.calls.NameExists + mock.lockNameExists.RUnlock() + return calls +} + +// ParseDetail calls ParseDetailFunc. +func (mock *ProjectRepo) ParseDetail(project *biz.Project) (*types.ProjectDetail, error) { + if mock.ParseDetailFunc == nil { + panic("ProjectRepo.ParseDetailFunc: method is nil but ProjectRepo.ParseDetail was just called") + } + callInfo := struct { + Project *biz.Project + }{ + Project: project, + } + mock.lockParseDetail.Lock() + mock.calls.ParseDetail = append(mock.calls.ParseDetail, callInfo) + mock.lockParseDetail.Unlock() + return mock.ParseDetailFunc(project) +} + +// ParseDetailCalls gets all the calls that were made to ParseDetail. +// Check the length with: +// +// len(mockedProjectRepo.ParseDetailCalls()) +func (mock *ProjectRepo) ParseDetailCalls() []struct { + Project *biz.Project +} { + var calls []struct { + Project *biz.Project + } + mock.lockParseDetail.RLock() + calls = mock.calls.ParseDetail + mock.lockParseDetail.RUnlock() + return calls +} + +// RemoveUnitFile calls RemoveUnitFileFunc. +func (mock *ProjectRepo) RemoveUnitFile(name string) error { + if mock.RemoveUnitFileFunc == nil { + panic("ProjectRepo.RemoveUnitFileFunc: method is nil but ProjectRepo.RemoveUnitFile was just called") + } + callInfo := struct { + Name string + }{ + Name: name, + } + mock.lockRemoveUnitFile.Lock() + mock.calls.RemoveUnitFile = append(mock.calls.RemoveUnitFile, callInfo) + mock.lockRemoveUnitFile.Unlock() + return mock.RemoveUnitFileFunc(name) +} + +// RemoveUnitFileCalls gets all the calls that were made to RemoveUnitFile. +// Check the length with: +// +// len(mockedProjectRepo.RemoveUnitFileCalls()) +func (mock *ProjectRepo) RemoveUnitFileCalls() []struct { + Name string +} { + var calls []struct { + Name string + } + mock.lockRemoveUnitFile.RLock() + calls = mock.calls.RemoveUnitFile + mock.lockRemoveUnitFile.RUnlock() + return calls +} + +// RenameUnitFile calls RenameUnitFileFunc. +func (mock *ProjectRepo) RenameUnitFile(oldName string, newName string) error { + if mock.RenameUnitFileFunc == nil { + panic("ProjectRepo.RenameUnitFileFunc: method is nil but ProjectRepo.RenameUnitFile was just called") + } + callInfo := struct { + OldName string + NewName string + }{ + OldName: oldName, + NewName: newName, + } + mock.lockRenameUnitFile.Lock() + mock.calls.RenameUnitFile = append(mock.calls.RenameUnitFile, callInfo) + mock.lockRenameUnitFile.Unlock() + return mock.RenameUnitFileFunc(oldName, newName) +} + +// RenameUnitFileCalls gets all the calls that were made to RenameUnitFile. +// Check the length with: +// +// len(mockedProjectRepo.RenameUnitFileCalls()) +func (mock *ProjectRepo) RenameUnitFileCalls() []struct { + OldName string + NewName string +} { + var calls []struct { + OldName string + NewName string + } + mock.lockRenameUnitFile.RLock() + calls = mock.calls.RenameUnitFile + mock.lockRenameUnitFile.RUnlock() + return calls +} + +// Save calls SaveFunc. +func (mock *ProjectRepo) Save(project *biz.Project) error { + if mock.SaveFunc == nil { + panic("ProjectRepo.SaveFunc: method is nil but ProjectRepo.Save was just called") + } + callInfo := struct { + Project *biz.Project + }{ + Project: project, + } + mock.lockSave.Lock() + mock.calls.Save = append(mock.calls.Save, callInfo) + mock.lockSave.Unlock() + return mock.SaveFunc(project) +} + +// SaveCalls gets all the calls that were made to Save. +// Check the length with: +// +// len(mockedProjectRepo.SaveCalls()) +func (mock *ProjectRepo) SaveCalls() []struct { + Project *biz.Project +} { + var calls []struct { + Project *biz.Project + } + mock.lockSave.RLock() + calls = mock.calls.Save + mock.lockSave.RUnlock() + return calls +} + +// UpdateUnitFile calls UpdateUnitFileFunc. +func (mock *ProjectRepo) UpdateUnitFile(name string, req *request.ProjectUpdate) error { + if mock.UpdateUnitFileFunc == nil { + panic("ProjectRepo.UpdateUnitFileFunc: method is nil but ProjectRepo.UpdateUnitFile was just called") + } + callInfo := struct { + Name string + Req *request.ProjectUpdate + }{ + Name: name, + Req: req, + } + mock.lockUpdateUnitFile.Lock() + mock.calls.UpdateUnitFile = append(mock.calls.UpdateUnitFile, callInfo) + mock.lockUpdateUnitFile.Unlock() + return mock.UpdateUnitFileFunc(name, req) +} + +// UpdateUnitFileCalls gets all the calls that were made to UpdateUnitFile. +// Check the length with: +// +// len(mockedProjectRepo.UpdateUnitFileCalls()) +func (mock *ProjectRepo) UpdateUnitFileCalls() []struct { + Name string + Req *request.ProjectUpdate +} { + var calls []struct { + Name string + Req *request.ProjectUpdate + } + mock.lockUpdateUnitFile.RLock() + calls = mock.calls.UpdateUnitFile + mock.lockUpdateUnitFile.RUnlock() + return calls +} diff --git a/internal/mocks/biz/SSHRepo.go b/internal/mocks/biz/SSHRepo.go new file mode 100644 index 000000000..c0ed32c7c --- /dev/null +++ b/internal/mocks/biz/SSHRepo.go @@ -0,0 +1,435 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "context" + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" +) + +// Ensure that SSHRepo does implement biz.SSHRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.SSHRepo = &SSHRepo{} + +// SSHRepo is a mock implementation of biz.SSHRepo. +// +// func TestSomethingThatUsesSSHRepo(t *testing.T) { +// +// // make and configure a mocked biz.SSHRepo +// mockedSSHRepo := &SSHRepo{ +// CreateFunc: func(req *request.SSHCreate) error { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(id uint) error { +// panic("mock out the Delete method") +// }, +// GetFunc: func(id uint) (*biz.SSH, error) { +// panic("mock out the Get method") +// }, +// ListFunc: func(page uint, limit uint) ([]*biz.SSH, int64, error) { +// panic("mock out the List method") +// }, +// ListFilesFunc: func(hostID uint, path string) ([]*biz.SSHFileInfo, error) { +// panic("mock out the ListFiles method") +// }, +// MkdirFunc: func(hostID uint, path string) error { +// panic("mock out the Mkdir method") +// }, +// TransferFileFunc: func(ctx context.Context, srcID uint, srcPath string, dstID uint, dstPath string, progress func(transferred int64, total int64)) error { +// panic("mock out the TransferFile method") +// }, +// UpdateFunc: func(req *request.SSHUpdate) error { +// panic("mock out the Update method") +// }, +// } +// +// // use mockedSSHRepo in code that requires biz.SSHRepo +// // and then make assertions. +// +// } +type SSHRepo struct { + // CreateFunc mocks the Create method. + CreateFunc func(req *request.SSHCreate) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) error + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*biz.SSH, error) + + // ListFunc mocks the List method. + ListFunc func(page uint, limit uint) ([]*biz.SSH, int64, error) + + // ListFilesFunc mocks the ListFiles method. + ListFilesFunc func(hostID uint, path string) ([]*biz.SSHFileInfo, error) + + // MkdirFunc mocks the Mkdir method. + MkdirFunc func(hostID uint, path string) error + + // TransferFileFunc mocks the TransferFile method. + TransferFileFunc func(ctx context.Context, srcID uint, srcPath string, dstID uint, dstPath string, progress func(transferred int64, total int64)) error + + // UpdateFunc mocks the Update method. + UpdateFunc func(req *request.SSHUpdate) error + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // Req is the req argument value. + Req *request.SSHCreate + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // List holds details about calls to the List method. + List []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // ListFiles holds details about calls to the ListFiles method. + ListFiles []struct { + // HostID is the hostID argument value. + HostID uint + // Path is the path argument value. + Path string + } + // Mkdir holds details about calls to the Mkdir method. + Mkdir []struct { + // HostID is the hostID argument value. + HostID uint + // Path is the path argument value. + Path string + } + // TransferFile holds details about calls to the TransferFile method. + TransferFile []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // SrcID is the srcID argument value. + SrcID uint + // SrcPath is the srcPath argument value. + SrcPath string + // DstID is the dstID argument value. + DstID uint + // DstPath is the dstPath argument value. + DstPath string + // Progress is the progress argument value. + Progress func(transferred int64, total int64) + } + // Update holds details about calls to the Update method. + Update []struct { + // Req is the req argument value. + Req *request.SSHUpdate + } + } + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockGet sync.RWMutex + lockList sync.RWMutex + lockListFiles sync.RWMutex + lockMkdir sync.RWMutex + lockTransferFile sync.RWMutex + lockUpdate sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *SSHRepo) Create(req *request.SSHCreate) error { + if mock.CreateFunc == nil { + panic("SSHRepo.CreateFunc: method is nil but SSHRepo.Create was just called") + } + callInfo := struct { + Req *request.SSHCreate + }{ + Req: req, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(req) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedSSHRepo.CreateCalls()) +func (mock *SSHRepo) CreateCalls() []struct { + Req *request.SSHCreate +} { + var calls []struct { + Req *request.SSHCreate + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *SSHRepo) Delete(id uint) error { + if mock.DeleteFunc == nil { + panic("SSHRepo.DeleteFunc: method is nil but SSHRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedSSHRepo.DeleteCalls()) +func (mock *SSHRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *SSHRepo) Get(id uint) (*biz.SSH, error) { + if mock.GetFunc == nil { + panic("SSHRepo.GetFunc: method is nil but SSHRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedSSHRepo.GetCalls()) +func (mock *SSHRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *SSHRepo) List(page uint, limit uint) ([]*biz.SSH, int64, error) { + if mock.ListFunc == nil { + panic("SSHRepo.ListFunc: method is nil but SSHRepo.List was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedSSHRepo.ListCalls()) +func (mock *SSHRepo) ListCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// ListFiles calls ListFilesFunc. +func (mock *SSHRepo) ListFiles(hostID uint, path string) ([]*biz.SSHFileInfo, error) { + if mock.ListFilesFunc == nil { + panic("SSHRepo.ListFilesFunc: method is nil but SSHRepo.ListFiles was just called") + } + callInfo := struct { + HostID uint + Path string + }{ + HostID: hostID, + Path: path, + } + mock.lockListFiles.Lock() + mock.calls.ListFiles = append(mock.calls.ListFiles, callInfo) + mock.lockListFiles.Unlock() + return mock.ListFilesFunc(hostID, path) +} + +// ListFilesCalls gets all the calls that were made to ListFiles. +// Check the length with: +// +// len(mockedSSHRepo.ListFilesCalls()) +func (mock *SSHRepo) ListFilesCalls() []struct { + HostID uint + Path string +} { + var calls []struct { + HostID uint + Path string + } + mock.lockListFiles.RLock() + calls = mock.calls.ListFiles + mock.lockListFiles.RUnlock() + return calls +} + +// Mkdir calls MkdirFunc. +func (mock *SSHRepo) Mkdir(hostID uint, path string) error { + if mock.MkdirFunc == nil { + panic("SSHRepo.MkdirFunc: method is nil but SSHRepo.Mkdir was just called") + } + callInfo := struct { + HostID uint + Path string + }{ + HostID: hostID, + Path: path, + } + mock.lockMkdir.Lock() + mock.calls.Mkdir = append(mock.calls.Mkdir, callInfo) + mock.lockMkdir.Unlock() + return mock.MkdirFunc(hostID, path) +} + +// MkdirCalls gets all the calls that were made to Mkdir. +// Check the length with: +// +// len(mockedSSHRepo.MkdirCalls()) +func (mock *SSHRepo) MkdirCalls() []struct { + HostID uint + Path string +} { + var calls []struct { + HostID uint + Path string + } + mock.lockMkdir.RLock() + calls = mock.calls.Mkdir + mock.lockMkdir.RUnlock() + return calls +} + +// TransferFile calls TransferFileFunc. +func (mock *SSHRepo) TransferFile(ctx context.Context, srcID uint, srcPath string, dstID uint, dstPath string, progress func(transferred int64, total int64)) error { + if mock.TransferFileFunc == nil { + panic("SSHRepo.TransferFileFunc: method is nil but SSHRepo.TransferFile was just called") + } + callInfo := struct { + Ctx context.Context + SrcID uint + SrcPath string + DstID uint + DstPath string + Progress func(transferred int64, total int64) + }{ + Ctx: ctx, + SrcID: srcID, + SrcPath: srcPath, + DstID: dstID, + DstPath: dstPath, + Progress: progress, + } + mock.lockTransferFile.Lock() + mock.calls.TransferFile = append(mock.calls.TransferFile, callInfo) + mock.lockTransferFile.Unlock() + return mock.TransferFileFunc(ctx, srcID, srcPath, dstID, dstPath, progress) +} + +// TransferFileCalls gets all the calls that were made to TransferFile. +// Check the length with: +// +// len(mockedSSHRepo.TransferFileCalls()) +func (mock *SSHRepo) TransferFileCalls() []struct { + Ctx context.Context + SrcID uint + SrcPath string + DstID uint + DstPath string + Progress func(transferred int64, total int64) +} { + var calls []struct { + Ctx context.Context + SrcID uint + SrcPath string + DstID uint + DstPath string + Progress func(transferred int64, total int64) + } + mock.lockTransferFile.RLock() + calls = mock.calls.TransferFile + mock.lockTransferFile.RUnlock() + return calls +} + +// Update calls UpdateFunc. +func (mock *SSHRepo) Update(req *request.SSHUpdate) error { + if mock.UpdateFunc == nil { + panic("SSHRepo.UpdateFunc: method is nil but SSHRepo.Update was just called") + } + callInfo := struct { + Req *request.SSHUpdate + }{ + Req: req, + } + mock.lockUpdate.Lock() + mock.calls.Update = append(mock.calls.Update, callInfo) + mock.lockUpdate.Unlock() + return mock.UpdateFunc(req) +} + +// UpdateCalls gets all the calls that were made to Update. +// Check the length with: +// +// len(mockedSSHRepo.UpdateCalls()) +func (mock *SSHRepo) UpdateCalls() []struct { + Req *request.SSHUpdate +} { + var calls []struct { + Req *request.SSHUpdate + } + mock.lockUpdate.RLock() + calls = mock.calls.Update + mock.lockUpdate.RUnlock() + return calls +} diff --git a/internal/mocks/biz/SafeRepo.go b/internal/mocks/biz/SafeRepo.go new file mode 100644 index 000000000..06fa3f8df --- /dev/null +++ b/internal/mocks/biz/SafeRepo.go @@ -0,0 +1,151 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that SafeRepo does implement biz.SafeRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.SafeRepo = &SafeRepo{} + +// SafeRepo is a mock implementation of biz.SafeRepo. +// +// func TestSomethingThatUsesSafeRepo(t *testing.T) { +// +// // make and configure a mocked biz.SafeRepo +// mockedSafeRepo := &SafeRepo{ +// FirewallRunningFunc: func() (bool, error) { +// panic("mock out the FirewallRunning method") +// }, +// GetPingStatusFunc: func() (bool, error) { +// panic("mock out the GetPingStatus method") +// }, +// SetPingStatusFunc: func(status bool) error { +// panic("mock out the SetPingStatus method") +// }, +// } +// +// // use mockedSafeRepo in code that requires biz.SafeRepo +// // and then make assertions. +// +// } +type SafeRepo struct { + // FirewallRunningFunc mocks the FirewallRunning method. + FirewallRunningFunc func() (bool, error) + + // GetPingStatusFunc mocks the GetPingStatus method. + GetPingStatusFunc func() (bool, error) + + // SetPingStatusFunc mocks the SetPingStatus method. + SetPingStatusFunc func(status bool) error + + // calls tracks calls to the methods. + calls struct { + // FirewallRunning holds details about calls to the FirewallRunning method. + FirewallRunning []struct { + } + // GetPingStatus holds details about calls to the GetPingStatus method. + GetPingStatus []struct { + } + // SetPingStatus holds details about calls to the SetPingStatus method. + SetPingStatus []struct { + // Status is the status argument value. + Status bool + } + } + lockFirewallRunning sync.RWMutex + lockGetPingStatus sync.RWMutex + lockSetPingStatus sync.RWMutex +} + +// FirewallRunning calls FirewallRunningFunc. +func (mock *SafeRepo) FirewallRunning() (bool, error) { + if mock.FirewallRunningFunc == nil { + panic("SafeRepo.FirewallRunningFunc: method is nil but SafeRepo.FirewallRunning was just called") + } + callInfo := struct { + }{} + mock.lockFirewallRunning.Lock() + mock.calls.FirewallRunning = append(mock.calls.FirewallRunning, callInfo) + mock.lockFirewallRunning.Unlock() + return mock.FirewallRunningFunc() +} + +// FirewallRunningCalls gets all the calls that were made to FirewallRunning. +// Check the length with: +// +// len(mockedSafeRepo.FirewallRunningCalls()) +func (mock *SafeRepo) FirewallRunningCalls() []struct { +} { + var calls []struct { + } + mock.lockFirewallRunning.RLock() + calls = mock.calls.FirewallRunning + mock.lockFirewallRunning.RUnlock() + return calls +} + +// GetPingStatus calls GetPingStatusFunc. +func (mock *SafeRepo) GetPingStatus() (bool, error) { + if mock.GetPingStatusFunc == nil { + panic("SafeRepo.GetPingStatusFunc: method is nil but SafeRepo.GetPingStatus was just called") + } + callInfo := struct { + }{} + mock.lockGetPingStatus.Lock() + mock.calls.GetPingStatus = append(mock.calls.GetPingStatus, callInfo) + mock.lockGetPingStatus.Unlock() + return mock.GetPingStatusFunc() +} + +// GetPingStatusCalls gets all the calls that were made to GetPingStatus. +// Check the length with: +// +// len(mockedSafeRepo.GetPingStatusCalls()) +func (mock *SafeRepo) GetPingStatusCalls() []struct { +} { + var calls []struct { + } + mock.lockGetPingStatus.RLock() + calls = mock.calls.GetPingStatus + mock.lockGetPingStatus.RUnlock() + return calls +} + +// SetPingStatus calls SetPingStatusFunc. +func (mock *SafeRepo) SetPingStatus(status bool) error { + if mock.SetPingStatusFunc == nil { + panic("SafeRepo.SetPingStatusFunc: method is nil but SafeRepo.SetPingStatus was just called") + } + callInfo := struct { + Status bool + }{ + Status: status, + } + mock.lockSetPingStatus.Lock() + mock.calls.SetPingStatus = append(mock.calls.SetPingStatus, callInfo) + mock.lockSetPingStatus.Unlock() + return mock.SetPingStatusFunc(status) +} + +// SetPingStatusCalls gets all the calls that were made to SetPingStatus. +// Check the length with: +// +// len(mockedSafeRepo.SetPingStatusCalls()) +func (mock *SafeRepo) SetPingStatusCalls() []struct { + Status bool +} { + var calls []struct { + Status bool + } + mock.lockSetPingStatus.RLock() + calls = mock.calls.SetPingStatus + mock.lockSetPingStatus.RUnlock() + return calls +} diff --git a/internal/mocks/biz/ScanEventRepo.go b/internal/mocks/biz/ScanEventRepo.go new file mode 100644 index 000000000..ecbd11d87 --- /dev/null +++ b/internal/mocks/biz/ScanEventRepo.go @@ -0,0 +1,487 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that ScanEventRepo does implement biz.ScanEventRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.ScanEventRepo = &ScanEventRepo{} + +// ScanEventRepo is a mock implementation of biz.ScanEventRepo. +// +// func TestSomethingThatUsesScanEventRepo(t *testing.T) { +// +// // make and configure a mocked biz.ScanEventRepo +// mockedScanEventRepo := &ScanEventRepo{ +// ClearFunc: func() error { +// panic("mock out the Clear method") +// }, +// ClearBeforeFunc: func(date string) error { +// panic("mock out the ClearBefore method") +// }, +// ListFunc: func(start string, end string, sourceIP string, port uint, location string, page uint, limit uint) ([]*biz.ScanEvent, uint, error) { +// panic("mock out the List method") +// }, +// SummaryFunc: func(start string, end string) (*biz.ScanSummary, error) { +// panic("mock out the Summary method") +// }, +// TopPortsFunc: func(start string, end string, limit uint) ([]*biz.ScanPortRank, error) { +// panic("mock out the TopPorts method") +// }, +// TopSourceIPsFunc: func(start string, end string, limit uint) ([]*biz.ScanSourceRank, error) { +// panic("mock out the TopSourceIPs method") +// }, +// TrendFunc: func(start string, end string) ([]*biz.ScanDayTrend, error) { +// panic("mock out the Trend method") +// }, +// UpsertFunc: func(events []*biz.ScanEvent) error { +// panic("mock out the Upsert method") +// }, +// VacuumDBFunc: func() error { +// panic("mock out the VacuumDB method") +// }, +// } +// +// // use mockedScanEventRepo in code that requires biz.ScanEventRepo +// // and then make assertions. +// +// } +type ScanEventRepo struct { + // ClearFunc mocks the Clear method. + ClearFunc func() error + + // ClearBeforeFunc mocks the ClearBefore method. + ClearBeforeFunc func(date string) error + + // ListFunc mocks the List method. + ListFunc func(start string, end string, sourceIP string, port uint, location string, page uint, limit uint) ([]*biz.ScanEvent, uint, error) + + // SummaryFunc mocks the Summary method. + SummaryFunc func(start string, end string) (*biz.ScanSummary, error) + + // TopPortsFunc mocks the TopPorts method. + TopPortsFunc func(start string, end string, limit uint) ([]*biz.ScanPortRank, error) + + // TopSourceIPsFunc mocks the TopSourceIPs method. + TopSourceIPsFunc func(start string, end string, limit uint) ([]*biz.ScanSourceRank, error) + + // TrendFunc mocks the Trend method. + TrendFunc func(start string, end string) ([]*biz.ScanDayTrend, error) + + // UpsertFunc mocks the Upsert method. + UpsertFunc func(events []*biz.ScanEvent) error + + // VacuumDBFunc mocks the VacuumDB method. + VacuumDBFunc func() error + + // calls tracks calls to the methods. + calls struct { + // Clear holds details about calls to the Clear method. + Clear []struct { + } + // ClearBefore holds details about calls to the ClearBefore method. + ClearBefore []struct { + // Date is the date argument value. + Date string + } + // List holds details about calls to the List method. + List []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // SourceIP is the sourceIP argument value. + SourceIP string + // Port is the port argument value. + Port uint + // Location is the location argument value. + Location string + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // Summary holds details about calls to the Summary method. + Summary []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + } + // TopPorts holds details about calls to the TopPorts method. + TopPorts []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Limit is the limit argument value. + Limit uint + } + // TopSourceIPs holds details about calls to the TopSourceIPs method. + TopSourceIPs []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Limit is the limit argument value. + Limit uint + } + // Trend holds details about calls to the Trend method. + Trend []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + } + // Upsert holds details about calls to the Upsert method. + Upsert []struct { + // Events is the events argument value. + Events []*biz.ScanEvent + } + // VacuumDB holds details about calls to the VacuumDB method. + VacuumDB []struct { + } + } + lockClear sync.RWMutex + lockClearBefore sync.RWMutex + lockList sync.RWMutex + lockSummary sync.RWMutex + lockTopPorts sync.RWMutex + lockTopSourceIPs sync.RWMutex + lockTrend sync.RWMutex + lockUpsert sync.RWMutex + lockVacuumDB sync.RWMutex +} + +// Clear calls ClearFunc. +func (mock *ScanEventRepo) Clear() error { + if mock.ClearFunc == nil { + panic("ScanEventRepo.ClearFunc: method is nil but ScanEventRepo.Clear was just called") + } + callInfo := struct { + }{} + mock.lockClear.Lock() + mock.calls.Clear = append(mock.calls.Clear, callInfo) + mock.lockClear.Unlock() + return mock.ClearFunc() +} + +// ClearCalls gets all the calls that were made to Clear. +// Check the length with: +// +// len(mockedScanEventRepo.ClearCalls()) +func (mock *ScanEventRepo) ClearCalls() []struct { +} { + var calls []struct { + } + mock.lockClear.RLock() + calls = mock.calls.Clear + mock.lockClear.RUnlock() + return calls +} + +// ClearBefore calls ClearBeforeFunc. +func (mock *ScanEventRepo) ClearBefore(date string) error { + if mock.ClearBeforeFunc == nil { + panic("ScanEventRepo.ClearBeforeFunc: method is nil but ScanEventRepo.ClearBefore was just called") + } + callInfo := struct { + Date string + }{ + Date: date, + } + mock.lockClearBefore.Lock() + mock.calls.ClearBefore = append(mock.calls.ClearBefore, callInfo) + mock.lockClearBefore.Unlock() + return mock.ClearBeforeFunc(date) +} + +// ClearBeforeCalls gets all the calls that were made to ClearBefore. +// Check the length with: +// +// len(mockedScanEventRepo.ClearBeforeCalls()) +func (mock *ScanEventRepo) ClearBeforeCalls() []struct { + Date string +} { + var calls []struct { + Date string + } + mock.lockClearBefore.RLock() + calls = mock.calls.ClearBefore + mock.lockClearBefore.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *ScanEventRepo) List(start string, end string, sourceIP string, port uint, location string, page uint, limit uint) ([]*biz.ScanEvent, uint, error) { + if mock.ListFunc == nil { + panic("ScanEventRepo.ListFunc: method is nil but ScanEventRepo.List was just called") + } + callInfo := struct { + Start string + End string + SourceIP string + Port uint + Location string + Page uint + Limit uint + }{ + Start: start, + End: end, + SourceIP: sourceIP, + Port: port, + Location: location, + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(start, end, sourceIP, port, location, page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedScanEventRepo.ListCalls()) +func (mock *ScanEventRepo) ListCalls() []struct { + Start string + End string + SourceIP string + Port uint + Location string + Page uint + Limit uint +} { + var calls []struct { + Start string + End string + SourceIP string + Port uint + Location string + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// Summary calls SummaryFunc. +func (mock *ScanEventRepo) Summary(start string, end string) (*biz.ScanSummary, error) { + if mock.SummaryFunc == nil { + panic("ScanEventRepo.SummaryFunc: method is nil but ScanEventRepo.Summary was just called") + } + callInfo := struct { + Start string + End string + }{ + Start: start, + End: end, + } + mock.lockSummary.Lock() + mock.calls.Summary = append(mock.calls.Summary, callInfo) + mock.lockSummary.Unlock() + return mock.SummaryFunc(start, end) +} + +// SummaryCalls gets all the calls that were made to Summary. +// Check the length with: +// +// len(mockedScanEventRepo.SummaryCalls()) +func (mock *ScanEventRepo) SummaryCalls() []struct { + Start string + End string +} { + var calls []struct { + Start string + End string + } + mock.lockSummary.RLock() + calls = mock.calls.Summary + mock.lockSummary.RUnlock() + return calls +} + +// TopPorts calls TopPortsFunc. +func (mock *ScanEventRepo) TopPorts(start string, end string, limit uint) ([]*biz.ScanPortRank, error) { + if mock.TopPortsFunc == nil { + panic("ScanEventRepo.TopPortsFunc: method is nil but ScanEventRepo.TopPorts was just called") + } + callInfo := struct { + Start string + End string + Limit uint + }{ + Start: start, + End: end, + Limit: limit, + } + mock.lockTopPorts.Lock() + mock.calls.TopPorts = append(mock.calls.TopPorts, callInfo) + mock.lockTopPorts.Unlock() + return mock.TopPortsFunc(start, end, limit) +} + +// TopPortsCalls gets all the calls that were made to TopPorts. +// Check the length with: +// +// len(mockedScanEventRepo.TopPortsCalls()) +func (mock *ScanEventRepo) TopPortsCalls() []struct { + Start string + End string + Limit uint +} { + var calls []struct { + Start string + End string + Limit uint + } + mock.lockTopPorts.RLock() + calls = mock.calls.TopPorts + mock.lockTopPorts.RUnlock() + return calls +} + +// TopSourceIPs calls TopSourceIPsFunc. +func (mock *ScanEventRepo) TopSourceIPs(start string, end string, limit uint) ([]*biz.ScanSourceRank, error) { + if mock.TopSourceIPsFunc == nil { + panic("ScanEventRepo.TopSourceIPsFunc: method is nil but ScanEventRepo.TopSourceIPs was just called") + } + callInfo := struct { + Start string + End string + Limit uint + }{ + Start: start, + End: end, + Limit: limit, + } + mock.lockTopSourceIPs.Lock() + mock.calls.TopSourceIPs = append(mock.calls.TopSourceIPs, callInfo) + mock.lockTopSourceIPs.Unlock() + return mock.TopSourceIPsFunc(start, end, limit) +} + +// TopSourceIPsCalls gets all the calls that were made to TopSourceIPs. +// Check the length with: +// +// len(mockedScanEventRepo.TopSourceIPsCalls()) +func (mock *ScanEventRepo) TopSourceIPsCalls() []struct { + Start string + End string + Limit uint +} { + var calls []struct { + Start string + End string + Limit uint + } + mock.lockTopSourceIPs.RLock() + calls = mock.calls.TopSourceIPs + mock.lockTopSourceIPs.RUnlock() + return calls +} + +// Trend calls TrendFunc. +func (mock *ScanEventRepo) Trend(start string, end string) ([]*biz.ScanDayTrend, error) { + if mock.TrendFunc == nil { + panic("ScanEventRepo.TrendFunc: method is nil but ScanEventRepo.Trend was just called") + } + callInfo := struct { + Start string + End string + }{ + Start: start, + End: end, + } + mock.lockTrend.Lock() + mock.calls.Trend = append(mock.calls.Trend, callInfo) + mock.lockTrend.Unlock() + return mock.TrendFunc(start, end) +} + +// TrendCalls gets all the calls that were made to Trend. +// Check the length with: +// +// len(mockedScanEventRepo.TrendCalls()) +func (mock *ScanEventRepo) TrendCalls() []struct { + Start string + End string +} { + var calls []struct { + Start string + End string + } + mock.lockTrend.RLock() + calls = mock.calls.Trend + mock.lockTrend.RUnlock() + return calls +} + +// Upsert calls UpsertFunc. +func (mock *ScanEventRepo) Upsert(events []*biz.ScanEvent) error { + if mock.UpsertFunc == nil { + panic("ScanEventRepo.UpsertFunc: method is nil but ScanEventRepo.Upsert was just called") + } + callInfo := struct { + Events []*biz.ScanEvent + }{ + Events: events, + } + mock.lockUpsert.Lock() + mock.calls.Upsert = append(mock.calls.Upsert, callInfo) + mock.lockUpsert.Unlock() + return mock.UpsertFunc(events) +} + +// UpsertCalls gets all the calls that were made to Upsert. +// Check the length with: +// +// len(mockedScanEventRepo.UpsertCalls()) +func (mock *ScanEventRepo) UpsertCalls() []struct { + Events []*biz.ScanEvent +} { + var calls []struct { + Events []*biz.ScanEvent + } + mock.lockUpsert.RLock() + calls = mock.calls.Upsert + mock.lockUpsert.RUnlock() + return calls +} + +// VacuumDB calls VacuumDBFunc. +func (mock *ScanEventRepo) VacuumDB() error { + if mock.VacuumDBFunc == nil { + panic("ScanEventRepo.VacuumDBFunc: method is nil but ScanEventRepo.VacuumDB was just called") + } + callInfo := struct { + }{} + mock.lockVacuumDB.Lock() + mock.calls.VacuumDB = append(mock.calls.VacuumDB, callInfo) + mock.lockVacuumDB.Unlock() + return mock.VacuumDBFunc() +} + +// VacuumDBCalls gets all the calls that were made to VacuumDB. +// Check the length with: +// +// len(mockedScanEventRepo.VacuumDBCalls()) +func (mock *ScanEventRepo) VacuumDBCalls() []struct { +} { + var calls []struct { + } + mock.lockVacuumDB.RLock() + calls = mock.calls.VacuumDB + mock.lockVacuumDB.RUnlock() + return calls +} diff --git a/internal/mocks/biz/SettingRepo.go b/internal/mocks/biz/SettingRepo.go new file mode 100644 index 000000000..4ef2842d7 --- /dev/null +++ b/internal/mocks/biz/SettingRepo.go @@ -0,0 +1,415 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" +) + +// Ensure that SettingRepo does implement biz.SettingRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.SettingRepo = &SettingRepo{} + +// SettingRepo is a mock implementation of biz.SettingRepo. +// +// func TestSomethingThatUsesSettingRepo(t *testing.T) { +// +// // make and configure a mocked biz.SettingRepo +// mockedSettingRepo := &SettingRepo{ +// DeleteFunc: func(key biz.SettingKey) error { +// panic("mock out the Delete method") +// }, +// GetFunc: func(key biz.SettingKey, defaultValue ...string) (string, error) { +// panic("mock out the Get method") +// }, +// GetBoolFunc: func(key biz.SettingKey, defaultValue ...bool) (bool, error) { +// panic("mock out the GetBool method") +// }, +// GetIntFunc: func(key biz.SettingKey, defaultValue ...int) (int, error) { +// panic("mock out the GetInt method") +// }, +// GetPanelFunc: func() (*request.SettingPanel, error) { +// panic("mock out the GetPanel method") +// }, +// GetSliceFunc: func(key biz.SettingKey, defaultValue ...[]string) ([]string, error) { +// panic("mock out the GetSlice method") +// }, +// SetFunc: func(key biz.SettingKey, value string) error { +// panic("mock out the Set method") +// }, +// SetSliceFunc: func(key biz.SettingKey, value []string) error { +// panic("mock out the SetSlice method") +// }, +// } +// +// // use mockedSettingRepo in code that requires biz.SettingRepo +// // and then make assertions. +// +// } +type SettingRepo struct { + // DeleteFunc mocks the Delete method. + DeleteFunc func(key biz.SettingKey) error + + // GetFunc mocks the Get method. + GetFunc func(key biz.SettingKey, defaultValue ...string) (string, error) + + // GetBoolFunc mocks the GetBool method. + GetBoolFunc func(key biz.SettingKey, defaultValue ...bool) (bool, error) + + // GetIntFunc mocks the GetInt method. + GetIntFunc func(key biz.SettingKey, defaultValue ...int) (int, error) + + // GetPanelFunc mocks the GetPanel method. + GetPanelFunc func() (*request.SettingPanel, error) + + // GetSliceFunc mocks the GetSlice method. + GetSliceFunc func(key biz.SettingKey, defaultValue ...[]string) ([]string, error) + + // SetFunc mocks the Set method. + SetFunc func(key biz.SettingKey, value string) error + + // SetSliceFunc mocks the SetSlice method. + SetSliceFunc func(key biz.SettingKey, value []string) error + + // calls tracks calls to the methods. + calls struct { + // Delete holds details about calls to the Delete method. + Delete []struct { + // Key is the key argument value. + Key biz.SettingKey + } + // Get holds details about calls to the Get method. + Get []struct { + // Key is the key argument value. + Key biz.SettingKey + // DefaultValue is the defaultValue argument value. + DefaultValue []string + } + // GetBool holds details about calls to the GetBool method. + GetBool []struct { + // Key is the key argument value. + Key biz.SettingKey + // DefaultValue is the defaultValue argument value. + DefaultValue []bool + } + // GetInt holds details about calls to the GetInt method. + GetInt []struct { + // Key is the key argument value. + Key biz.SettingKey + // DefaultValue is the defaultValue argument value. + DefaultValue []int + } + // GetPanel holds details about calls to the GetPanel method. + GetPanel []struct { + } + // GetSlice holds details about calls to the GetSlice method. + GetSlice []struct { + // Key is the key argument value. + Key biz.SettingKey + // DefaultValue is the defaultValue argument value. + DefaultValue [][]string + } + // Set holds details about calls to the Set method. + Set []struct { + // Key is the key argument value. + Key biz.SettingKey + // Value is the value argument value. + Value string + } + // SetSlice holds details about calls to the SetSlice method. + SetSlice []struct { + // Key is the key argument value. + Key biz.SettingKey + // Value is the value argument value. + Value []string + } + } + lockDelete sync.RWMutex + lockGet sync.RWMutex + lockGetBool sync.RWMutex + lockGetInt sync.RWMutex + lockGetPanel sync.RWMutex + lockGetSlice sync.RWMutex + lockSet sync.RWMutex + lockSetSlice sync.RWMutex +} + +// Delete calls DeleteFunc. +func (mock *SettingRepo) Delete(key biz.SettingKey) error { + if mock.DeleteFunc == nil { + panic("SettingRepo.DeleteFunc: method is nil but SettingRepo.Delete was just called") + } + callInfo := struct { + Key biz.SettingKey + }{ + Key: key, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(key) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedSettingRepo.DeleteCalls()) +func (mock *SettingRepo) DeleteCalls() []struct { + Key biz.SettingKey +} { + var calls []struct { + Key biz.SettingKey + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *SettingRepo) Get(key biz.SettingKey, defaultValue ...string) (string, error) { + if mock.GetFunc == nil { + panic("SettingRepo.GetFunc: method is nil but SettingRepo.Get was just called") + } + callInfo := struct { + Key biz.SettingKey + DefaultValue []string + }{ + Key: key, + DefaultValue: defaultValue, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(key, defaultValue...) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedSettingRepo.GetCalls()) +func (mock *SettingRepo) GetCalls() []struct { + Key biz.SettingKey + DefaultValue []string +} { + var calls []struct { + Key biz.SettingKey + DefaultValue []string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// GetBool calls GetBoolFunc. +func (mock *SettingRepo) GetBool(key biz.SettingKey, defaultValue ...bool) (bool, error) { + if mock.GetBoolFunc == nil { + panic("SettingRepo.GetBoolFunc: method is nil but SettingRepo.GetBool was just called") + } + callInfo := struct { + Key biz.SettingKey + DefaultValue []bool + }{ + Key: key, + DefaultValue: defaultValue, + } + mock.lockGetBool.Lock() + mock.calls.GetBool = append(mock.calls.GetBool, callInfo) + mock.lockGetBool.Unlock() + return mock.GetBoolFunc(key, defaultValue...) +} + +// GetBoolCalls gets all the calls that were made to GetBool. +// Check the length with: +// +// len(mockedSettingRepo.GetBoolCalls()) +func (mock *SettingRepo) GetBoolCalls() []struct { + Key biz.SettingKey + DefaultValue []bool +} { + var calls []struct { + Key biz.SettingKey + DefaultValue []bool + } + mock.lockGetBool.RLock() + calls = mock.calls.GetBool + mock.lockGetBool.RUnlock() + return calls +} + +// GetInt calls GetIntFunc. +func (mock *SettingRepo) GetInt(key biz.SettingKey, defaultValue ...int) (int, error) { + if mock.GetIntFunc == nil { + panic("SettingRepo.GetIntFunc: method is nil but SettingRepo.GetInt was just called") + } + callInfo := struct { + Key biz.SettingKey + DefaultValue []int + }{ + Key: key, + DefaultValue: defaultValue, + } + mock.lockGetInt.Lock() + mock.calls.GetInt = append(mock.calls.GetInt, callInfo) + mock.lockGetInt.Unlock() + return mock.GetIntFunc(key, defaultValue...) +} + +// GetIntCalls gets all the calls that were made to GetInt. +// Check the length with: +// +// len(mockedSettingRepo.GetIntCalls()) +func (mock *SettingRepo) GetIntCalls() []struct { + Key biz.SettingKey + DefaultValue []int +} { + var calls []struct { + Key biz.SettingKey + DefaultValue []int + } + mock.lockGetInt.RLock() + calls = mock.calls.GetInt + mock.lockGetInt.RUnlock() + return calls +} + +// GetPanel calls GetPanelFunc. +func (mock *SettingRepo) GetPanel() (*request.SettingPanel, error) { + if mock.GetPanelFunc == nil { + panic("SettingRepo.GetPanelFunc: method is nil but SettingRepo.GetPanel was just called") + } + callInfo := struct { + }{} + mock.lockGetPanel.Lock() + mock.calls.GetPanel = append(mock.calls.GetPanel, callInfo) + mock.lockGetPanel.Unlock() + return mock.GetPanelFunc() +} + +// GetPanelCalls gets all the calls that were made to GetPanel. +// Check the length with: +// +// len(mockedSettingRepo.GetPanelCalls()) +func (mock *SettingRepo) GetPanelCalls() []struct { +} { + var calls []struct { + } + mock.lockGetPanel.RLock() + calls = mock.calls.GetPanel + mock.lockGetPanel.RUnlock() + return calls +} + +// GetSlice calls GetSliceFunc. +func (mock *SettingRepo) GetSlice(key biz.SettingKey, defaultValue ...[]string) ([]string, error) { + if mock.GetSliceFunc == nil { + panic("SettingRepo.GetSliceFunc: method is nil but SettingRepo.GetSlice was just called") + } + callInfo := struct { + Key biz.SettingKey + DefaultValue [][]string + }{ + Key: key, + DefaultValue: defaultValue, + } + mock.lockGetSlice.Lock() + mock.calls.GetSlice = append(mock.calls.GetSlice, callInfo) + mock.lockGetSlice.Unlock() + return mock.GetSliceFunc(key, defaultValue...) +} + +// GetSliceCalls gets all the calls that were made to GetSlice. +// Check the length with: +// +// len(mockedSettingRepo.GetSliceCalls()) +func (mock *SettingRepo) GetSliceCalls() []struct { + Key biz.SettingKey + DefaultValue [][]string +} { + var calls []struct { + Key biz.SettingKey + DefaultValue [][]string + } + mock.lockGetSlice.RLock() + calls = mock.calls.GetSlice + mock.lockGetSlice.RUnlock() + return calls +} + +// Set calls SetFunc. +func (mock *SettingRepo) Set(key biz.SettingKey, value string) error { + if mock.SetFunc == nil { + panic("SettingRepo.SetFunc: method is nil but SettingRepo.Set was just called") + } + callInfo := struct { + Key biz.SettingKey + Value string + }{ + Key: key, + Value: value, + } + mock.lockSet.Lock() + mock.calls.Set = append(mock.calls.Set, callInfo) + mock.lockSet.Unlock() + return mock.SetFunc(key, value) +} + +// SetCalls gets all the calls that were made to Set. +// Check the length with: +// +// len(mockedSettingRepo.SetCalls()) +func (mock *SettingRepo) SetCalls() []struct { + Key biz.SettingKey + Value string +} { + var calls []struct { + Key biz.SettingKey + Value string + } + mock.lockSet.RLock() + calls = mock.calls.Set + mock.lockSet.RUnlock() + return calls +} + +// SetSlice calls SetSliceFunc. +func (mock *SettingRepo) SetSlice(key biz.SettingKey, value []string) error { + if mock.SetSliceFunc == nil { + panic("SettingRepo.SetSliceFunc: method is nil but SettingRepo.SetSlice was just called") + } + callInfo := struct { + Key biz.SettingKey + Value []string + }{ + Key: key, + Value: value, + } + mock.lockSetSlice.Lock() + mock.calls.SetSlice = append(mock.calls.SetSlice, callInfo) + mock.lockSetSlice.Unlock() + return mock.SetSliceFunc(key, value) +} + +// SetSliceCalls gets all the calls that were made to SetSlice. +// Check the length with: +// +// len(mockedSettingRepo.SetSliceCalls()) +func (mock *SettingRepo) SetSliceCalls() []struct { + Key biz.SettingKey + Value []string +} { + var calls []struct { + Key biz.SettingKey + Value []string + } + mock.lockSetSlice.RLock() + calls = mock.calls.SetSlice + mock.lockSetSlice.RUnlock() + return calls +} diff --git a/internal/mocks/biz/TamperRepo.go b/internal/mocks/biz/TamperRepo.go new file mode 100644 index 000000000..0a08bd15e --- /dev/null +++ b/internal/mocks/biz/TamperRepo.go @@ -0,0 +1,503 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + "time" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that TamperRepo does implement biz.TamperRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.TamperRepo = &TamperRepo{} + +// TamperRepo is a mock implementation of biz.TamperRepo. +// +// func TestSomethingThatUsesTamperRepo(t *testing.T) { +// +// // make and configure a mocked biz.TamperRepo +// mockedTamperRepo := &TamperRepo{ +// AddLogsFunc: func(logs []*biz.TamperLog) error { +// panic("mock out the AddLogs method") +// }, +// ClearLogsFunc: func() error { +// panic("mock out the ClearLogs method") +// }, +// ClearLogsBeforeFunc: func(t time.Time) error { +// panic("mock out the ClearLogsBefore method") +// }, +// CreateRuleFunc: func(rule *biz.TamperRule) error { +// panic("mock out the CreateRule method") +// }, +// DeleteRuleFunc: func(id uint) error { +// panic("mock out the DeleteRule method") +// }, +// GetRuleFunc: func(id uint) (*biz.TamperRule, error) { +// panic("mock out the GetRule method") +// }, +// GetRuleByNameFunc: func(name string) (*biz.TamperRule, error) { +// panic("mock out the GetRuleByName method") +// }, +// ListLogsFunc: func(page uint, limit uint) ([]*biz.TamperLog, int64, error) { +// panic("mock out the ListLogs method") +// }, +// ListRulesFunc: func() ([]*biz.TamperRule, error) { +// panic("mock out the ListRules method") +// }, +// UpdateRuleFunc: func(rule *biz.TamperRule) error { +// panic("mock out the UpdateRule method") +// }, +// VacuumDBFunc: func() error { +// panic("mock out the VacuumDB method") +// }, +// } +// +// // use mockedTamperRepo in code that requires biz.TamperRepo +// // and then make assertions. +// +// } +type TamperRepo struct { + // AddLogsFunc mocks the AddLogs method. + AddLogsFunc func(logs []*biz.TamperLog) error + + // ClearLogsFunc mocks the ClearLogs method. + ClearLogsFunc func() error + + // ClearLogsBeforeFunc mocks the ClearLogsBefore method. + ClearLogsBeforeFunc func(t time.Time) error + + // CreateRuleFunc mocks the CreateRule method. + CreateRuleFunc func(rule *biz.TamperRule) error + + // DeleteRuleFunc mocks the DeleteRule method. + DeleteRuleFunc func(id uint) error + + // GetRuleFunc mocks the GetRule method. + GetRuleFunc func(id uint) (*biz.TamperRule, error) + + // GetRuleByNameFunc mocks the GetRuleByName method. + GetRuleByNameFunc func(name string) (*biz.TamperRule, error) + + // ListLogsFunc mocks the ListLogs method. + ListLogsFunc func(page uint, limit uint) ([]*biz.TamperLog, int64, error) + + // ListRulesFunc mocks the ListRules method. + ListRulesFunc func() ([]*biz.TamperRule, error) + + // UpdateRuleFunc mocks the UpdateRule method. + UpdateRuleFunc func(rule *biz.TamperRule) error + + // VacuumDBFunc mocks the VacuumDB method. + VacuumDBFunc func() error + + // calls tracks calls to the methods. + calls struct { + // AddLogs holds details about calls to the AddLogs method. + AddLogs []struct { + // Logs is the logs argument value. + Logs []*biz.TamperLog + } + // ClearLogs holds details about calls to the ClearLogs method. + ClearLogs []struct { + } + // ClearLogsBefore holds details about calls to the ClearLogsBefore method. + ClearLogsBefore []struct { + // T is the t argument value. + T time.Time + } + // CreateRule holds details about calls to the CreateRule method. + CreateRule []struct { + // Rule is the rule argument value. + Rule *biz.TamperRule + } + // DeleteRule holds details about calls to the DeleteRule method. + DeleteRule []struct { + // ID is the id argument value. + ID uint + } + // GetRule holds details about calls to the GetRule method. + GetRule []struct { + // ID is the id argument value. + ID uint + } + // GetRuleByName holds details about calls to the GetRuleByName method. + GetRuleByName []struct { + // Name is the name argument value. + Name string + } + // ListLogs holds details about calls to the ListLogs method. + ListLogs []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // ListRules holds details about calls to the ListRules method. + ListRules []struct { + } + // UpdateRule holds details about calls to the UpdateRule method. + UpdateRule []struct { + // Rule is the rule argument value. + Rule *biz.TamperRule + } + // VacuumDB holds details about calls to the VacuumDB method. + VacuumDB []struct { + } + } + lockAddLogs sync.RWMutex + lockClearLogs sync.RWMutex + lockClearLogsBefore sync.RWMutex + lockCreateRule sync.RWMutex + lockDeleteRule sync.RWMutex + lockGetRule sync.RWMutex + lockGetRuleByName sync.RWMutex + lockListLogs sync.RWMutex + lockListRules sync.RWMutex + lockUpdateRule sync.RWMutex + lockVacuumDB sync.RWMutex +} + +// AddLogs calls AddLogsFunc. +func (mock *TamperRepo) AddLogs(logs []*biz.TamperLog) error { + if mock.AddLogsFunc == nil { + panic("TamperRepo.AddLogsFunc: method is nil but TamperRepo.AddLogs was just called") + } + callInfo := struct { + Logs []*biz.TamperLog + }{ + Logs: logs, + } + mock.lockAddLogs.Lock() + mock.calls.AddLogs = append(mock.calls.AddLogs, callInfo) + mock.lockAddLogs.Unlock() + return mock.AddLogsFunc(logs) +} + +// AddLogsCalls gets all the calls that were made to AddLogs. +// Check the length with: +// +// len(mockedTamperRepo.AddLogsCalls()) +func (mock *TamperRepo) AddLogsCalls() []struct { + Logs []*biz.TamperLog +} { + var calls []struct { + Logs []*biz.TamperLog + } + mock.lockAddLogs.RLock() + calls = mock.calls.AddLogs + mock.lockAddLogs.RUnlock() + return calls +} + +// ClearLogs calls ClearLogsFunc. +func (mock *TamperRepo) ClearLogs() error { + if mock.ClearLogsFunc == nil { + panic("TamperRepo.ClearLogsFunc: method is nil but TamperRepo.ClearLogs was just called") + } + callInfo := struct { + }{} + mock.lockClearLogs.Lock() + mock.calls.ClearLogs = append(mock.calls.ClearLogs, callInfo) + mock.lockClearLogs.Unlock() + return mock.ClearLogsFunc() +} + +// ClearLogsCalls gets all the calls that were made to ClearLogs. +// Check the length with: +// +// len(mockedTamperRepo.ClearLogsCalls()) +func (mock *TamperRepo) ClearLogsCalls() []struct { +} { + var calls []struct { + } + mock.lockClearLogs.RLock() + calls = mock.calls.ClearLogs + mock.lockClearLogs.RUnlock() + return calls +} + +// ClearLogsBefore calls ClearLogsBeforeFunc. +func (mock *TamperRepo) ClearLogsBefore(t time.Time) error { + if mock.ClearLogsBeforeFunc == nil { + panic("TamperRepo.ClearLogsBeforeFunc: method is nil but TamperRepo.ClearLogsBefore was just called") + } + callInfo := struct { + T time.Time + }{ + T: t, + } + mock.lockClearLogsBefore.Lock() + mock.calls.ClearLogsBefore = append(mock.calls.ClearLogsBefore, callInfo) + mock.lockClearLogsBefore.Unlock() + return mock.ClearLogsBeforeFunc(t) +} + +// ClearLogsBeforeCalls gets all the calls that were made to ClearLogsBefore. +// Check the length with: +// +// len(mockedTamperRepo.ClearLogsBeforeCalls()) +func (mock *TamperRepo) ClearLogsBeforeCalls() []struct { + T time.Time +} { + var calls []struct { + T time.Time + } + mock.lockClearLogsBefore.RLock() + calls = mock.calls.ClearLogsBefore + mock.lockClearLogsBefore.RUnlock() + return calls +} + +// CreateRule calls CreateRuleFunc. +func (mock *TamperRepo) CreateRule(rule *biz.TamperRule) error { + if mock.CreateRuleFunc == nil { + panic("TamperRepo.CreateRuleFunc: method is nil but TamperRepo.CreateRule was just called") + } + callInfo := struct { + Rule *biz.TamperRule + }{ + Rule: rule, + } + mock.lockCreateRule.Lock() + mock.calls.CreateRule = append(mock.calls.CreateRule, callInfo) + mock.lockCreateRule.Unlock() + return mock.CreateRuleFunc(rule) +} + +// CreateRuleCalls gets all the calls that were made to CreateRule. +// Check the length with: +// +// len(mockedTamperRepo.CreateRuleCalls()) +func (mock *TamperRepo) CreateRuleCalls() []struct { + Rule *biz.TamperRule +} { + var calls []struct { + Rule *biz.TamperRule + } + mock.lockCreateRule.RLock() + calls = mock.calls.CreateRule + mock.lockCreateRule.RUnlock() + return calls +} + +// DeleteRule calls DeleteRuleFunc. +func (mock *TamperRepo) DeleteRule(id uint) error { + if mock.DeleteRuleFunc == nil { + panic("TamperRepo.DeleteRuleFunc: method is nil but TamperRepo.DeleteRule was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDeleteRule.Lock() + mock.calls.DeleteRule = append(mock.calls.DeleteRule, callInfo) + mock.lockDeleteRule.Unlock() + return mock.DeleteRuleFunc(id) +} + +// DeleteRuleCalls gets all the calls that were made to DeleteRule. +// Check the length with: +// +// len(mockedTamperRepo.DeleteRuleCalls()) +func (mock *TamperRepo) DeleteRuleCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDeleteRule.RLock() + calls = mock.calls.DeleteRule + mock.lockDeleteRule.RUnlock() + return calls +} + +// GetRule calls GetRuleFunc. +func (mock *TamperRepo) GetRule(id uint) (*biz.TamperRule, error) { + if mock.GetRuleFunc == nil { + panic("TamperRepo.GetRuleFunc: method is nil but TamperRepo.GetRule was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGetRule.Lock() + mock.calls.GetRule = append(mock.calls.GetRule, callInfo) + mock.lockGetRule.Unlock() + return mock.GetRuleFunc(id) +} + +// GetRuleCalls gets all the calls that were made to GetRule. +// Check the length with: +// +// len(mockedTamperRepo.GetRuleCalls()) +func (mock *TamperRepo) GetRuleCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGetRule.RLock() + calls = mock.calls.GetRule + mock.lockGetRule.RUnlock() + return calls +} + +// GetRuleByName calls GetRuleByNameFunc. +func (mock *TamperRepo) GetRuleByName(name string) (*biz.TamperRule, error) { + if mock.GetRuleByNameFunc == nil { + panic("TamperRepo.GetRuleByNameFunc: method is nil but TamperRepo.GetRuleByName was just called") + } + callInfo := struct { + Name string + }{ + Name: name, + } + mock.lockGetRuleByName.Lock() + mock.calls.GetRuleByName = append(mock.calls.GetRuleByName, callInfo) + mock.lockGetRuleByName.Unlock() + return mock.GetRuleByNameFunc(name) +} + +// GetRuleByNameCalls gets all the calls that were made to GetRuleByName. +// Check the length with: +// +// len(mockedTamperRepo.GetRuleByNameCalls()) +func (mock *TamperRepo) GetRuleByNameCalls() []struct { + Name string +} { + var calls []struct { + Name string + } + mock.lockGetRuleByName.RLock() + calls = mock.calls.GetRuleByName + mock.lockGetRuleByName.RUnlock() + return calls +} + +// ListLogs calls ListLogsFunc. +func (mock *TamperRepo) ListLogs(page uint, limit uint) ([]*biz.TamperLog, int64, error) { + if mock.ListLogsFunc == nil { + panic("TamperRepo.ListLogsFunc: method is nil but TamperRepo.ListLogs was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockListLogs.Lock() + mock.calls.ListLogs = append(mock.calls.ListLogs, callInfo) + mock.lockListLogs.Unlock() + return mock.ListLogsFunc(page, limit) +} + +// ListLogsCalls gets all the calls that were made to ListLogs. +// Check the length with: +// +// len(mockedTamperRepo.ListLogsCalls()) +func (mock *TamperRepo) ListLogsCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockListLogs.RLock() + calls = mock.calls.ListLogs + mock.lockListLogs.RUnlock() + return calls +} + +// ListRules calls ListRulesFunc. +func (mock *TamperRepo) ListRules() ([]*biz.TamperRule, error) { + if mock.ListRulesFunc == nil { + panic("TamperRepo.ListRulesFunc: method is nil but TamperRepo.ListRules was just called") + } + callInfo := struct { + }{} + mock.lockListRules.Lock() + mock.calls.ListRules = append(mock.calls.ListRules, callInfo) + mock.lockListRules.Unlock() + return mock.ListRulesFunc() +} + +// ListRulesCalls gets all the calls that were made to ListRules. +// Check the length with: +// +// len(mockedTamperRepo.ListRulesCalls()) +func (mock *TamperRepo) ListRulesCalls() []struct { +} { + var calls []struct { + } + mock.lockListRules.RLock() + calls = mock.calls.ListRules + mock.lockListRules.RUnlock() + return calls +} + +// UpdateRule calls UpdateRuleFunc. +func (mock *TamperRepo) UpdateRule(rule *biz.TamperRule) error { + if mock.UpdateRuleFunc == nil { + panic("TamperRepo.UpdateRuleFunc: method is nil but TamperRepo.UpdateRule was just called") + } + callInfo := struct { + Rule *biz.TamperRule + }{ + Rule: rule, + } + mock.lockUpdateRule.Lock() + mock.calls.UpdateRule = append(mock.calls.UpdateRule, callInfo) + mock.lockUpdateRule.Unlock() + return mock.UpdateRuleFunc(rule) +} + +// UpdateRuleCalls gets all the calls that were made to UpdateRule. +// Check the length with: +// +// len(mockedTamperRepo.UpdateRuleCalls()) +func (mock *TamperRepo) UpdateRuleCalls() []struct { + Rule *biz.TamperRule +} { + var calls []struct { + Rule *biz.TamperRule + } + mock.lockUpdateRule.RLock() + calls = mock.calls.UpdateRule + mock.lockUpdateRule.RUnlock() + return calls +} + +// VacuumDB calls VacuumDBFunc. +func (mock *TamperRepo) VacuumDB() error { + if mock.VacuumDBFunc == nil { + panic("TamperRepo.VacuumDBFunc: method is nil but TamperRepo.VacuumDB was just called") + } + callInfo := struct { + }{} + mock.lockVacuumDB.Lock() + mock.calls.VacuumDB = append(mock.calls.VacuumDB, callInfo) + mock.lockVacuumDB.Unlock() + return mock.VacuumDBFunc() +} + +// VacuumDBCalls gets all the calls that were made to VacuumDB. +// Check the length with: +// +// len(mockedTamperRepo.VacuumDBCalls()) +func (mock *TamperRepo) VacuumDBCalls() []struct { +} { + var calls []struct { + } + mock.lockVacuumDB.RLock() + calls = mock.calls.VacuumDB + mock.lockVacuumDB.RUnlock() + return calls +} diff --git a/internal/mocks/biz/TaskRepo.go b/internal/mocks/biz/TaskRepo.go new file mode 100644 index 000000000..f15ad3a54 --- /dev/null +++ b/internal/mocks/biz/TaskRepo.go @@ -0,0 +1,396 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that TaskRepo does implement biz.TaskRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.TaskRepo = &TaskRepo{} + +// TaskRepo is a mock implementation of biz.TaskRepo. +// +// func TestSomethingThatUsesTaskRepo(t *testing.T) { +// +// // make and configure a mocked biz.TaskRepo +// mockedTaskRepo := &TaskRepo{ +// CancelFunc: func(id uint) error { +// panic("mock out the Cancel method") +// }, +// DeleteFunc: func(id uint) error { +// panic("mock out the Delete method") +// }, +// GetFunc: func(id uint) (*biz.Task, error) { +// panic("mock out the Get method") +// }, +// HasRunningTaskFunc: func() bool { +// panic("mock out the HasRunningTask method") +// }, +// ListFunc: func(page uint, limit uint) ([]*biz.Task, int64, error) { +// panic("mock out the List method") +// }, +// PushFunc: func(task *biz.Task) error { +// panic("mock out the Push method") +// }, +// UpdateLogFunc: func(id uint, log string) error { +// panic("mock out the UpdateLog method") +// }, +// UpdateStatusFunc: func(id uint, status biz.TaskStatus) error { +// panic("mock out the UpdateStatus method") +// }, +// } +// +// // use mockedTaskRepo in code that requires biz.TaskRepo +// // and then make assertions. +// +// } +type TaskRepo struct { + // CancelFunc mocks the Cancel method. + CancelFunc func(id uint) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) error + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*biz.Task, error) + + // HasRunningTaskFunc mocks the HasRunningTask method. + HasRunningTaskFunc func() bool + + // ListFunc mocks the List method. + ListFunc func(page uint, limit uint) ([]*biz.Task, int64, error) + + // PushFunc mocks the Push method. + PushFunc func(task *biz.Task) error + + // UpdateLogFunc mocks the UpdateLog method. + UpdateLogFunc func(id uint, log string) error + + // UpdateStatusFunc mocks the UpdateStatus method. + UpdateStatusFunc func(id uint, status biz.TaskStatus) error + + // calls tracks calls to the methods. + calls struct { + // Cancel holds details about calls to the Cancel method. + Cancel []struct { + // ID is the id argument value. + ID uint + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // HasRunningTask holds details about calls to the HasRunningTask method. + HasRunningTask []struct { + } + // List holds details about calls to the List method. + List []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // Push holds details about calls to the Push method. + Push []struct { + // Task is the task argument value. + Task *biz.Task + } + // UpdateLog holds details about calls to the UpdateLog method. + UpdateLog []struct { + // ID is the id argument value. + ID uint + // Log is the log argument value. + Log string + } + // UpdateStatus holds details about calls to the UpdateStatus method. + UpdateStatus []struct { + // ID is the id argument value. + ID uint + // Status is the status argument value. + Status biz.TaskStatus + } + } + lockCancel sync.RWMutex + lockDelete sync.RWMutex + lockGet sync.RWMutex + lockHasRunningTask sync.RWMutex + lockList sync.RWMutex + lockPush sync.RWMutex + lockUpdateLog sync.RWMutex + lockUpdateStatus sync.RWMutex +} + +// Cancel calls CancelFunc. +func (mock *TaskRepo) Cancel(id uint) error { + if mock.CancelFunc == nil { + panic("TaskRepo.CancelFunc: method is nil but TaskRepo.Cancel was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockCancel.Lock() + mock.calls.Cancel = append(mock.calls.Cancel, callInfo) + mock.lockCancel.Unlock() + return mock.CancelFunc(id) +} + +// CancelCalls gets all the calls that were made to Cancel. +// Check the length with: +// +// len(mockedTaskRepo.CancelCalls()) +func (mock *TaskRepo) CancelCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockCancel.RLock() + calls = mock.calls.Cancel + mock.lockCancel.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *TaskRepo) Delete(id uint) error { + if mock.DeleteFunc == nil { + panic("TaskRepo.DeleteFunc: method is nil but TaskRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedTaskRepo.DeleteCalls()) +func (mock *TaskRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *TaskRepo) Get(id uint) (*biz.Task, error) { + if mock.GetFunc == nil { + panic("TaskRepo.GetFunc: method is nil but TaskRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedTaskRepo.GetCalls()) +func (mock *TaskRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// HasRunningTask calls HasRunningTaskFunc. +func (mock *TaskRepo) HasRunningTask() bool { + if mock.HasRunningTaskFunc == nil { + panic("TaskRepo.HasRunningTaskFunc: method is nil but TaskRepo.HasRunningTask was just called") + } + callInfo := struct { + }{} + mock.lockHasRunningTask.Lock() + mock.calls.HasRunningTask = append(mock.calls.HasRunningTask, callInfo) + mock.lockHasRunningTask.Unlock() + return mock.HasRunningTaskFunc() +} + +// HasRunningTaskCalls gets all the calls that were made to HasRunningTask. +// Check the length with: +// +// len(mockedTaskRepo.HasRunningTaskCalls()) +func (mock *TaskRepo) HasRunningTaskCalls() []struct { +} { + var calls []struct { + } + mock.lockHasRunningTask.RLock() + calls = mock.calls.HasRunningTask + mock.lockHasRunningTask.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *TaskRepo) List(page uint, limit uint) ([]*biz.Task, int64, error) { + if mock.ListFunc == nil { + panic("TaskRepo.ListFunc: method is nil but TaskRepo.List was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedTaskRepo.ListCalls()) +func (mock *TaskRepo) ListCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// Push calls PushFunc. +func (mock *TaskRepo) Push(task *biz.Task) error { + if mock.PushFunc == nil { + panic("TaskRepo.PushFunc: method is nil but TaskRepo.Push was just called") + } + callInfo := struct { + Task *biz.Task + }{ + Task: task, + } + mock.lockPush.Lock() + mock.calls.Push = append(mock.calls.Push, callInfo) + mock.lockPush.Unlock() + return mock.PushFunc(task) +} + +// PushCalls gets all the calls that were made to Push. +// Check the length with: +// +// len(mockedTaskRepo.PushCalls()) +func (mock *TaskRepo) PushCalls() []struct { + Task *biz.Task +} { + var calls []struct { + Task *biz.Task + } + mock.lockPush.RLock() + calls = mock.calls.Push + mock.lockPush.RUnlock() + return calls +} + +// UpdateLog calls UpdateLogFunc. +func (mock *TaskRepo) UpdateLog(id uint, log string) error { + if mock.UpdateLogFunc == nil { + panic("TaskRepo.UpdateLogFunc: method is nil but TaskRepo.UpdateLog was just called") + } + callInfo := struct { + ID uint + Log string + }{ + ID: id, + Log: log, + } + mock.lockUpdateLog.Lock() + mock.calls.UpdateLog = append(mock.calls.UpdateLog, callInfo) + mock.lockUpdateLog.Unlock() + return mock.UpdateLogFunc(id, log) +} + +// UpdateLogCalls gets all the calls that were made to UpdateLog. +// Check the length with: +// +// len(mockedTaskRepo.UpdateLogCalls()) +func (mock *TaskRepo) UpdateLogCalls() []struct { + ID uint + Log string +} { + var calls []struct { + ID uint + Log string + } + mock.lockUpdateLog.RLock() + calls = mock.calls.UpdateLog + mock.lockUpdateLog.RUnlock() + return calls +} + +// UpdateStatus calls UpdateStatusFunc. +func (mock *TaskRepo) UpdateStatus(id uint, status biz.TaskStatus) error { + if mock.UpdateStatusFunc == nil { + panic("TaskRepo.UpdateStatusFunc: method is nil but TaskRepo.UpdateStatus was just called") + } + callInfo := struct { + ID uint + Status biz.TaskStatus + }{ + ID: id, + Status: status, + } + mock.lockUpdateStatus.Lock() + mock.calls.UpdateStatus = append(mock.calls.UpdateStatus, callInfo) + mock.lockUpdateStatus.Unlock() + return mock.UpdateStatusFunc(id, status) +} + +// UpdateStatusCalls gets all the calls that were made to UpdateStatus. +// Check the length with: +// +// len(mockedTaskRepo.UpdateStatusCalls()) +func (mock *TaskRepo) UpdateStatusCalls() []struct { + ID uint + Status biz.TaskStatus +} { + var calls []struct { + ID uint + Status biz.TaskStatus + } + mock.lockUpdateStatus.RLock() + calls = mock.calls.UpdateStatus + mock.lockUpdateStatus.RUnlock() + return calls +} diff --git a/internal/mocks/biz/TemplateRepo.go b/internal/mocks/biz/TemplateRepo.go new file mode 100644 index 000000000..c824e1b02 --- /dev/null +++ b/internal/mocks/biz/TemplateRepo.go @@ -0,0 +1,172 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/pkg/api" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that TemplateRepo does implement biz.TemplateRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.TemplateRepo = &TemplateRepo{} + +// TemplateRepo is a mock implementation of biz.TemplateRepo. +// +// func TestSomethingThatUsesTemplateRepo(t *testing.T) { +// +// // make and configure a mocked biz.TemplateRepo +// mockedTemplateRepo := &TemplateRepo{ +// CallbackFunc: func(slug string) error { +// panic("mock out the Callback method") +// }, +// LoadLocalTemplatesFunc: func() api.Templates { +// panic("mock out the LoadLocalTemplates method") +// }, +// WriteComposeFunc: func(name string, compose string, envs []types.KV) (string, error) { +// panic("mock out the WriteCompose method") +// }, +// } +// +// // use mockedTemplateRepo in code that requires biz.TemplateRepo +// // and then make assertions. +// +// } +type TemplateRepo struct { + // CallbackFunc mocks the Callback method. + CallbackFunc func(slug string) error + + // LoadLocalTemplatesFunc mocks the LoadLocalTemplates method. + LoadLocalTemplatesFunc func() api.Templates + + // WriteComposeFunc mocks the WriteCompose method. + WriteComposeFunc func(name string, compose string, envs []types.KV) (string, error) + + // calls tracks calls to the methods. + calls struct { + // Callback holds details about calls to the Callback method. + Callback []struct { + // Slug is the slug argument value. + Slug string + } + // LoadLocalTemplates holds details about calls to the LoadLocalTemplates method. + LoadLocalTemplates []struct { + } + // WriteCompose holds details about calls to the WriteCompose method. + WriteCompose []struct { + // Name is the name argument value. + Name string + // Compose is the compose argument value. + Compose string + // Envs is the envs argument value. + Envs []types.KV + } + } + lockCallback sync.RWMutex + lockLoadLocalTemplates sync.RWMutex + lockWriteCompose sync.RWMutex +} + +// Callback calls CallbackFunc. +func (mock *TemplateRepo) Callback(slug string) error { + if mock.CallbackFunc == nil { + panic("TemplateRepo.CallbackFunc: method is nil but TemplateRepo.Callback was just called") + } + callInfo := struct { + Slug string + }{ + Slug: slug, + } + mock.lockCallback.Lock() + mock.calls.Callback = append(mock.calls.Callback, callInfo) + mock.lockCallback.Unlock() + return mock.CallbackFunc(slug) +} + +// CallbackCalls gets all the calls that were made to Callback. +// Check the length with: +// +// len(mockedTemplateRepo.CallbackCalls()) +func (mock *TemplateRepo) CallbackCalls() []struct { + Slug string +} { + var calls []struct { + Slug string + } + mock.lockCallback.RLock() + calls = mock.calls.Callback + mock.lockCallback.RUnlock() + return calls +} + +// LoadLocalTemplates calls LoadLocalTemplatesFunc. +func (mock *TemplateRepo) LoadLocalTemplates() api.Templates { + if mock.LoadLocalTemplatesFunc == nil { + panic("TemplateRepo.LoadLocalTemplatesFunc: method is nil but TemplateRepo.LoadLocalTemplates was just called") + } + callInfo := struct { + }{} + mock.lockLoadLocalTemplates.Lock() + mock.calls.LoadLocalTemplates = append(mock.calls.LoadLocalTemplates, callInfo) + mock.lockLoadLocalTemplates.Unlock() + return mock.LoadLocalTemplatesFunc() +} + +// LoadLocalTemplatesCalls gets all the calls that were made to LoadLocalTemplates. +// Check the length with: +// +// len(mockedTemplateRepo.LoadLocalTemplatesCalls()) +func (mock *TemplateRepo) LoadLocalTemplatesCalls() []struct { +} { + var calls []struct { + } + mock.lockLoadLocalTemplates.RLock() + calls = mock.calls.LoadLocalTemplates + mock.lockLoadLocalTemplates.RUnlock() + return calls +} + +// WriteCompose calls WriteComposeFunc. +func (mock *TemplateRepo) WriteCompose(name string, compose string, envs []types.KV) (string, error) { + if mock.WriteComposeFunc == nil { + panic("TemplateRepo.WriteComposeFunc: method is nil but TemplateRepo.WriteCompose was just called") + } + callInfo := struct { + Name string + Compose string + Envs []types.KV + }{ + Name: name, + Compose: compose, + Envs: envs, + } + mock.lockWriteCompose.Lock() + mock.calls.WriteCompose = append(mock.calls.WriteCompose, callInfo) + mock.lockWriteCompose.Unlock() + return mock.WriteComposeFunc(name, compose, envs) +} + +// WriteComposeCalls gets all the calls that were made to WriteCompose. +// Check the length with: +// +// len(mockedTemplateRepo.WriteComposeCalls()) +func (mock *TemplateRepo) WriteComposeCalls() []struct { + Name string + Compose string + Envs []types.KV +} { + var calls []struct { + Name string + Compose string + Envs []types.KV + } + mock.lockWriteCompose.RLock() + calls = mock.calls.WriteCompose + mock.lockWriteCompose.RUnlock() + return calls +} diff --git a/internal/mocks/biz/UserPasskeyRepo.go b/internal/mocks/biz/UserPasskeyRepo.go new file mode 100644 index 000000000..4bac5e1e6 --- /dev/null +++ b/internal/mocks/biz/UserPasskeyRepo.go @@ -0,0 +1,434 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that UserPasskeyRepo does implement biz.UserPasskeyRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.UserPasskeyRepo = &UserPasskeyRepo{} + +// UserPasskeyRepo is a mock implementation of biz.UserPasskeyRepo. +// +// func TestSomethingThatUsesUserPasskeyRepo(t *testing.T) { +// +// // make and configure a mocked biz.UserPasskeyRepo +// mockedUserPasskeyRepo := &UserPasskeyRepo{ +// CreateFunc: func(passkey *biz.UserPasskey) error { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(userID uint, id uint) error { +// panic("mock out the Delete method") +// }, +// DeleteAllByUserIDFunc: func(userID uint) error { +// panic("mock out the DeleteAllByUserID method") +// }, +// GetByCredentialIDFunc: func(credentialID []byte) (*biz.UserPasskey, *biz.User, error) { +// panic("mock out the GetByCredentialID method") +// }, +// HasAnyFunc: func() (bool, error) { +// panic("mock out the HasAny method") +// }, +// HasPasskeyFunc: func(userID uint) (bool, error) { +// panic("mock out the HasPasskey method") +// }, +// ListFunc: func(userID uint) ([]*biz.UserPasskey, error) { +// panic("mock out the List method") +// }, +// UpdateLastUsedFunc: func(credentialID []byte) error { +// panic("mock out the UpdateLastUsed method") +// }, +// UpdateSignCountFunc: func(credentialID []byte, signCount uint32) error { +// panic("mock out the UpdateSignCount method") +// }, +// } +// +// // use mockedUserPasskeyRepo in code that requires biz.UserPasskeyRepo +// // and then make assertions. +// +// } +type UserPasskeyRepo struct { + // CreateFunc mocks the Create method. + CreateFunc func(passkey *biz.UserPasskey) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(userID uint, id uint) error + + // DeleteAllByUserIDFunc mocks the DeleteAllByUserID method. + DeleteAllByUserIDFunc func(userID uint) error + + // GetByCredentialIDFunc mocks the GetByCredentialID method. + GetByCredentialIDFunc func(credentialID []byte) (*biz.UserPasskey, *biz.User, error) + + // HasAnyFunc mocks the HasAny method. + HasAnyFunc func() (bool, error) + + // HasPasskeyFunc mocks the HasPasskey method. + HasPasskeyFunc func(userID uint) (bool, error) + + // ListFunc mocks the List method. + ListFunc func(userID uint) ([]*biz.UserPasskey, error) + + // UpdateLastUsedFunc mocks the UpdateLastUsed method. + UpdateLastUsedFunc func(credentialID []byte) error + + // UpdateSignCountFunc mocks the UpdateSignCount method. + UpdateSignCountFunc func(credentialID []byte, signCount uint32) error + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // Passkey is the passkey argument value. + Passkey *biz.UserPasskey + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // UserID is the userID argument value. + UserID uint + // ID is the id argument value. + ID uint + } + // DeleteAllByUserID holds details about calls to the DeleteAllByUserID method. + DeleteAllByUserID []struct { + // UserID is the userID argument value. + UserID uint + } + // GetByCredentialID holds details about calls to the GetByCredentialID method. + GetByCredentialID []struct { + // CredentialID is the credentialID argument value. + CredentialID []byte + } + // HasAny holds details about calls to the HasAny method. + HasAny []struct { + } + // HasPasskey holds details about calls to the HasPasskey method. + HasPasskey []struct { + // UserID is the userID argument value. + UserID uint + } + // List holds details about calls to the List method. + List []struct { + // UserID is the userID argument value. + UserID uint + } + // UpdateLastUsed holds details about calls to the UpdateLastUsed method. + UpdateLastUsed []struct { + // CredentialID is the credentialID argument value. + CredentialID []byte + } + // UpdateSignCount holds details about calls to the UpdateSignCount method. + UpdateSignCount []struct { + // CredentialID is the credentialID argument value. + CredentialID []byte + // SignCount is the signCount argument value. + SignCount uint32 + } + } + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockDeleteAllByUserID sync.RWMutex + lockGetByCredentialID sync.RWMutex + lockHasAny sync.RWMutex + lockHasPasskey sync.RWMutex + lockList sync.RWMutex + lockUpdateLastUsed sync.RWMutex + lockUpdateSignCount sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *UserPasskeyRepo) Create(passkey *biz.UserPasskey) error { + if mock.CreateFunc == nil { + panic("UserPasskeyRepo.CreateFunc: method is nil but UserPasskeyRepo.Create was just called") + } + callInfo := struct { + Passkey *biz.UserPasskey + }{ + Passkey: passkey, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(passkey) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedUserPasskeyRepo.CreateCalls()) +func (mock *UserPasskeyRepo) CreateCalls() []struct { + Passkey *biz.UserPasskey +} { + var calls []struct { + Passkey *biz.UserPasskey + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *UserPasskeyRepo) Delete(userID uint, id uint) error { + if mock.DeleteFunc == nil { + panic("UserPasskeyRepo.DeleteFunc: method is nil but UserPasskeyRepo.Delete was just called") + } + callInfo := struct { + UserID uint + ID uint + }{ + UserID: userID, + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(userID, id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedUserPasskeyRepo.DeleteCalls()) +func (mock *UserPasskeyRepo) DeleteCalls() []struct { + UserID uint + ID uint +} { + var calls []struct { + UserID uint + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// DeleteAllByUserID calls DeleteAllByUserIDFunc. +func (mock *UserPasskeyRepo) DeleteAllByUserID(userID uint) error { + if mock.DeleteAllByUserIDFunc == nil { + panic("UserPasskeyRepo.DeleteAllByUserIDFunc: method is nil but UserPasskeyRepo.DeleteAllByUserID was just called") + } + callInfo := struct { + UserID uint + }{ + UserID: userID, + } + mock.lockDeleteAllByUserID.Lock() + mock.calls.DeleteAllByUserID = append(mock.calls.DeleteAllByUserID, callInfo) + mock.lockDeleteAllByUserID.Unlock() + return mock.DeleteAllByUserIDFunc(userID) +} + +// DeleteAllByUserIDCalls gets all the calls that were made to DeleteAllByUserID. +// Check the length with: +// +// len(mockedUserPasskeyRepo.DeleteAllByUserIDCalls()) +func (mock *UserPasskeyRepo) DeleteAllByUserIDCalls() []struct { + UserID uint +} { + var calls []struct { + UserID uint + } + mock.lockDeleteAllByUserID.RLock() + calls = mock.calls.DeleteAllByUserID + mock.lockDeleteAllByUserID.RUnlock() + return calls +} + +// GetByCredentialID calls GetByCredentialIDFunc. +func (mock *UserPasskeyRepo) GetByCredentialID(credentialID []byte) (*biz.UserPasskey, *biz.User, error) { + if mock.GetByCredentialIDFunc == nil { + panic("UserPasskeyRepo.GetByCredentialIDFunc: method is nil but UserPasskeyRepo.GetByCredentialID was just called") + } + callInfo := struct { + CredentialID []byte + }{ + CredentialID: credentialID, + } + mock.lockGetByCredentialID.Lock() + mock.calls.GetByCredentialID = append(mock.calls.GetByCredentialID, callInfo) + mock.lockGetByCredentialID.Unlock() + return mock.GetByCredentialIDFunc(credentialID) +} + +// GetByCredentialIDCalls gets all the calls that were made to GetByCredentialID. +// Check the length with: +// +// len(mockedUserPasskeyRepo.GetByCredentialIDCalls()) +func (mock *UserPasskeyRepo) GetByCredentialIDCalls() []struct { + CredentialID []byte +} { + var calls []struct { + CredentialID []byte + } + mock.lockGetByCredentialID.RLock() + calls = mock.calls.GetByCredentialID + mock.lockGetByCredentialID.RUnlock() + return calls +} + +// HasAny calls HasAnyFunc. +func (mock *UserPasskeyRepo) HasAny() (bool, error) { + if mock.HasAnyFunc == nil { + panic("UserPasskeyRepo.HasAnyFunc: method is nil but UserPasskeyRepo.HasAny was just called") + } + callInfo := struct { + }{} + mock.lockHasAny.Lock() + mock.calls.HasAny = append(mock.calls.HasAny, callInfo) + mock.lockHasAny.Unlock() + return mock.HasAnyFunc() +} + +// HasAnyCalls gets all the calls that were made to HasAny. +// Check the length with: +// +// len(mockedUserPasskeyRepo.HasAnyCalls()) +func (mock *UserPasskeyRepo) HasAnyCalls() []struct { +} { + var calls []struct { + } + mock.lockHasAny.RLock() + calls = mock.calls.HasAny + mock.lockHasAny.RUnlock() + return calls +} + +// HasPasskey calls HasPasskeyFunc. +func (mock *UserPasskeyRepo) HasPasskey(userID uint) (bool, error) { + if mock.HasPasskeyFunc == nil { + panic("UserPasskeyRepo.HasPasskeyFunc: method is nil but UserPasskeyRepo.HasPasskey was just called") + } + callInfo := struct { + UserID uint + }{ + UserID: userID, + } + mock.lockHasPasskey.Lock() + mock.calls.HasPasskey = append(mock.calls.HasPasskey, callInfo) + mock.lockHasPasskey.Unlock() + return mock.HasPasskeyFunc(userID) +} + +// HasPasskeyCalls gets all the calls that were made to HasPasskey. +// Check the length with: +// +// len(mockedUserPasskeyRepo.HasPasskeyCalls()) +func (mock *UserPasskeyRepo) HasPasskeyCalls() []struct { + UserID uint +} { + var calls []struct { + UserID uint + } + mock.lockHasPasskey.RLock() + calls = mock.calls.HasPasskey + mock.lockHasPasskey.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *UserPasskeyRepo) List(userID uint) ([]*biz.UserPasskey, error) { + if mock.ListFunc == nil { + panic("UserPasskeyRepo.ListFunc: method is nil but UserPasskeyRepo.List was just called") + } + callInfo := struct { + UserID uint + }{ + UserID: userID, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(userID) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedUserPasskeyRepo.ListCalls()) +func (mock *UserPasskeyRepo) ListCalls() []struct { + UserID uint +} { + var calls []struct { + UserID uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// UpdateLastUsed calls UpdateLastUsedFunc. +func (mock *UserPasskeyRepo) UpdateLastUsed(credentialID []byte) error { + if mock.UpdateLastUsedFunc == nil { + panic("UserPasskeyRepo.UpdateLastUsedFunc: method is nil but UserPasskeyRepo.UpdateLastUsed was just called") + } + callInfo := struct { + CredentialID []byte + }{ + CredentialID: credentialID, + } + mock.lockUpdateLastUsed.Lock() + mock.calls.UpdateLastUsed = append(mock.calls.UpdateLastUsed, callInfo) + mock.lockUpdateLastUsed.Unlock() + return mock.UpdateLastUsedFunc(credentialID) +} + +// UpdateLastUsedCalls gets all the calls that were made to UpdateLastUsed. +// Check the length with: +// +// len(mockedUserPasskeyRepo.UpdateLastUsedCalls()) +func (mock *UserPasskeyRepo) UpdateLastUsedCalls() []struct { + CredentialID []byte +} { + var calls []struct { + CredentialID []byte + } + mock.lockUpdateLastUsed.RLock() + calls = mock.calls.UpdateLastUsed + mock.lockUpdateLastUsed.RUnlock() + return calls +} + +// UpdateSignCount calls UpdateSignCountFunc. +func (mock *UserPasskeyRepo) UpdateSignCount(credentialID []byte, signCount uint32) error { + if mock.UpdateSignCountFunc == nil { + panic("UserPasskeyRepo.UpdateSignCountFunc: method is nil but UserPasskeyRepo.UpdateSignCount was just called") + } + callInfo := struct { + CredentialID []byte + SignCount uint32 + }{ + CredentialID: credentialID, + SignCount: signCount, + } + mock.lockUpdateSignCount.Lock() + mock.calls.UpdateSignCount = append(mock.calls.UpdateSignCount, callInfo) + mock.lockUpdateSignCount.Unlock() + return mock.UpdateSignCountFunc(credentialID, signCount) +} + +// UpdateSignCountCalls gets all the calls that were made to UpdateSignCount. +// Check the length with: +// +// len(mockedUserPasskeyRepo.UpdateSignCountCalls()) +func (mock *UserPasskeyRepo) UpdateSignCountCalls() []struct { + CredentialID []byte + SignCount uint32 +} { + var calls []struct { + CredentialID []byte + SignCount uint32 + } + mock.lockUpdateSignCount.RLock() + calls = mock.calls.UpdateSignCount + mock.lockUpdateSignCount.RUnlock() + return calls +} diff --git a/internal/mocks/biz/UserRepo.go b/internal/mocks/biz/UserRepo.go new file mode 100644 index 000000000..2bab307ee --- /dev/null +++ b/internal/mocks/biz/UserRepo.go @@ -0,0 +1,609 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "image" + "sync" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that UserRepo does implement biz.UserRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.UserRepo = &UserRepo{} + +// UserRepo is a mock implementation of biz.UserRepo. +// +// func TestSomethingThatUsesUserRepo(t *testing.T) { +// +// // make and configure a mocked biz.UserRepo +// mockedUserRepo := &UserRepo{ +// CheckPasswordFunc: func(username string, password string) (*biz.User, error) { +// panic("mock out the CheckPassword method") +// }, +// CountFunc: func() (int64, error) { +// panic("mock out the Count method") +// }, +// CreateFunc: func(username string, password string, email string) (*biz.User, error) { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(id uint) (string, error) { +// panic("mock out the Delete method") +// }, +// GenerateTwoFAFunc: func(id uint) (image.Image, string, string, error) { +// panic("mock out the GenerateTwoFA method") +// }, +// GetFunc: func(id uint) (*biz.User, error) { +// panic("mock out the Get method") +// }, +// IsTwoFAFunc: func(username string) (bool, error) { +// panic("mock out the IsTwoFA method") +// }, +// ListFunc: func(page uint, limit uint) ([]*biz.User, int64, error) { +// panic("mock out the List method") +// }, +// UpdateEmailFunc: func(id uint, email string) error { +// panic("mock out the UpdateEmail method") +// }, +// UpdatePasswordFunc: func(id uint, password string) error { +// panic("mock out the UpdatePassword method") +// }, +// UpdateTwoFAFunc: func(id uint, code string, secret string) error { +// panic("mock out the UpdateTwoFA method") +// }, +// UpdateUsernameFunc: func(id uint, username string) error { +// panic("mock out the UpdateUsername method") +// }, +// } +// +// // use mockedUserRepo in code that requires biz.UserRepo +// // and then make assertions. +// +// } +type UserRepo struct { + // CheckPasswordFunc mocks the CheckPassword method. + CheckPasswordFunc func(username string, password string) (*biz.User, error) + + // CountFunc mocks the Count method. + CountFunc func() (int64, error) + + // CreateFunc mocks the Create method. + CreateFunc func(username string, password string, email string) (*biz.User, error) + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) (string, error) + + // GenerateTwoFAFunc mocks the GenerateTwoFA method. + GenerateTwoFAFunc func(id uint) (image.Image, string, string, error) + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*biz.User, error) + + // IsTwoFAFunc mocks the IsTwoFA method. + IsTwoFAFunc func(username string) (bool, error) + + // ListFunc mocks the List method. + ListFunc func(page uint, limit uint) ([]*biz.User, int64, error) + + // UpdateEmailFunc mocks the UpdateEmail method. + UpdateEmailFunc func(id uint, email string) error + + // UpdatePasswordFunc mocks the UpdatePassword method. + UpdatePasswordFunc func(id uint, password string) error + + // UpdateTwoFAFunc mocks the UpdateTwoFA method. + UpdateTwoFAFunc func(id uint, code string, secret string) error + + // UpdateUsernameFunc mocks the UpdateUsername method. + UpdateUsernameFunc func(id uint, username string) error + + // calls tracks calls to the methods. + calls struct { + // CheckPassword holds details about calls to the CheckPassword method. + CheckPassword []struct { + // Username is the username argument value. + Username string + // Password is the password argument value. + Password string + } + // Count holds details about calls to the Count method. + Count []struct { + } + // Create holds details about calls to the Create method. + Create []struct { + // Username is the username argument value. + Username string + // Password is the password argument value. + Password string + // Email is the email argument value. + Email string + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // GenerateTwoFA holds details about calls to the GenerateTwoFA method. + GenerateTwoFA []struct { + // ID is the id argument value. + ID uint + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // IsTwoFA holds details about calls to the IsTwoFA method. + IsTwoFA []struct { + // Username is the username argument value. + Username string + } + // List holds details about calls to the List method. + List []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // UpdateEmail holds details about calls to the UpdateEmail method. + UpdateEmail []struct { + // ID is the id argument value. + ID uint + // Email is the email argument value. + Email string + } + // UpdatePassword holds details about calls to the UpdatePassword method. + UpdatePassword []struct { + // ID is the id argument value. + ID uint + // Password is the password argument value. + Password string + } + // UpdateTwoFA holds details about calls to the UpdateTwoFA method. + UpdateTwoFA []struct { + // ID is the id argument value. + ID uint + // Code is the code argument value. + Code string + // Secret is the secret argument value. + Secret string + } + // UpdateUsername holds details about calls to the UpdateUsername method. + UpdateUsername []struct { + // ID is the id argument value. + ID uint + // Username is the username argument value. + Username string + } + } + lockCheckPassword sync.RWMutex + lockCount sync.RWMutex + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockGenerateTwoFA sync.RWMutex + lockGet sync.RWMutex + lockIsTwoFA sync.RWMutex + lockList sync.RWMutex + lockUpdateEmail sync.RWMutex + lockUpdatePassword sync.RWMutex + lockUpdateTwoFA sync.RWMutex + lockUpdateUsername sync.RWMutex +} + +// CheckPassword calls CheckPasswordFunc. +func (mock *UserRepo) CheckPassword(username string, password string) (*biz.User, error) { + if mock.CheckPasswordFunc == nil { + panic("UserRepo.CheckPasswordFunc: method is nil but UserRepo.CheckPassword was just called") + } + callInfo := struct { + Username string + Password string + }{ + Username: username, + Password: password, + } + mock.lockCheckPassword.Lock() + mock.calls.CheckPassword = append(mock.calls.CheckPassword, callInfo) + mock.lockCheckPassword.Unlock() + return mock.CheckPasswordFunc(username, password) +} + +// CheckPasswordCalls gets all the calls that were made to CheckPassword. +// Check the length with: +// +// len(mockedUserRepo.CheckPasswordCalls()) +func (mock *UserRepo) CheckPasswordCalls() []struct { + Username string + Password string +} { + var calls []struct { + Username string + Password string + } + mock.lockCheckPassword.RLock() + calls = mock.calls.CheckPassword + mock.lockCheckPassword.RUnlock() + return calls +} + +// Count calls CountFunc. +func (mock *UserRepo) Count() (int64, error) { + if mock.CountFunc == nil { + panic("UserRepo.CountFunc: method is nil but UserRepo.Count was just called") + } + callInfo := struct { + }{} + mock.lockCount.Lock() + mock.calls.Count = append(mock.calls.Count, callInfo) + mock.lockCount.Unlock() + return mock.CountFunc() +} + +// CountCalls gets all the calls that were made to Count. +// Check the length with: +// +// len(mockedUserRepo.CountCalls()) +func (mock *UserRepo) CountCalls() []struct { +} { + var calls []struct { + } + mock.lockCount.RLock() + calls = mock.calls.Count + mock.lockCount.RUnlock() + return calls +} + +// Create calls CreateFunc. +func (mock *UserRepo) Create(username string, password string, email string) (*biz.User, error) { + if mock.CreateFunc == nil { + panic("UserRepo.CreateFunc: method is nil but UserRepo.Create was just called") + } + callInfo := struct { + Username string + Password string + Email string + }{ + Username: username, + Password: password, + Email: email, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(username, password, email) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedUserRepo.CreateCalls()) +func (mock *UserRepo) CreateCalls() []struct { + Username string + Password string + Email string +} { + var calls []struct { + Username string + Password string + Email string + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *UserRepo) Delete(id uint) (string, error) { + if mock.DeleteFunc == nil { + panic("UserRepo.DeleteFunc: method is nil but UserRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedUserRepo.DeleteCalls()) +func (mock *UserRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// GenerateTwoFA calls GenerateTwoFAFunc. +func (mock *UserRepo) GenerateTwoFA(id uint) (image.Image, string, string, error) { + if mock.GenerateTwoFAFunc == nil { + panic("UserRepo.GenerateTwoFAFunc: method is nil but UserRepo.GenerateTwoFA was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGenerateTwoFA.Lock() + mock.calls.GenerateTwoFA = append(mock.calls.GenerateTwoFA, callInfo) + mock.lockGenerateTwoFA.Unlock() + return mock.GenerateTwoFAFunc(id) +} + +// GenerateTwoFACalls gets all the calls that were made to GenerateTwoFA. +// Check the length with: +// +// len(mockedUserRepo.GenerateTwoFACalls()) +func (mock *UserRepo) GenerateTwoFACalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGenerateTwoFA.RLock() + calls = mock.calls.GenerateTwoFA + mock.lockGenerateTwoFA.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *UserRepo) Get(id uint) (*biz.User, error) { + if mock.GetFunc == nil { + panic("UserRepo.GetFunc: method is nil but UserRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedUserRepo.GetCalls()) +func (mock *UserRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// IsTwoFA calls IsTwoFAFunc. +func (mock *UserRepo) IsTwoFA(username string) (bool, error) { + if mock.IsTwoFAFunc == nil { + panic("UserRepo.IsTwoFAFunc: method is nil but UserRepo.IsTwoFA was just called") + } + callInfo := struct { + Username string + }{ + Username: username, + } + mock.lockIsTwoFA.Lock() + mock.calls.IsTwoFA = append(mock.calls.IsTwoFA, callInfo) + mock.lockIsTwoFA.Unlock() + return mock.IsTwoFAFunc(username) +} + +// IsTwoFACalls gets all the calls that were made to IsTwoFA. +// Check the length with: +// +// len(mockedUserRepo.IsTwoFACalls()) +func (mock *UserRepo) IsTwoFACalls() []struct { + Username string +} { + var calls []struct { + Username string + } + mock.lockIsTwoFA.RLock() + calls = mock.calls.IsTwoFA + mock.lockIsTwoFA.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *UserRepo) List(page uint, limit uint) ([]*biz.User, int64, error) { + if mock.ListFunc == nil { + panic("UserRepo.ListFunc: method is nil but UserRepo.List was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedUserRepo.ListCalls()) +func (mock *UserRepo) ListCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// UpdateEmail calls UpdateEmailFunc. +func (mock *UserRepo) UpdateEmail(id uint, email string) error { + if mock.UpdateEmailFunc == nil { + panic("UserRepo.UpdateEmailFunc: method is nil but UserRepo.UpdateEmail was just called") + } + callInfo := struct { + ID uint + Email string + }{ + ID: id, + Email: email, + } + mock.lockUpdateEmail.Lock() + mock.calls.UpdateEmail = append(mock.calls.UpdateEmail, callInfo) + mock.lockUpdateEmail.Unlock() + return mock.UpdateEmailFunc(id, email) +} + +// UpdateEmailCalls gets all the calls that were made to UpdateEmail. +// Check the length with: +// +// len(mockedUserRepo.UpdateEmailCalls()) +func (mock *UserRepo) UpdateEmailCalls() []struct { + ID uint + Email string +} { + var calls []struct { + ID uint + Email string + } + mock.lockUpdateEmail.RLock() + calls = mock.calls.UpdateEmail + mock.lockUpdateEmail.RUnlock() + return calls +} + +// UpdatePassword calls UpdatePasswordFunc. +func (mock *UserRepo) UpdatePassword(id uint, password string) error { + if mock.UpdatePasswordFunc == nil { + panic("UserRepo.UpdatePasswordFunc: method is nil but UserRepo.UpdatePassword was just called") + } + callInfo := struct { + ID uint + Password string + }{ + ID: id, + Password: password, + } + mock.lockUpdatePassword.Lock() + mock.calls.UpdatePassword = append(mock.calls.UpdatePassword, callInfo) + mock.lockUpdatePassword.Unlock() + return mock.UpdatePasswordFunc(id, password) +} + +// UpdatePasswordCalls gets all the calls that were made to UpdatePassword. +// Check the length with: +// +// len(mockedUserRepo.UpdatePasswordCalls()) +func (mock *UserRepo) UpdatePasswordCalls() []struct { + ID uint + Password string +} { + var calls []struct { + ID uint + Password string + } + mock.lockUpdatePassword.RLock() + calls = mock.calls.UpdatePassword + mock.lockUpdatePassword.RUnlock() + return calls +} + +// UpdateTwoFA calls UpdateTwoFAFunc. +func (mock *UserRepo) UpdateTwoFA(id uint, code string, secret string) error { + if mock.UpdateTwoFAFunc == nil { + panic("UserRepo.UpdateTwoFAFunc: method is nil but UserRepo.UpdateTwoFA was just called") + } + callInfo := struct { + ID uint + Code string + Secret string + }{ + ID: id, + Code: code, + Secret: secret, + } + mock.lockUpdateTwoFA.Lock() + mock.calls.UpdateTwoFA = append(mock.calls.UpdateTwoFA, callInfo) + mock.lockUpdateTwoFA.Unlock() + return mock.UpdateTwoFAFunc(id, code, secret) +} + +// UpdateTwoFACalls gets all the calls that were made to UpdateTwoFA. +// Check the length with: +// +// len(mockedUserRepo.UpdateTwoFACalls()) +func (mock *UserRepo) UpdateTwoFACalls() []struct { + ID uint + Code string + Secret string +} { + var calls []struct { + ID uint + Code string + Secret string + } + mock.lockUpdateTwoFA.RLock() + calls = mock.calls.UpdateTwoFA + mock.lockUpdateTwoFA.RUnlock() + return calls +} + +// UpdateUsername calls UpdateUsernameFunc. +func (mock *UserRepo) UpdateUsername(id uint, username string) error { + if mock.UpdateUsernameFunc == nil { + panic("UserRepo.UpdateUsernameFunc: method is nil but UserRepo.UpdateUsername was just called") + } + callInfo := struct { + ID uint + Username string + }{ + ID: id, + Username: username, + } + mock.lockUpdateUsername.Lock() + mock.calls.UpdateUsername = append(mock.calls.UpdateUsername, callInfo) + mock.lockUpdateUsername.Unlock() + return mock.UpdateUsernameFunc(id, username) +} + +// UpdateUsernameCalls gets all the calls that were made to UpdateUsername. +// Check the length with: +// +// len(mockedUserRepo.UpdateUsernameCalls()) +func (mock *UserRepo) UpdateUsernameCalls() []struct { + ID uint + Username string +} { + var calls []struct { + ID uint + Username string + } + mock.lockUpdateUsername.RLock() + calls = mock.calls.UpdateUsername + mock.lockUpdateUsername.RUnlock() + return calls +} diff --git a/internal/mocks/biz/UserTokenRepo.go b/internal/mocks/biz/UserTokenRepo.go new file mode 100644 index 000000000..c2432a20e --- /dev/null +++ b/internal/mocks/biz/UserTokenRepo.go @@ -0,0 +1,335 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "net/http" + "sync" + "time" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that UserTokenRepo does implement biz.UserTokenRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.UserTokenRepo = &UserTokenRepo{} + +// UserTokenRepo is a mock implementation of biz.UserTokenRepo. +// +// func TestSomethingThatUsesUserTokenRepo(t *testing.T) { +// +// // make and configure a mocked biz.UserTokenRepo +// mockedUserTokenRepo := &UserTokenRepo{ +// CreateFunc: func(userID uint, ips []string, expired time.Time) (*biz.UserToken, error) { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(id uint) error { +// panic("mock out the Delete method") +// }, +// GetFunc: func(id uint) (*biz.UserToken, error) { +// panic("mock out the Get method") +// }, +// ListFunc: func(userID uint, page uint, limit uint) ([]*biz.UserToken, int64, error) { +// panic("mock out the List method") +// }, +// UpdateFunc: func(id uint, ips []string, expired time.Time) (*biz.UserToken, error) { +// panic("mock out the Update method") +// }, +// ValidateReqFunc: func(req *http.Request) (uint, error) { +// panic("mock out the ValidateReq method") +// }, +// } +// +// // use mockedUserTokenRepo in code that requires biz.UserTokenRepo +// // and then make assertions. +// +// } +type UserTokenRepo struct { + // CreateFunc mocks the Create method. + CreateFunc func(userID uint, ips []string, expired time.Time) (*biz.UserToken, error) + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) error + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*biz.UserToken, error) + + // ListFunc mocks the List method. + ListFunc func(userID uint, page uint, limit uint) ([]*biz.UserToken, int64, error) + + // UpdateFunc mocks the Update method. + UpdateFunc func(id uint, ips []string, expired time.Time) (*biz.UserToken, error) + + // ValidateReqFunc mocks the ValidateReq method. + ValidateReqFunc func(req *http.Request) (uint, error) + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // UserID is the userID argument value. + UserID uint + // Ips is the ips argument value. + Ips []string + // Expired is the expired argument value. + Expired time.Time + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // List holds details about calls to the List method. + List []struct { + // UserID is the userID argument value. + UserID uint + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // Update holds details about calls to the Update method. + Update []struct { + // ID is the id argument value. + ID uint + // Ips is the ips argument value. + Ips []string + // Expired is the expired argument value. + Expired time.Time + } + // ValidateReq holds details about calls to the ValidateReq method. + ValidateReq []struct { + // Req is the req argument value. + Req *http.Request + } + } + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockGet sync.RWMutex + lockList sync.RWMutex + lockUpdate sync.RWMutex + lockValidateReq sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *UserTokenRepo) Create(userID uint, ips []string, expired time.Time) (*biz.UserToken, error) { + if mock.CreateFunc == nil { + panic("UserTokenRepo.CreateFunc: method is nil but UserTokenRepo.Create was just called") + } + callInfo := struct { + UserID uint + Ips []string + Expired time.Time + }{ + UserID: userID, + Ips: ips, + Expired: expired, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(userID, ips, expired) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedUserTokenRepo.CreateCalls()) +func (mock *UserTokenRepo) CreateCalls() []struct { + UserID uint + Ips []string + Expired time.Time +} { + var calls []struct { + UserID uint + Ips []string + Expired time.Time + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *UserTokenRepo) Delete(id uint) error { + if mock.DeleteFunc == nil { + panic("UserTokenRepo.DeleteFunc: method is nil but UserTokenRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedUserTokenRepo.DeleteCalls()) +func (mock *UserTokenRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *UserTokenRepo) Get(id uint) (*biz.UserToken, error) { + if mock.GetFunc == nil { + panic("UserTokenRepo.GetFunc: method is nil but UserTokenRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedUserTokenRepo.GetCalls()) +func (mock *UserTokenRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *UserTokenRepo) List(userID uint, page uint, limit uint) ([]*biz.UserToken, int64, error) { + if mock.ListFunc == nil { + panic("UserTokenRepo.ListFunc: method is nil but UserTokenRepo.List was just called") + } + callInfo := struct { + UserID uint + Page uint + Limit uint + }{ + UserID: userID, + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(userID, page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedUserTokenRepo.ListCalls()) +func (mock *UserTokenRepo) ListCalls() []struct { + UserID uint + Page uint + Limit uint +} { + var calls []struct { + UserID uint + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// Update calls UpdateFunc. +func (mock *UserTokenRepo) Update(id uint, ips []string, expired time.Time) (*biz.UserToken, error) { + if mock.UpdateFunc == nil { + panic("UserTokenRepo.UpdateFunc: method is nil but UserTokenRepo.Update was just called") + } + callInfo := struct { + ID uint + Ips []string + Expired time.Time + }{ + ID: id, + Ips: ips, + Expired: expired, + } + mock.lockUpdate.Lock() + mock.calls.Update = append(mock.calls.Update, callInfo) + mock.lockUpdate.Unlock() + return mock.UpdateFunc(id, ips, expired) +} + +// UpdateCalls gets all the calls that were made to Update. +// Check the length with: +// +// len(mockedUserTokenRepo.UpdateCalls()) +func (mock *UserTokenRepo) UpdateCalls() []struct { + ID uint + Ips []string + Expired time.Time +} { + var calls []struct { + ID uint + Ips []string + Expired time.Time + } + mock.lockUpdate.RLock() + calls = mock.calls.Update + mock.lockUpdate.RUnlock() + return calls +} + +// ValidateReq calls ValidateReqFunc. +func (mock *UserTokenRepo) ValidateReq(req *http.Request) (uint, error) { + if mock.ValidateReqFunc == nil { + panic("UserTokenRepo.ValidateReqFunc: method is nil but UserTokenRepo.ValidateReq was just called") + } + callInfo := struct { + Req *http.Request + }{ + Req: req, + } + mock.lockValidateReq.Lock() + mock.calls.ValidateReq = append(mock.calls.ValidateReq, callInfo) + mock.lockValidateReq.Unlock() + return mock.ValidateReqFunc(req) +} + +// ValidateReqCalls gets all the calls that were made to ValidateReq. +// Check the length with: +// +// len(mockedUserTokenRepo.ValidateReqCalls()) +func (mock *UserTokenRepo) ValidateReqCalls() []struct { + Req *http.Request +} { + var calls []struct { + Req *http.Request + } + mock.lockValidateReq.RLock() + calls = mock.calls.ValidateReq + mock.lockValidateReq.RUnlock() + return calls +} diff --git a/internal/mocks/biz/WebHookRepo.go b/internal/mocks/biz/WebHookRepo.go new file mode 100644 index 000000000..d812882d1 --- /dev/null +++ b/internal/mocks/biz/WebHookRepo.go @@ -0,0 +1,404 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" +) + +// Ensure that WebHookRepo does implement biz.WebHookRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.WebHookRepo = &WebHookRepo{} + +// WebHookRepo is a mock implementation of biz.WebHookRepo. +// +// func TestSomethingThatUsesWebHookRepo(t *testing.T) { +// +// // make and configure a mocked biz.WebHookRepo +// mockedWebHookRepo := &WebHookRepo{ +// CallFunc: func(key string) (string, error) { +// panic("mock out the Call method") +// }, +// CreateWithScriptFunc: func(webhook *biz.WebHook, script string) error { +// panic("mock out the CreateWithScript method") +// }, +// DeleteFunc: func(id uint) error { +// panic("mock out the Delete method") +// }, +// GetFunc: func(id uint) (*biz.WebHook, error) { +// panic("mock out the Get method") +// }, +// GetByKeyFunc: func(key string) (*biz.WebHook, error) { +// panic("mock out the GetByKey method") +// }, +// ListFunc: func(page uint, limit uint) ([]*biz.WebHook, int64, error) { +// panic("mock out the List method") +// }, +// RemoveScriptFunc: func(key string) error { +// panic("mock out the RemoveScript method") +// }, +// UpdateWithScriptFunc: func(webhook *biz.WebHook, req *request.WebHookUpdate) error { +// panic("mock out the UpdateWithScript method") +// }, +// } +// +// // use mockedWebHookRepo in code that requires biz.WebHookRepo +// // and then make assertions. +// +// } +type WebHookRepo struct { + // CallFunc mocks the Call method. + CallFunc func(key string) (string, error) + + // CreateWithScriptFunc mocks the CreateWithScript method. + CreateWithScriptFunc func(webhook *biz.WebHook, script string) error + + // DeleteFunc mocks the Delete method. + DeleteFunc func(id uint) error + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*biz.WebHook, error) + + // GetByKeyFunc mocks the GetByKey method. + GetByKeyFunc func(key string) (*biz.WebHook, error) + + // ListFunc mocks the List method. + ListFunc func(page uint, limit uint) ([]*biz.WebHook, int64, error) + + // RemoveScriptFunc mocks the RemoveScript method. + RemoveScriptFunc func(key string) error + + // UpdateWithScriptFunc mocks the UpdateWithScript method. + UpdateWithScriptFunc func(webhook *biz.WebHook, req *request.WebHookUpdate) error + + // calls tracks calls to the methods. + calls struct { + // Call holds details about calls to the Call method. + Call []struct { + // Key is the key argument value. + Key string + } + // CreateWithScript holds details about calls to the CreateWithScript method. + CreateWithScript []struct { + // Webhook is the webhook argument value. + Webhook *biz.WebHook + // Script is the script argument value. + Script string + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // ID is the id argument value. + ID uint + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // GetByKey holds details about calls to the GetByKey method. + GetByKey []struct { + // Key is the key argument value. + Key string + } + // List holds details about calls to the List method. + List []struct { + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // RemoveScript holds details about calls to the RemoveScript method. + RemoveScript []struct { + // Key is the key argument value. + Key string + } + // UpdateWithScript holds details about calls to the UpdateWithScript method. + UpdateWithScript []struct { + // Webhook is the webhook argument value. + Webhook *biz.WebHook + // Req is the req argument value. + Req *request.WebHookUpdate + } + } + lockCall sync.RWMutex + lockCreateWithScript sync.RWMutex + lockDelete sync.RWMutex + lockGet sync.RWMutex + lockGetByKey sync.RWMutex + lockList sync.RWMutex + lockRemoveScript sync.RWMutex + lockUpdateWithScript sync.RWMutex +} + +// Call calls CallFunc. +func (mock *WebHookRepo) Call(key string) (string, error) { + if mock.CallFunc == nil { + panic("WebHookRepo.CallFunc: method is nil but WebHookRepo.Call was just called") + } + callInfo := struct { + Key string + }{ + Key: key, + } + mock.lockCall.Lock() + mock.calls.Call = append(mock.calls.Call, callInfo) + mock.lockCall.Unlock() + return mock.CallFunc(key) +} + +// CallCalls gets all the calls that were made to Call. +// Check the length with: +// +// len(mockedWebHookRepo.CallCalls()) +func (mock *WebHookRepo) CallCalls() []struct { + Key string +} { + var calls []struct { + Key string + } + mock.lockCall.RLock() + calls = mock.calls.Call + mock.lockCall.RUnlock() + return calls +} + +// CreateWithScript calls CreateWithScriptFunc. +func (mock *WebHookRepo) CreateWithScript(webhook *biz.WebHook, script string) error { + if mock.CreateWithScriptFunc == nil { + panic("WebHookRepo.CreateWithScriptFunc: method is nil but WebHookRepo.CreateWithScript was just called") + } + callInfo := struct { + Webhook *biz.WebHook + Script string + }{ + Webhook: webhook, + Script: script, + } + mock.lockCreateWithScript.Lock() + mock.calls.CreateWithScript = append(mock.calls.CreateWithScript, callInfo) + mock.lockCreateWithScript.Unlock() + return mock.CreateWithScriptFunc(webhook, script) +} + +// CreateWithScriptCalls gets all the calls that were made to CreateWithScript. +// Check the length with: +// +// len(mockedWebHookRepo.CreateWithScriptCalls()) +func (mock *WebHookRepo) CreateWithScriptCalls() []struct { + Webhook *biz.WebHook + Script string +} { + var calls []struct { + Webhook *biz.WebHook + Script string + } + mock.lockCreateWithScript.RLock() + calls = mock.calls.CreateWithScript + mock.lockCreateWithScript.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *WebHookRepo) Delete(id uint) error { + if mock.DeleteFunc == nil { + panic("WebHookRepo.DeleteFunc: method is nil but WebHookRepo.Delete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(id) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedWebHookRepo.DeleteCalls()) +func (mock *WebHookRepo) DeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *WebHookRepo) Get(id uint) (*biz.WebHook, error) { + if mock.GetFunc == nil { + panic("WebHookRepo.GetFunc: method is nil but WebHookRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedWebHookRepo.GetCalls()) +func (mock *WebHookRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// GetByKey calls GetByKeyFunc. +func (mock *WebHookRepo) GetByKey(key string) (*biz.WebHook, error) { + if mock.GetByKeyFunc == nil { + panic("WebHookRepo.GetByKeyFunc: method is nil but WebHookRepo.GetByKey was just called") + } + callInfo := struct { + Key string + }{ + Key: key, + } + mock.lockGetByKey.Lock() + mock.calls.GetByKey = append(mock.calls.GetByKey, callInfo) + mock.lockGetByKey.Unlock() + return mock.GetByKeyFunc(key) +} + +// GetByKeyCalls gets all the calls that were made to GetByKey. +// Check the length with: +// +// len(mockedWebHookRepo.GetByKeyCalls()) +func (mock *WebHookRepo) GetByKeyCalls() []struct { + Key string +} { + var calls []struct { + Key string + } + mock.lockGetByKey.RLock() + calls = mock.calls.GetByKey + mock.lockGetByKey.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *WebHookRepo) List(page uint, limit uint) ([]*biz.WebHook, int64, error) { + if mock.ListFunc == nil { + panic("WebHookRepo.ListFunc: method is nil but WebHookRepo.List was just called") + } + callInfo := struct { + Page uint + Limit uint + }{ + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedWebHookRepo.ListCalls()) +func (mock *WebHookRepo) ListCalls() []struct { + Page uint + Limit uint +} { + var calls []struct { + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// RemoveScript calls RemoveScriptFunc. +func (mock *WebHookRepo) RemoveScript(key string) error { + if mock.RemoveScriptFunc == nil { + panic("WebHookRepo.RemoveScriptFunc: method is nil but WebHookRepo.RemoveScript was just called") + } + callInfo := struct { + Key string + }{ + Key: key, + } + mock.lockRemoveScript.Lock() + mock.calls.RemoveScript = append(mock.calls.RemoveScript, callInfo) + mock.lockRemoveScript.Unlock() + return mock.RemoveScriptFunc(key) +} + +// RemoveScriptCalls gets all the calls that were made to RemoveScript. +// Check the length with: +// +// len(mockedWebHookRepo.RemoveScriptCalls()) +func (mock *WebHookRepo) RemoveScriptCalls() []struct { + Key string +} { + var calls []struct { + Key string + } + mock.lockRemoveScript.RLock() + calls = mock.calls.RemoveScript + mock.lockRemoveScript.RUnlock() + return calls +} + +// UpdateWithScript calls UpdateWithScriptFunc. +func (mock *WebHookRepo) UpdateWithScript(webhook *biz.WebHook, req *request.WebHookUpdate) error { + if mock.UpdateWithScriptFunc == nil { + panic("WebHookRepo.UpdateWithScriptFunc: method is nil but WebHookRepo.UpdateWithScript was just called") + } + callInfo := struct { + Webhook *biz.WebHook + Req *request.WebHookUpdate + }{ + Webhook: webhook, + Req: req, + } + mock.lockUpdateWithScript.Lock() + mock.calls.UpdateWithScript = append(mock.calls.UpdateWithScript, callInfo) + mock.lockUpdateWithScript.Unlock() + return mock.UpdateWithScriptFunc(webhook, req) +} + +// UpdateWithScriptCalls gets all the calls that were made to UpdateWithScript. +// Check the length with: +// +// len(mockedWebHookRepo.UpdateWithScriptCalls()) +func (mock *WebHookRepo) UpdateWithScriptCalls() []struct { + Webhook *biz.WebHook + Req *request.WebHookUpdate +} { + var calls []struct { + Webhook *biz.WebHook + Req *request.WebHookUpdate + } + mock.lockUpdateWithScript.RLock() + calls = mock.calls.UpdateWithScript + mock.lockUpdateWithScript.RUnlock() + return calls +} diff --git a/internal/mocks/biz/WebsiteRepo.go b/internal/mocks/biz/WebsiteRepo.go new file mode 100644 index 000000000..cb5caed55 --- /dev/null +++ b/internal/mocks/biz/WebsiteRepo.go @@ -0,0 +1,887 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + "time" + + "github.com/acepanel/panel/v3/internal/biz" + "github.com/acepanel/panel/v3/internal/request" + "github.com/acepanel/panel/v3/pkg/types" +) + +// Ensure that WebsiteRepo does implement biz.WebsiteRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.WebsiteRepo = &WebsiteRepo{} + +// WebsiteRepo is a mock implementation of biz.WebsiteRepo. +// +// func TestSomethingThatUsesWebsiteRepo(t *testing.T) { +// +// // make and configure a mocked biz.WebsiteRepo +// mockedWebsiteRepo := &WebsiteRepo{ +// CountFunc: func() (int64, error) { +// panic("mock out the Count method") +// }, +// CreateFunc: func(req *request.WebsiteCreate) (*biz.Website, error) { +// panic("mock out the Create method") +// }, +// DeleteFunc: func(website *biz.Website) error { +// panic("mock out the Delete method") +// }, +// GetFunc: func(id uint) (*types.WebsiteSetting, error) { +// panic("mock out the Get method") +// }, +// GetByNameFunc: func(name string) (*types.WebsiteSetting, error) { +// panic("mock out the GetByName method") +// }, +// GetForDeleteFunc: func(id uint) (*biz.Website, error) { +// panic("mock out the GetForDelete method") +// }, +// GetRewritesFunc: func() (map[string]string, error) { +// panic("mock out the GetRewrites method") +// }, +// ListFunc: func(typ string, page uint, limit uint) ([]*biz.Website, int64, error) { +// panic("mock out the List method") +// }, +// RebuildFunc: func(website *biz.Website) (bool, []string, error) { +// panic("mock out the Rebuild method") +// }, +// ReloadWebServerFunc: func() error { +// panic("mock out the ReloadWebServer method") +// }, +// RemoveFilesFunc: func(name string, removePath bool) error { +// panic("mock out the RemoveFiles method") +// }, +// ResetConfigFunc: func(id uint) error { +// panic("mock out the ResetConfig method") +// }, +// SwitchTypeFunc: func(req *request.WebsiteSwitchType) (*biz.Website, error) { +// panic("mock out the SwitchType method") +// }, +// UpdateFunc: func(req *request.WebsiteUpdate) (*biz.Website, error) { +// panic("mock out the Update method") +// }, +// UpdateCertFunc: func(req *request.WebsiteUpdateCert) error { +// panic("mock out the UpdateCert method") +// }, +// UpdateDefaultConfigFunc: func(req *request.WebsiteDefaultConfig) error { +// panic("mock out the UpdateDefaultConfig method") +// }, +// UpdateExpireAtFunc: func(id uint, expireAt *time.Time) error { +// panic("mock out the UpdateExpireAt method") +// }, +// UpdateRemarkFunc: func(id uint, remark string) error { +// panic("mock out the UpdateRemark method") +// }, +// UpdateStatusFunc: func(id uint, status bool) error { +// panic("mock out the UpdateStatus method") +// }, +// } +// +// // use mockedWebsiteRepo in code that requires biz.WebsiteRepo +// // and then make assertions. +// +// } +type WebsiteRepo struct { + // CountFunc mocks the Count method. + CountFunc func() (int64, error) + + // CreateFunc mocks the Create method. + CreateFunc func(req *request.WebsiteCreate) (*biz.Website, error) + + // DeleteFunc mocks the Delete method. + DeleteFunc func(website *biz.Website) error + + // GetFunc mocks the Get method. + GetFunc func(id uint) (*types.WebsiteSetting, error) + + // GetByNameFunc mocks the GetByName method. + GetByNameFunc func(name string) (*types.WebsiteSetting, error) + + // GetForDeleteFunc mocks the GetForDelete method. + GetForDeleteFunc func(id uint) (*biz.Website, error) + + // GetRewritesFunc mocks the GetRewrites method. + GetRewritesFunc func() (map[string]string, error) + + // ListFunc mocks the List method. + ListFunc func(typ string, page uint, limit uint) ([]*biz.Website, int64, error) + + // RebuildFunc mocks the Rebuild method. + RebuildFunc func(website *biz.Website) (bool, []string, error) + + // ReloadWebServerFunc mocks the ReloadWebServer method. + ReloadWebServerFunc func() error + + // RemoveFilesFunc mocks the RemoveFiles method. + RemoveFilesFunc func(name string, removePath bool) error + + // ResetConfigFunc mocks the ResetConfig method. + ResetConfigFunc func(id uint) error + + // SwitchTypeFunc mocks the SwitchType method. + SwitchTypeFunc func(req *request.WebsiteSwitchType) (*biz.Website, error) + + // UpdateFunc mocks the Update method. + UpdateFunc func(req *request.WebsiteUpdate) (*biz.Website, error) + + // UpdateCertFunc mocks the UpdateCert method. + UpdateCertFunc func(req *request.WebsiteUpdateCert) error + + // UpdateDefaultConfigFunc mocks the UpdateDefaultConfig method. + UpdateDefaultConfigFunc func(req *request.WebsiteDefaultConfig) error + + // UpdateExpireAtFunc mocks the UpdateExpireAt method. + UpdateExpireAtFunc func(id uint, expireAt *time.Time) error + + // UpdateRemarkFunc mocks the UpdateRemark method. + UpdateRemarkFunc func(id uint, remark string) error + + // UpdateStatusFunc mocks the UpdateStatus method. + UpdateStatusFunc func(id uint, status bool) error + + // calls tracks calls to the methods. + calls struct { + // Count holds details about calls to the Count method. + Count []struct { + } + // Create holds details about calls to the Create method. + Create []struct { + // Req is the req argument value. + Req *request.WebsiteCreate + } + // Delete holds details about calls to the Delete method. + Delete []struct { + // Website is the website argument value. + Website *biz.Website + } + // Get holds details about calls to the Get method. + Get []struct { + // ID is the id argument value. + ID uint + } + // GetByName holds details about calls to the GetByName method. + GetByName []struct { + // Name is the name argument value. + Name string + } + // GetForDelete holds details about calls to the GetForDelete method. + GetForDelete []struct { + // ID is the id argument value. + ID uint + } + // GetRewrites holds details about calls to the GetRewrites method. + GetRewrites []struct { + } + // List holds details about calls to the List method. + List []struct { + // Typ is the typ argument value. + Typ string + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // Rebuild holds details about calls to the Rebuild method. + Rebuild []struct { + // Website is the website argument value. + Website *biz.Website + } + // ReloadWebServer holds details about calls to the ReloadWebServer method. + ReloadWebServer []struct { + } + // RemoveFiles holds details about calls to the RemoveFiles method. + RemoveFiles []struct { + // Name is the name argument value. + Name string + // RemovePath is the removePath argument value. + RemovePath bool + } + // ResetConfig holds details about calls to the ResetConfig method. + ResetConfig []struct { + // ID is the id argument value. + ID uint + } + // SwitchType holds details about calls to the SwitchType method. + SwitchType []struct { + // Req is the req argument value. + Req *request.WebsiteSwitchType + } + // Update holds details about calls to the Update method. + Update []struct { + // Req is the req argument value. + Req *request.WebsiteUpdate + } + // UpdateCert holds details about calls to the UpdateCert method. + UpdateCert []struct { + // Req is the req argument value. + Req *request.WebsiteUpdateCert + } + // UpdateDefaultConfig holds details about calls to the UpdateDefaultConfig method. + UpdateDefaultConfig []struct { + // Req is the req argument value. + Req *request.WebsiteDefaultConfig + } + // UpdateExpireAt holds details about calls to the UpdateExpireAt method. + UpdateExpireAt []struct { + // ID is the id argument value. + ID uint + // ExpireAt is the expireAt argument value. + ExpireAt *time.Time + } + // UpdateRemark holds details about calls to the UpdateRemark method. + UpdateRemark []struct { + // ID is the id argument value. + ID uint + // Remark is the remark argument value. + Remark string + } + // UpdateStatus holds details about calls to the UpdateStatus method. + UpdateStatus []struct { + // ID is the id argument value. + ID uint + // Status is the status argument value. + Status bool + } + } + lockCount sync.RWMutex + lockCreate sync.RWMutex + lockDelete sync.RWMutex + lockGet sync.RWMutex + lockGetByName sync.RWMutex + lockGetForDelete sync.RWMutex + lockGetRewrites sync.RWMutex + lockList sync.RWMutex + lockRebuild sync.RWMutex + lockReloadWebServer sync.RWMutex + lockRemoveFiles sync.RWMutex + lockResetConfig sync.RWMutex + lockSwitchType sync.RWMutex + lockUpdate sync.RWMutex + lockUpdateCert sync.RWMutex + lockUpdateDefaultConfig sync.RWMutex + lockUpdateExpireAt sync.RWMutex + lockUpdateRemark sync.RWMutex + lockUpdateStatus sync.RWMutex +} + +// Count calls CountFunc. +func (mock *WebsiteRepo) Count() (int64, error) { + if mock.CountFunc == nil { + panic("WebsiteRepo.CountFunc: method is nil but WebsiteRepo.Count was just called") + } + callInfo := struct { + }{} + mock.lockCount.Lock() + mock.calls.Count = append(mock.calls.Count, callInfo) + mock.lockCount.Unlock() + return mock.CountFunc() +} + +// CountCalls gets all the calls that were made to Count. +// Check the length with: +// +// len(mockedWebsiteRepo.CountCalls()) +func (mock *WebsiteRepo) CountCalls() []struct { +} { + var calls []struct { + } + mock.lockCount.RLock() + calls = mock.calls.Count + mock.lockCount.RUnlock() + return calls +} + +// Create calls CreateFunc. +func (mock *WebsiteRepo) Create(req *request.WebsiteCreate) (*biz.Website, error) { + if mock.CreateFunc == nil { + panic("WebsiteRepo.CreateFunc: method is nil but WebsiteRepo.Create was just called") + } + callInfo := struct { + Req *request.WebsiteCreate + }{ + Req: req, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(req) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedWebsiteRepo.CreateCalls()) +func (mock *WebsiteRepo) CreateCalls() []struct { + Req *request.WebsiteCreate +} { + var calls []struct { + Req *request.WebsiteCreate + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Delete calls DeleteFunc. +func (mock *WebsiteRepo) Delete(website *biz.Website) error { + if mock.DeleteFunc == nil { + panic("WebsiteRepo.DeleteFunc: method is nil but WebsiteRepo.Delete was just called") + } + callInfo := struct { + Website *biz.Website + }{ + Website: website, + } + mock.lockDelete.Lock() + mock.calls.Delete = append(mock.calls.Delete, callInfo) + mock.lockDelete.Unlock() + return mock.DeleteFunc(website) +} + +// DeleteCalls gets all the calls that were made to Delete. +// Check the length with: +// +// len(mockedWebsiteRepo.DeleteCalls()) +func (mock *WebsiteRepo) DeleteCalls() []struct { + Website *biz.Website +} { + var calls []struct { + Website *biz.Website + } + mock.lockDelete.RLock() + calls = mock.calls.Delete + mock.lockDelete.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *WebsiteRepo) Get(id uint) (*types.WebsiteSetting, error) { + if mock.GetFunc == nil { + panic("WebsiteRepo.GetFunc: method is nil but WebsiteRepo.Get was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedWebsiteRepo.GetCalls()) +func (mock *WebsiteRepo) GetCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// GetByName calls GetByNameFunc. +func (mock *WebsiteRepo) GetByName(name string) (*types.WebsiteSetting, error) { + if mock.GetByNameFunc == nil { + panic("WebsiteRepo.GetByNameFunc: method is nil but WebsiteRepo.GetByName was just called") + } + callInfo := struct { + Name string + }{ + Name: name, + } + mock.lockGetByName.Lock() + mock.calls.GetByName = append(mock.calls.GetByName, callInfo) + mock.lockGetByName.Unlock() + return mock.GetByNameFunc(name) +} + +// GetByNameCalls gets all the calls that were made to GetByName. +// Check the length with: +// +// len(mockedWebsiteRepo.GetByNameCalls()) +func (mock *WebsiteRepo) GetByNameCalls() []struct { + Name string +} { + var calls []struct { + Name string + } + mock.lockGetByName.RLock() + calls = mock.calls.GetByName + mock.lockGetByName.RUnlock() + return calls +} + +// GetForDelete calls GetForDeleteFunc. +func (mock *WebsiteRepo) GetForDelete(id uint) (*biz.Website, error) { + if mock.GetForDeleteFunc == nil { + panic("WebsiteRepo.GetForDeleteFunc: method is nil but WebsiteRepo.GetForDelete was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockGetForDelete.Lock() + mock.calls.GetForDelete = append(mock.calls.GetForDelete, callInfo) + mock.lockGetForDelete.Unlock() + return mock.GetForDeleteFunc(id) +} + +// GetForDeleteCalls gets all the calls that were made to GetForDelete. +// Check the length with: +// +// len(mockedWebsiteRepo.GetForDeleteCalls()) +func (mock *WebsiteRepo) GetForDeleteCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockGetForDelete.RLock() + calls = mock.calls.GetForDelete + mock.lockGetForDelete.RUnlock() + return calls +} + +// GetRewrites calls GetRewritesFunc. +func (mock *WebsiteRepo) GetRewrites() (map[string]string, error) { + if mock.GetRewritesFunc == nil { + panic("WebsiteRepo.GetRewritesFunc: method is nil but WebsiteRepo.GetRewrites was just called") + } + callInfo := struct { + }{} + mock.lockGetRewrites.Lock() + mock.calls.GetRewrites = append(mock.calls.GetRewrites, callInfo) + mock.lockGetRewrites.Unlock() + return mock.GetRewritesFunc() +} + +// GetRewritesCalls gets all the calls that were made to GetRewrites. +// Check the length with: +// +// len(mockedWebsiteRepo.GetRewritesCalls()) +func (mock *WebsiteRepo) GetRewritesCalls() []struct { +} { + var calls []struct { + } + mock.lockGetRewrites.RLock() + calls = mock.calls.GetRewrites + mock.lockGetRewrites.RUnlock() + return calls +} + +// List calls ListFunc. +func (mock *WebsiteRepo) List(typ string, page uint, limit uint) ([]*biz.Website, int64, error) { + if mock.ListFunc == nil { + panic("WebsiteRepo.ListFunc: method is nil but WebsiteRepo.List was just called") + } + callInfo := struct { + Typ string + Page uint + Limit uint + }{ + Typ: typ, + Page: page, + Limit: limit, + } + mock.lockList.Lock() + mock.calls.List = append(mock.calls.List, callInfo) + mock.lockList.Unlock() + return mock.ListFunc(typ, page, limit) +} + +// ListCalls gets all the calls that were made to List. +// Check the length with: +// +// len(mockedWebsiteRepo.ListCalls()) +func (mock *WebsiteRepo) ListCalls() []struct { + Typ string + Page uint + Limit uint +} { + var calls []struct { + Typ string + Page uint + Limit uint + } + mock.lockList.RLock() + calls = mock.calls.List + mock.lockList.RUnlock() + return calls +} + +// Rebuild calls RebuildFunc. +func (mock *WebsiteRepo) Rebuild(website *biz.Website) (bool, []string, error) { + if mock.RebuildFunc == nil { + panic("WebsiteRepo.RebuildFunc: method is nil but WebsiteRepo.Rebuild was just called") + } + callInfo := struct { + Website *biz.Website + }{ + Website: website, + } + mock.lockRebuild.Lock() + mock.calls.Rebuild = append(mock.calls.Rebuild, callInfo) + mock.lockRebuild.Unlock() + return mock.RebuildFunc(website) +} + +// RebuildCalls gets all the calls that were made to Rebuild. +// Check the length with: +// +// len(mockedWebsiteRepo.RebuildCalls()) +func (mock *WebsiteRepo) RebuildCalls() []struct { + Website *biz.Website +} { + var calls []struct { + Website *biz.Website + } + mock.lockRebuild.RLock() + calls = mock.calls.Rebuild + mock.lockRebuild.RUnlock() + return calls +} + +// ReloadWebServer calls ReloadWebServerFunc. +func (mock *WebsiteRepo) ReloadWebServer() error { + if mock.ReloadWebServerFunc == nil { + panic("WebsiteRepo.ReloadWebServerFunc: method is nil but WebsiteRepo.ReloadWebServer was just called") + } + callInfo := struct { + }{} + mock.lockReloadWebServer.Lock() + mock.calls.ReloadWebServer = append(mock.calls.ReloadWebServer, callInfo) + mock.lockReloadWebServer.Unlock() + return mock.ReloadWebServerFunc() +} + +// ReloadWebServerCalls gets all the calls that were made to ReloadWebServer. +// Check the length with: +// +// len(mockedWebsiteRepo.ReloadWebServerCalls()) +func (mock *WebsiteRepo) ReloadWebServerCalls() []struct { +} { + var calls []struct { + } + mock.lockReloadWebServer.RLock() + calls = mock.calls.ReloadWebServer + mock.lockReloadWebServer.RUnlock() + return calls +} + +// RemoveFiles calls RemoveFilesFunc. +func (mock *WebsiteRepo) RemoveFiles(name string, removePath bool) error { + if mock.RemoveFilesFunc == nil { + panic("WebsiteRepo.RemoveFilesFunc: method is nil but WebsiteRepo.RemoveFiles was just called") + } + callInfo := struct { + Name string + RemovePath bool + }{ + Name: name, + RemovePath: removePath, + } + mock.lockRemoveFiles.Lock() + mock.calls.RemoveFiles = append(mock.calls.RemoveFiles, callInfo) + mock.lockRemoveFiles.Unlock() + return mock.RemoveFilesFunc(name, removePath) +} + +// RemoveFilesCalls gets all the calls that were made to RemoveFiles. +// Check the length with: +// +// len(mockedWebsiteRepo.RemoveFilesCalls()) +func (mock *WebsiteRepo) RemoveFilesCalls() []struct { + Name string + RemovePath bool +} { + var calls []struct { + Name string + RemovePath bool + } + mock.lockRemoveFiles.RLock() + calls = mock.calls.RemoveFiles + mock.lockRemoveFiles.RUnlock() + return calls +} + +// ResetConfig calls ResetConfigFunc. +func (mock *WebsiteRepo) ResetConfig(id uint) error { + if mock.ResetConfigFunc == nil { + panic("WebsiteRepo.ResetConfigFunc: method is nil but WebsiteRepo.ResetConfig was just called") + } + callInfo := struct { + ID uint + }{ + ID: id, + } + mock.lockResetConfig.Lock() + mock.calls.ResetConfig = append(mock.calls.ResetConfig, callInfo) + mock.lockResetConfig.Unlock() + return mock.ResetConfigFunc(id) +} + +// ResetConfigCalls gets all the calls that were made to ResetConfig. +// Check the length with: +// +// len(mockedWebsiteRepo.ResetConfigCalls()) +func (mock *WebsiteRepo) ResetConfigCalls() []struct { + ID uint +} { + var calls []struct { + ID uint + } + mock.lockResetConfig.RLock() + calls = mock.calls.ResetConfig + mock.lockResetConfig.RUnlock() + return calls +} + +// SwitchType calls SwitchTypeFunc. +func (mock *WebsiteRepo) SwitchType(req *request.WebsiteSwitchType) (*biz.Website, error) { + if mock.SwitchTypeFunc == nil { + panic("WebsiteRepo.SwitchTypeFunc: method is nil but WebsiteRepo.SwitchType was just called") + } + callInfo := struct { + Req *request.WebsiteSwitchType + }{ + Req: req, + } + mock.lockSwitchType.Lock() + mock.calls.SwitchType = append(mock.calls.SwitchType, callInfo) + mock.lockSwitchType.Unlock() + return mock.SwitchTypeFunc(req) +} + +// SwitchTypeCalls gets all the calls that were made to SwitchType. +// Check the length with: +// +// len(mockedWebsiteRepo.SwitchTypeCalls()) +func (mock *WebsiteRepo) SwitchTypeCalls() []struct { + Req *request.WebsiteSwitchType +} { + var calls []struct { + Req *request.WebsiteSwitchType + } + mock.lockSwitchType.RLock() + calls = mock.calls.SwitchType + mock.lockSwitchType.RUnlock() + return calls +} + +// Update calls UpdateFunc. +func (mock *WebsiteRepo) Update(req *request.WebsiteUpdate) (*biz.Website, error) { + if mock.UpdateFunc == nil { + panic("WebsiteRepo.UpdateFunc: method is nil but WebsiteRepo.Update was just called") + } + callInfo := struct { + Req *request.WebsiteUpdate + }{ + Req: req, + } + mock.lockUpdate.Lock() + mock.calls.Update = append(mock.calls.Update, callInfo) + mock.lockUpdate.Unlock() + return mock.UpdateFunc(req) +} + +// UpdateCalls gets all the calls that were made to Update. +// Check the length with: +// +// len(mockedWebsiteRepo.UpdateCalls()) +func (mock *WebsiteRepo) UpdateCalls() []struct { + Req *request.WebsiteUpdate +} { + var calls []struct { + Req *request.WebsiteUpdate + } + mock.lockUpdate.RLock() + calls = mock.calls.Update + mock.lockUpdate.RUnlock() + return calls +} + +// UpdateCert calls UpdateCertFunc. +func (mock *WebsiteRepo) UpdateCert(req *request.WebsiteUpdateCert) error { + if mock.UpdateCertFunc == nil { + panic("WebsiteRepo.UpdateCertFunc: method is nil but WebsiteRepo.UpdateCert was just called") + } + callInfo := struct { + Req *request.WebsiteUpdateCert + }{ + Req: req, + } + mock.lockUpdateCert.Lock() + mock.calls.UpdateCert = append(mock.calls.UpdateCert, callInfo) + mock.lockUpdateCert.Unlock() + return mock.UpdateCertFunc(req) +} + +// UpdateCertCalls gets all the calls that were made to UpdateCert. +// Check the length with: +// +// len(mockedWebsiteRepo.UpdateCertCalls()) +func (mock *WebsiteRepo) UpdateCertCalls() []struct { + Req *request.WebsiteUpdateCert +} { + var calls []struct { + Req *request.WebsiteUpdateCert + } + mock.lockUpdateCert.RLock() + calls = mock.calls.UpdateCert + mock.lockUpdateCert.RUnlock() + return calls +} + +// UpdateDefaultConfig calls UpdateDefaultConfigFunc. +func (mock *WebsiteRepo) UpdateDefaultConfig(req *request.WebsiteDefaultConfig) error { + if mock.UpdateDefaultConfigFunc == nil { + panic("WebsiteRepo.UpdateDefaultConfigFunc: method is nil but WebsiteRepo.UpdateDefaultConfig was just called") + } + callInfo := struct { + Req *request.WebsiteDefaultConfig + }{ + Req: req, + } + mock.lockUpdateDefaultConfig.Lock() + mock.calls.UpdateDefaultConfig = append(mock.calls.UpdateDefaultConfig, callInfo) + mock.lockUpdateDefaultConfig.Unlock() + return mock.UpdateDefaultConfigFunc(req) +} + +// UpdateDefaultConfigCalls gets all the calls that were made to UpdateDefaultConfig. +// Check the length with: +// +// len(mockedWebsiteRepo.UpdateDefaultConfigCalls()) +func (mock *WebsiteRepo) UpdateDefaultConfigCalls() []struct { + Req *request.WebsiteDefaultConfig +} { + var calls []struct { + Req *request.WebsiteDefaultConfig + } + mock.lockUpdateDefaultConfig.RLock() + calls = mock.calls.UpdateDefaultConfig + mock.lockUpdateDefaultConfig.RUnlock() + return calls +} + +// UpdateExpireAt calls UpdateExpireAtFunc. +func (mock *WebsiteRepo) UpdateExpireAt(id uint, expireAt *time.Time) error { + if mock.UpdateExpireAtFunc == nil { + panic("WebsiteRepo.UpdateExpireAtFunc: method is nil but WebsiteRepo.UpdateExpireAt was just called") + } + callInfo := struct { + ID uint + ExpireAt *time.Time + }{ + ID: id, + ExpireAt: expireAt, + } + mock.lockUpdateExpireAt.Lock() + mock.calls.UpdateExpireAt = append(mock.calls.UpdateExpireAt, callInfo) + mock.lockUpdateExpireAt.Unlock() + return mock.UpdateExpireAtFunc(id, expireAt) +} + +// UpdateExpireAtCalls gets all the calls that were made to UpdateExpireAt. +// Check the length with: +// +// len(mockedWebsiteRepo.UpdateExpireAtCalls()) +func (mock *WebsiteRepo) UpdateExpireAtCalls() []struct { + ID uint + ExpireAt *time.Time +} { + var calls []struct { + ID uint + ExpireAt *time.Time + } + mock.lockUpdateExpireAt.RLock() + calls = mock.calls.UpdateExpireAt + mock.lockUpdateExpireAt.RUnlock() + return calls +} + +// UpdateRemark calls UpdateRemarkFunc. +func (mock *WebsiteRepo) UpdateRemark(id uint, remark string) error { + if mock.UpdateRemarkFunc == nil { + panic("WebsiteRepo.UpdateRemarkFunc: method is nil but WebsiteRepo.UpdateRemark was just called") + } + callInfo := struct { + ID uint + Remark string + }{ + ID: id, + Remark: remark, + } + mock.lockUpdateRemark.Lock() + mock.calls.UpdateRemark = append(mock.calls.UpdateRemark, callInfo) + mock.lockUpdateRemark.Unlock() + return mock.UpdateRemarkFunc(id, remark) +} + +// UpdateRemarkCalls gets all the calls that were made to UpdateRemark. +// Check the length with: +// +// len(mockedWebsiteRepo.UpdateRemarkCalls()) +func (mock *WebsiteRepo) UpdateRemarkCalls() []struct { + ID uint + Remark string +} { + var calls []struct { + ID uint + Remark string + } + mock.lockUpdateRemark.RLock() + calls = mock.calls.UpdateRemark + mock.lockUpdateRemark.RUnlock() + return calls +} + +// UpdateStatus calls UpdateStatusFunc. +func (mock *WebsiteRepo) UpdateStatus(id uint, status bool) error { + if mock.UpdateStatusFunc == nil { + panic("WebsiteRepo.UpdateStatusFunc: method is nil but WebsiteRepo.UpdateStatus was just called") + } + callInfo := struct { + ID uint + Status bool + }{ + ID: id, + Status: status, + } + mock.lockUpdateStatus.Lock() + mock.calls.UpdateStatus = append(mock.calls.UpdateStatus, callInfo) + mock.lockUpdateStatus.Unlock() + return mock.UpdateStatusFunc(id, status) +} + +// UpdateStatusCalls gets all the calls that were made to UpdateStatus. +// Check the length with: +// +// len(mockedWebsiteRepo.UpdateStatusCalls()) +func (mock *WebsiteRepo) UpdateStatusCalls() []struct { + ID uint + Status bool +} { + var calls []struct { + ID uint + Status bool + } + mock.lockUpdateStatus.RLock() + calls = mock.calls.UpdateStatus + mock.lockUpdateStatus.RUnlock() + return calls +} diff --git a/internal/mocks/biz/WebsiteStatRepo.go b/internal/mocks/biz/WebsiteStatRepo.go new file mode 100644 index 000000000..18a1fb196 --- /dev/null +++ b/internal/mocks/biz/WebsiteStatRepo.go @@ -0,0 +1,1380 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: matryer + +package biz + +import ( + "sync" + "time" + + "github.com/acepanel/panel/v3/internal/biz" +) + +// Ensure that WebsiteStatRepo does implement biz.WebsiteStatRepo. +// If this is not the case, regenerate this file with mockery. +var _ biz.WebsiteStatRepo = &WebsiteStatRepo{} + +// WebsiteStatRepo is a mock implementation of biz.WebsiteStatRepo. +// +// func TestSomethingThatUsesWebsiteStatRepo(t *testing.T) { +// +// // make and configure a mocked biz.WebsiteStatRepo +// mockedWebsiteStatRepo := &WebsiteStatRepo{ +// ClearFunc: func() error { +// panic("mock out the Clear method") +// }, +// ClearBeforeFunc: func(date string) error { +// panic("mock out the ClearBefore method") +// }, +// ClearClientsBeforeFunc: func(date string) error { +// panic("mock out the ClearClientsBefore method") +// }, +// ClearErrorsBeforeFunc: func(t time.Time) error { +// panic("mock out the ClearErrorsBefore method") +// }, +// ClearIPsBeforeFunc: func(date string) error { +// panic("mock out the ClearIPsBefore method") +// }, +// ClearSpidersBeforeFunc: func(date string) error { +// panic("mock out the ClearSpidersBefore method") +// }, +// ClearURIsBeforeFunc: func(date string) error { +// panic("mock out the ClearURIsBefore method") +// }, +// DailySeriesFunc: func(start string, end string, sites []string) ([]*biz.WebsiteStatSeries, error) { +// panic("mock out the DailySeries method") +// }, +// DeleteBySiteFunc: func(site string) error { +// panic("mock out the DeleteBySite method") +// }, +// HourlySeriesFunc: func(date string, sites []string) ([]*biz.WebsiteStatSeries, error) { +// panic("mock out the HourlySeries method") +// }, +// InsertErrorsFunc: func(errors []*biz.WebsiteErrorLog) error { +// panic("mock out the InsertErrors method") +// }, +// ListByDateRangeFunc: func(start string, end string, sites []string) ([]*biz.WebsiteStat, error) { +// panic("mock out the ListByDateRange method") +// }, +// ListErrorsFunc: func(start string, end string, sites []string, status int, page uint, limit uint) ([]*biz.WebsiteErrorLog, uint, error) { +// panic("mock out the ListErrors method") +// }, +// ListSiteStatsFunc: func(start string, end string, sites []string) ([]*biz.WebsiteStatSiteItem, error) { +// panic("mock out the ListSiteStats method") +// }, +// TopClientsFunc: func(start string, end string, sites []string, limit uint) ([]*biz.WebsiteStatClientRank, error) { +// panic("mock out the TopClients method") +// }, +// TopGeosFunc: func(start string, end string, sites []string, groupBy string, country string, limit uint) ([]*biz.WebsiteStatGeoRank, error) { +// panic("mock out the TopGeos method") +// }, +// TopIPsFunc: func(start string, end string, sites []string, page uint, limit uint) ([]*biz.WebsiteStatIPRank, uint, error) { +// panic("mock out the TopIPs method") +// }, +// TopSlowURIsFunc: func(start string, end string, sites []string, threshold uint, page uint, limit uint) ([]*biz.WebsiteStatURIRank, uint, error) { +// panic("mock out the TopSlowURIs method") +// }, +// TopSpidersFunc: func(start string, end string, sites []string, limit uint) ([]*biz.WebsiteStatSpiderRank, error) { +// panic("mock out the TopSpiders method") +// }, +// TopURIsFunc: func(start string, end string, sites []string, page uint, limit uint) ([]*biz.WebsiteStatURIRank, uint, error) { +// panic("mock out the TopURIs method") +// }, +// UpsertFunc: func(stats []*biz.WebsiteStat) error { +// panic("mock out the Upsert method") +// }, +// UpsertClientsFunc: func(stats []*biz.WebsiteStatClient) error { +// panic("mock out the UpsertClients method") +// }, +// UpsertIPsFunc: func(stats []*biz.WebsiteStatIP) error { +// panic("mock out the UpsertIPs method") +// }, +// UpsertSpidersFunc: func(stats []*biz.WebsiteStatSpider) error { +// panic("mock out the UpsertSpiders method") +// }, +// UpsertURIsFunc: func(stats []*biz.WebsiteStatURI) error { +// panic("mock out the UpsertURIs method") +// }, +// VacuumDBFunc: func() error { +// panic("mock out the VacuumDB method") +// }, +// } +// +// // use mockedWebsiteStatRepo in code that requires biz.WebsiteStatRepo +// // and then make assertions. +// +// } +type WebsiteStatRepo struct { + // ClearFunc mocks the Clear method. + ClearFunc func() error + + // ClearBeforeFunc mocks the ClearBefore method. + ClearBeforeFunc func(date string) error + + // ClearClientsBeforeFunc mocks the ClearClientsBefore method. + ClearClientsBeforeFunc func(date string) error + + // ClearErrorsBeforeFunc mocks the ClearErrorsBefore method. + ClearErrorsBeforeFunc func(t time.Time) error + + // ClearIPsBeforeFunc mocks the ClearIPsBefore method. + ClearIPsBeforeFunc func(date string) error + + // ClearSpidersBeforeFunc mocks the ClearSpidersBefore method. + ClearSpidersBeforeFunc func(date string) error + + // ClearURIsBeforeFunc mocks the ClearURIsBefore method. + ClearURIsBeforeFunc func(date string) error + + // DailySeriesFunc mocks the DailySeries method. + DailySeriesFunc func(start string, end string, sites []string) ([]*biz.WebsiteStatSeries, error) + + // DeleteBySiteFunc mocks the DeleteBySite method. + DeleteBySiteFunc func(site string) error + + // HourlySeriesFunc mocks the HourlySeries method. + HourlySeriesFunc func(date string, sites []string) ([]*biz.WebsiteStatSeries, error) + + // InsertErrorsFunc mocks the InsertErrors method. + InsertErrorsFunc func(errors []*biz.WebsiteErrorLog) error + + // ListByDateRangeFunc mocks the ListByDateRange method. + ListByDateRangeFunc func(start string, end string, sites []string) ([]*biz.WebsiteStat, error) + + // ListErrorsFunc mocks the ListErrors method. + ListErrorsFunc func(start string, end string, sites []string, status int, page uint, limit uint) ([]*biz.WebsiteErrorLog, uint, error) + + // ListSiteStatsFunc mocks the ListSiteStats method. + ListSiteStatsFunc func(start string, end string, sites []string) ([]*biz.WebsiteStatSiteItem, error) + + // TopClientsFunc mocks the TopClients method. + TopClientsFunc func(start string, end string, sites []string, limit uint) ([]*biz.WebsiteStatClientRank, error) + + // TopGeosFunc mocks the TopGeos method. + TopGeosFunc func(start string, end string, sites []string, groupBy string, country string, limit uint) ([]*biz.WebsiteStatGeoRank, error) + + // TopIPsFunc mocks the TopIPs method. + TopIPsFunc func(start string, end string, sites []string, page uint, limit uint) ([]*biz.WebsiteStatIPRank, uint, error) + + // TopSlowURIsFunc mocks the TopSlowURIs method. + TopSlowURIsFunc func(start string, end string, sites []string, threshold uint, page uint, limit uint) ([]*biz.WebsiteStatURIRank, uint, error) + + // TopSpidersFunc mocks the TopSpiders method. + TopSpidersFunc func(start string, end string, sites []string, limit uint) ([]*biz.WebsiteStatSpiderRank, error) + + // TopURIsFunc mocks the TopURIs method. + TopURIsFunc func(start string, end string, sites []string, page uint, limit uint) ([]*biz.WebsiteStatURIRank, uint, error) + + // UpsertFunc mocks the Upsert method. + UpsertFunc func(stats []*biz.WebsiteStat) error + + // UpsertClientsFunc mocks the UpsertClients method. + UpsertClientsFunc func(stats []*biz.WebsiteStatClient) error + + // UpsertIPsFunc mocks the UpsertIPs method. + UpsertIPsFunc func(stats []*biz.WebsiteStatIP) error + + // UpsertSpidersFunc mocks the UpsertSpiders method. + UpsertSpidersFunc func(stats []*biz.WebsiteStatSpider) error + + // UpsertURIsFunc mocks the UpsertURIs method. + UpsertURIsFunc func(stats []*biz.WebsiteStatURI) error + + // VacuumDBFunc mocks the VacuumDB method. + VacuumDBFunc func() error + + // calls tracks calls to the methods. + calls struct { + // Clear holds details about calls to the Clear method. + Clear []struct { + } + // ClearBefore holds details about calls to the ClearBefore method. + ClearBefore []struct { + // Date is the date argument value. + Date string + } + // ClearClientsBefore holds details about calls to the ClearClientsBefore method. + ClearClientsBefore []struct { + // Date is the date argument value. + Date string + } + // ClearErrorsBefore holds details about calls to the ClearErrorsBefore method. + ClearErrorsBefore []struct { + // T is the t argument value. + T time.Time + } + // ClearIPsBefore holds details about calls to the ClearIPsBefore method. + ClearIPsBefore []struct { + // Date is the date argument value. + Date string + } + // ClearSpidersBefore holds details about calls to the ClearSpidersBefore method. + ClearSpidersBefore []struct { + // Date is the date argument value. + Date string + } + // ClearURIsBefore holds details about calls to the ClearURIsBefore method. + ClearURIsBefore []struct { + // Date is the date argument value. + Date string + } + // DailySeries holds details about calls to the DailySeries method. + DailySeries []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Sites is the sites argument value. + Sites []string + } + // DeleteBySite holds details about calls to the DeleteBySite method. + DeleteBySite []struct { + // Site is the site argument value. + Site string + } + // HourlySeries holds details about calls to the HourlySeries method. + HourlySeries []struct { + // Date is the date argument value. + Date string + // Sites is the sites argument value. + Sites []string + } + // InsertErrors holds details about calls to the InsertErrors method. + InsertErrors []struct { + // Errors is the errors argument value. + Errors []*biz.WebsiteErrorLog + } + // ListByDateRange holds details about calls to the ListByDateRange method. + ListByDateRange []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Sites is the sites argument value. + Sites []string + } + // ListErrors holds details about calls to the ListErrors method. + ListErrors []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Sites is the sites argument value. + Sites []string + // Status is the status argument value. + Status int + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // ListSiteStats holds details about calls to the ListSiteStats method. + ListSiteStats []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Sites is the sites argument value. + Sites []string + } + // TopClients holds details about calls to the TopClients method. + TopClients []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Sites is the sites argument value. + Sites []string + // Limit is the limit argument value. + Limit uint + } + // TopGeos holds details about calls to the TopGeos method. + TopGeos []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Sites is the sites argument value. + Sites []string + // GroupBy is the groupBy argument value. + GroupBy string + // Country is the country argument value. + Country string + // Limit is the limit argument value. + Limit uint + } + // TopIPs holds details about calls to the TopIPs method. + TopIPs []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Sites is the sites argument value. + Sites []string + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // TopSlowURIs holds details about calls to the TopSlowURIs method. + TopSlowURIs []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Sites is the sites argument value. + Sites []string + // Threshold is the threshold argument value. + Threshold uint + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // TopSpiders holds details about calls to the TopSpiders method. + TopSpiders []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Sites is the sites argument value. + Sites []string + // Limit is the limit argument value. + Limit uint + } + // TopURIs holds details about calls to the TopURIs method. + TopURIs []struct { + // Start is the start argument value. + Start string + // End is the end argument value. + End string + // Sites is the sites argument value. + Sites []string + // Page is the page argument value. + Page uint + // Limit is the limit argument value. + Limit uint + } + // Upsert holds details about calls to the Upsert method. + Upsert []struct { + // Stats is the stats argument value. + Stats []*biz.WebsiteStat + } + // UpsertClients holds details about calls to the UpsertClients method. + UpsertClients []struct { + // Stats is the stats argument value. + Stats []*biz.WebsiteStatClient + } + // UpsertIPs holds details about calls to the UpsertIPs method. + UpsertIPs []struct { + // Stats is the stats argument value. + Stats []*biz.WebsiteStatIP + } + // UpsertSpiders holds details about calls to the UpsertSpiders method. + UpsertSpiders []struct { + // Stats is the stats argument value. + Stats []*biz.WebsiteStatSpider + } + // UpsertURIs holds details about calls to the UpsertURIs method. + UpsertURIs []struct { + // Stats is the stats argument value. + Stats []*biz.WebsiteStatURI + } + // VacuumDB holds details about calls to the VacuumDB method. + VacuumDB []struct { + } + } + lockClear sync.RWMutex + lockClearBefore sync.RWMutex + lockClearClientsBefore sync.RWMutex + lockClearErrorsBefore sync.RWMutex + lockClearIPsBefore sync.RWMutex + lockClearSpidersBefore sync.RWMutex + lockClearURIsBefore sync.RWMutex + lockDailySeries sync.RWMutex + lockDeleteBySite sync.RWMutex + lockHourlySeries sync.RWMutex + lockInsertErrors sync.RWMutex + lockListByDateRange sync.RWMutex + lockListErrors sync.RWMutex + lockListSiteStats sync.RWMutex + lockTopClients sync.RWMutex + lockTopGeos sync.RWMutex + lockTopIPs sync.RWMutex + lockTopSlowURIs sync.RWMutex + lockTopSpiders sync.RWMutex + lockTopURIs sync.RWMutex + lockUpsert sync.RWMutex + lockUpsertClients sync.RWMutex + lockUpsertIPs sync.RWMutex + lockUpsertSpiders sync.RWMutex + lockUpsertURIs sync.RWMutex + lockVacuumDB sync.RWMutex +} + +// Clear calls ClearFunc. +func (mock *WebsiteStatRepo) Clear() error { + if mock.ClearFunc == nil { + panic("WebsiteStatRepo.ClearFunc: method is nil but WebsiteStatRepo.Clear was just called") + } + callInfo := struct { + }{} + mock.lockClear.Lock() + mock.calls.Clear = append(mock.calls.Clear, callInfo) + mock.lockClear.Unlock() + return mock.ClearFunc() +} + +// ClearCalls gets all the calls that were made to Clear. +// Check the length with: +// +// len(mockedWebsiteStatRepo.ClearCalls()) +func (mock *WebsiteStatRepo) ClearCalls() []struct { +} { + var calls []struct { + } + mock.lockClear.RLock() + calls = mock.calls.Clear + mock.lockClear.RUnlock() + return calls +} + +// ClearBefore calls ClearBeforeFunc. +func (mock *WebsiteStatRepo) ClearBefore(date string) error { + if mock.ClearBeforeFunc == nil { + panic("WebsiteStatRepo.ClearBeforeFunc: method is nil but WebsiteStatRepo.ClearBefore was just called") + } + callInfo := struct { + Date string + }{ + Date: date, + } + mock.lockClearBefore.Lock() + mock.calls.ClearBefore = append(mock.calls.ClearBefore, callInfo) + mock.lockClearBefore.Unlock() + return mock.ClearBeforeFunc(date) +} + +// ClearBeforeCalls gets all the calls that were made to ClearBefore. +// Check the length with: +// +// len(mockedWebsiteStatRepo.ClearBeforeCalls()) +func (mock *WebsiteStatRepo) ClearBeforeCalls() []struct { + Date string +} { + var calls []struct { + Date string + } + mock.lockClearBefore.RLock() + calls = mock.calls.ClearBefore + mock.lockClearBefore.RUnlock() + return calls +} + +// ClearClientsBefore calls ClearClientsBeforeFunc. +func (mock *WebsiteStatRepo) ClearClientsBefore(date string) error { + if mock.ClearClientsBeforeFunc == nil { + panic("WebsiteStatRepo.ClearClientsBeforeFunc: method is nil but WebsiteStatRepo.ClearClientsBefore was just called") + } + callInfo := struct { + Date string + }{ + Date: date, + } + mock.lockClearClientsBefore.Lock() + mock.calls.ClearClientsBefore = append(mock.calls.ClearClientsBefore, callInfo) + mock.lockClearClientsBefore.Unlock() + return mock.ClearClientsBeforeFunc(date) +} + +// ClearClientsBeforeCalls gets all the calls that were made to ClearClientsBefore. +// Check the length with: +// +// len(mockedWebsiteStatRepo.ClearClientsBeforeCalls()) +func (mock *WebsiteStatRepo) ClearClientsBeforeCalls() []struct { + Date string +} { + var calls []struct { + Date string + } + mock.lockClearClientsBefore.RLock() + calls = mock.calls.ClearClientsBefore + mock.lockClearClientsBefore.RUnlock() + return calls +} + +// ClearErrorsBefore calls ClearErrorsBeforeFunc. +func (mock *WebsiteStatRepo) ClearErrorsBefore(t time.Time) error { + if mock.ClearErrorsBeforeFunc == nil { + panic("WebsiteStatRepo.ClearErrorsBeforeFunc: method is nil but WebsiteStatRepo.ClearErrorsBefore was just called") + } + callInfo := struct { + T time.Time + }{ + T: t, + } + mock.lockClearErrorsBefore.Lock() + mock.calls.ClearErrorsBefore = append(mock.calls.ClearErrorsBefore, callInfo) + mock.lockClearErrorsBefore.Unlock() + return mock.ClearErrorsBeforeFunc(t) +} + +// ClearErrorsBeforeCalls gets all the calls that were made to ClearErrorsBefore. +// Check the length with: +// +// len(mockedWebsiteStatRepo.ClearErrorsBeforeCalls()) +func (mock *WebsiteStatRepo) ClearErrorsBeforeCalls() []struct { + T time.Time +} { + var calls []struct { + T time.Time + } + mock.lockClearErrorsBefore.RLock() + calls = mock.calls.ClearErrorsBefore + mock.lockClearErrorsBefore.RUnlock() + return calls +} + +// ClearIPsBefore calls ClearIPsBeforeFunc. +func (mock *WebsiteStatRepo) ClearIPsBefore(date string) error { + if mock.ClearIPsBeforeFunc == nil { + panic("WebsiteStatRepo.ClearIPsBeforeFunc: method is nil but WebsiteStatRepo.ClearIPsBefore was just called") + } + callInfo := struct { + Date string + }{ + Date: date, + } + mock.lockClearIPsBefore.Lock() + mock.calls.ClearIPsBefore = append(mock.calls.ClearIPsBefore, callInfo) + mock.lockClearIPsBefore.Unlock() + return mock.ClearIPsBeforeFunc(date) +} + +// ClearIPsBeforeCalls gets all the calls that were made to ClearIPsBefore. +// Check the length with: +// +// len(mockedWebsiteStatRepo.ClearIPsBeforeCalls()) +func (mock *WebsiteStatRepo) ClearIPsBeforeCalls() []struct { + Date string +} { + var calls []struct { + Date string + } + mock.lockClearIPsBefore.RLock() + calls = mock.calls.ClearIPsBefore + mock.lockClearIPsBefore.RUnlock() + return calls +} + +// ClearSpidersBefore calls ClearSpidersBeforeFunc. +func (mock *WebsiteStatRepo) ClearSpidersBefore(date string) error { + if mock.ClearSpidersBeforeFunc == nil { + panic("WebsiteStatRepo.ClearSpidersBeforeFunc: method is nil but WebsiteStatRepo.ClearSpidersBefore was just called") + } + callInfo := struct { + Date string + }{ + Date: date, + } + mock.lockClearSpidersBefore.Lock() + mock.calls.ClearSpidersBefore = append(mock.calls.ClearSpidersBefore, callInfo) + mock.lockClearSpidersBefore.Unlock() + return mock.ClearSpidersBeforeFunc(date) +} + +// ClearSpidersBeforeCalls gets all the calls that were made to ClearSpidersBefore. +// Check the length with: +// +// len(mockedWebsiteStatRepo.ClearSpidersBeforeCalls()) +func (mock *WebsiteStatRepo) ClearSpidersBeforeCalls() []struct { + Date string +} { + var calls []struct { + Date string + } + mock.lockClearSpidersBefore.RLock() + calls = mock.calls.ClearSpidersBefore + mock.lockClearSpidersBefore.RUnlock() + return calls +} + +// ClearURIsBefore calls ClearURIsBeforeFunc. +func (mock *WebsiteStatRepo) ClearURIsBefore(date string) error { + if mock.ClearURIsBeforeFunc == nil { + panic("WebsiteStatRepo.ClearURIsBeforeFunc: method is nil but WebsiteStatRepo.ClearURIsBefore was just called") + } + callInfo := struct { + Date string + }{ + Date: date, + } + mock.lockClearURIsBefore.Lock() + mock.calls.ClearURIsBefore = append(mock.calls.ClearURIsBefore, callInfo) + mock.lockClearURIsBefore.Unlock() + return mock.ClearURIsBeforeFunc(date) +} + +// ClearURIsBeforeCalls gets all the calls that were made to ClearURIsBefore. +// Check the length with: +// +// len(mockedWebsiteStatRepo.ClearURIsBeforeCalls()) +func (mock *WebsiteStatRepo) ClearURIsBeforeCalls() []struct { + Date string +} { + var calls []struct { + Date string + } + mock.lockClearURIsBefore.RLock() + calls = mock.calls.ClearURIsBefore + mock.lockClearURIsBefore.RUnlock() + return calls +} + +// DailySeries calls DailySeriesFunc. +func (mock *WebsiteStatRepo) DailySeries(start string, end string, sites []string) ([]*biz.WebsiteStatSeries, error) { + if mock.DailySeriesFunc == nil { + panic("WebsiteStatRepo.DailySeriesFunc: method is nil but WebsiteStatRepo.DailySeries was just called") + } + callInfo := struct { + Start string + End string + Sites []string + }{ + Start: start, + End: end, + Sites: sites, + } + mock.lockDailySeries.Lock() + mock.calls.DailySeries = append(mock.calls.DailySeries, callInfo) + mock.lockDailySeries.Unlock() + return mock.DailySeriesFunc(start, end, sites) +} + +// DailySeriesCalls gets all the calls that were made to DailySeries. +// Check the length with: +// +// len(mockedWebsiteStatRepo.DailySeriesCalls()) +func (mock *WebsiteStatRepo) DailySeriesCalls() []struct { + Start string + End string + Sites []string +} { + var calls []struct { + Start string + End string + Sites []string + } + mock.lockDailySeries.RLock() + calls = mock.calls.DailySeries + mock.lockDailySeries.RUnlock() + return calls +} + +// DeleteBySite calls DeleteBySiteFunc. +func (mock *WebsiteStatRepo) DeleteBySite(site string) error { + if mock.DeleteBySiteFunc == nil { + panic("WebsiteStatRepo.DeleteBySiteFunc: method is nil but WebsiteStatRepo.DeleteBySite was just called") + } + callInfo := struct { + Site string + }{ + Site: site, + } + mock.lockDeleteBySite.Lock() + mock.calls.DeleteBySite = append(mock.calls.DeleteBySite, callInfo) + mock.lockDeleteBySite.Unlock() + return mock.DeleteBySiteFunc(site) +} + +// DeleteBySiteCalls gets all the calls that were made to DeleteBySite. +// Check the length with: +// +// len(mockedWebsiteStatRepo.DeleteBySiteCalls()) +func (mock *WebsiteStatRepo) DeleteBySiteCalls() []struct { + Site string +} { + var calls []struct { + Site string + } + mock.lockDeleteBySite.RLock() + calls = mock.calls.DeleteBySite + mock.lockDeleteBySite.RUnlock() + return calls +} + +// HourlySeries calls HourlySeriesFunc. +func (mock *WebsiteStatRepo) HourlySeries(date string, sites []string) ([]*biz.WebsiteStatSeries, error) { + if mock.HourlySeriesFunc == nil { + panic("WebsiteStatRepo.HourlySeriesFunc: method is nil but WebsiteStatRepo.HourlySeries was just called") + } + callInfo := struct { + Date string + Sites []string + }{ + Date: date, + Sites: sites, + } + mock.lockHourlySeries.Lock() + mock.calls.HourlySeries = append(mock.calls.HourlySeries, callInfo) + mock.lockHourlySeries.Unlock() + return mock.HourlySeriesFunc(date, sites) +} + +// HourlySeriesCalls gets all the calls that were made to HourlySeries. +// Check the length with: +// +// len(mockedWebsiteStatRepo.HourlySeriesCalls()) +func (mock *WebsiteStatRepo) HourlySeriesCalls() []struct { + Date string + Sites []string +} { + var calls []struct { + Date string + Sites []string + } + mock.lockHourlySeries.RLock() + calls = mock.calls.HourlySeries + mock.lockHourlySeries.RUnlock() + return calls +} + +// InsertErrors calls InsertErrorsFunc. +func (mock *WebsiteStatRepo) InsertErrors(errors []*biz.WebsiteErrorLog) error { + if mock.InsertErrorsFunc == nil { + panic("WebsiteStatRepo.InsertErrorsFunc: method is nil but WebsiteStatRepo.InsertErrors was just called") + } + callInfo := struct { + Errors []*biz.WebsiteErrorLog + }{ + Errors: errors, + } + mock.lockInsertErrors.Lock() + mock.calls.InsertErrors = append(mock.calls.InsertErrors, callInfo) + mock.lockInsertErrors.Unlock() + return mock.InsertErrorsFunc(errors) +} + +// InsertErrorsCalls gets all the calls that were made to InsertErrors. +// Check the length with: +// +// len(mockedWebsiteStatRepo.InsertErrorsCalls()) +func (mock *WebsiteStatRepo) InsertErrorsCalls() []struct { + Errors []*biz.WebsiteErrorLog +} { + var calls []struct { + Errors []*biz.WebsiteErrorLog + } + mock.lockInsertErrors.RLock() + calls = mock.calls.InsertErrors + mock.lockInsertErrors.RUnlock() + return calls +} + +// ListByDateRange calls ListByDateRangeFunc. +func (mock *WebsiteStatRepo) ListByDateRange(start string, end string, sites []string) ([]*biz.WebsiteStat, error) { + if mock.ListByDateRangeFunc == nil { + panic("WebsiteStatRepo.ListByDateRangeFunc: method is nil but WebsiteStatRepo.ListByDateRange was just called") + } + callInfo := struct { + Start string + End string + Sites []string + }{ + Start: start, + End: end, + Sites: sites, + } + mock.lockListByDateRange.Lock() + mock.calls.ListByDateRange = append(mock.calls.ListByDateRange, callInfo) + mock.lockListByDateRange.Unlock() + return mock.ListByDateRangeFunc(start, end, sites) +} + +// ListByDateRangeCalls gets all the calls that were made to ListByDateRange. +// Check the length with: +// +// len(mockedWebsiteStatRepo.ListByDateRangeCalls()) +func (mock *WebsiteStatRepo) ListByDateRangeCalls() []struct { + Start string + End string + Sites []string +} { + var calls []struct { + Start string + End string + Sites []string + } + mock.lockListByDateRange.RLock() + calls = mock.calls.ListByDateRange + mock.lockListByDateRange.RUnlock() + return calls +} + +// ListErrors calls ListErrorsFunc. +func (mock *WebsiteStatRepo) ListErrors(start string, end string, sites []string, status int, page uint, limit uint) ([]*biz.WebsiteErrorLog, uint, error) { + if mock.ListErrorsFunc == nil { + panic("WebsiteStatRepo.ListErrorsFunc: method is nil but WebsiteStatRepo.ListErrors was just called") + } + callInfo := struct { + Start string + End string + Sites []string + Status int + Page uint + Limit uint + }{ + Start: start, + End: end, + Sites: sites, + Status: status, + Page: page, + Limit: limit, + } + mock.lockListErrors.Lock() + mock.calls.ListErrors = append(mock.calls.ListErrors, callInfo) + mock.lockListErrors.Unlock() + return mock.ListErrorsFunc(start, end, sites, status, page, limit) +} + +// ListErrorsCalls gets all the calls that were made to ListErrors. +// Check the length with: +// +// len(mockedWebsiteStatRepo.ListErrorsCalls()) +func (mock *WebsiteStatRepo) ListErrorsCalls() []struct { + Start string + End string + Sites []string + Status int + Page uint + Limit uint +} { + var calls []struct { + Start string + End string + Sites []string + Status int + Page uint + Limit uint + } + mock.lockListErrors.RLock() + calls = mock.calls.ListErrors + mock.lockListErrors.RUnlock() + return calls +} + +// ListSiteStats calls ListSiteStatsFunc. +func (mock *WebsiteStatRepo) ListSiteStats(start string, end string, sites []string) ([]*biz.WebsiteStatSiteItem, error) { + if mock.ListSiteStatsFunc == nil { + panic("WebsiteStatRepo.ListSiteStatsFunc: method is nil but WebsiteStatRepo.ListSiteStats was just called") + } + callInfo := struct { + Start string + End string + Sites []string + }{ + Start: start, + End: end, + Sites: sites, + } + mock.lockListSiteStats.Lock() + mock.calls.ListSiteStats = append(mock.calls.ListSiteStats, callInfo) + mock.lockListSiteStats.Unlock() + return mock.ListSiteStatsFunc(start, end, sites) +} + +// ListSiteStatsCalls gets all the calls that were made to ListSiteStats. +// Check the length with: +// +// len(mockedWebsiteStatRepo.ListSiteStatsCalls()) +func (mock *WebsiteStatRepo) ListSiteStatsCalls() []struct { + Start string + End string + Sites []string +} { + var calls []struct { + Start string + End string + Sites []string + } + mock.lockListSiteStats.RLock() + calls = mock.calls.ListSiteStats + mock.lockListSiteStats.RUnlock() + return calls +} + +// TopClients calls TopClientsFunc. +func (mock *WebsiteStatRepo) TopClients(start string, end string, sites []string, limit uint) ([]*biz.WebsiteStatClientRank, error) { + if mock.TopClientsFunc == nil { + panic("WebsiteStatRepo.TopClientsFunc: method is nil but WebsiteStatRepo.TopClients was just called") + } + callInfo := struct { + Start string + End string + Sites []string + Limit uint + }{ + Start: start, + End: end, + Sites: sites, + Limit: limit, + } + mock.lockTopClients.Lock() + mock.calls.TopClients = append(mock.calls.TopClients, callInfo) + mock.lockTopClients.Unlock() + return mock.TopClientsFunc(start, end, sites, limit) +} + +// TopClientsCalls gets all the calls that were made to TopClients. +// Check the length with: +// +// len(mockedWebsiteStatRepo.TopClientsCalls()) +func (mock *WebsiteStatRepo) TopClientsCalls() []struct { + Start string + End string + Sites []string + Limit uint +} { + var calls []struct { + Start string + End string + Sites []string + Limit uint + } + mock.lockTopClients.RLock() + calls = mock.calls.TopClients + mock.lockTopClients.RUnlock() + return calls +} + +// TopGeos calls TopGeosFunc. +func (mock *WebsiteStatRepo) TopGeos(start string, end string, sites []string, groupBy string, country string, limit uint) ([]*biz.WebsiteStatGeoRank, error) { + if mock.TopGeosFunc == nil { + panic("WebsiteStatRepo.TopGeosFunc: method is nil but WebsiteStatRepo.TopGeos was just called") + } + callInfo := struct { + Start string + End string + Sites []string + GroupBy string + Country string + Limit uint + }{ + Start: start, + End: end, + Sites: sites, + GroupBy: groupBy, + Country: country, + Limit: limit, + } + mock.lockTopGeos.Lock() + mock.calls.TopGeos = append(mock.calls.TopGeos, callInfo) + mock.lockTopGeos.Unlock() + return mock.TopGeosFunc(start, end, sites, groupBy, country, limit) +} + +// TopGeosCalls gets all the calls that were made to TopGeos. +// Check the length with: +// +// len(mockedWebsiteStatRepo.TopGeosCalls()) +func (mock *WebsiteStatRepo) TopGeosCalls() []struct { + Start string + End string + Sites []string + GroupBy string + Country string + Limit uint +} { + var calls []struct { + Start string + End string + Sites []string + GroupBy string + Country string + Limit uint + } + mock.lockTopGeos.RLock() + calls = mock.calls.TopGeos + mock.lockTopGeos.RUnlock() + return calls +} + +// TopIPs calls TopIPsFunc. +func (mock *WebsiteStatRepo) TopIPs(start string, end string, sites []string, page uint, limit uint) ([]*biz.WebsiteStatIPRank, uint, error) { + if mock.TopIPsFunc == nil { + panic("WebsiteStatRepo.TopIPsFunc: method is nil but WebsiteStatRepo.TopIPs was just called") + } + callInfo := struct { + Start string + End string + Sites []string + Page uint + Limit uint + }{ + Start: start, + End: end, + Sites: sites, + Page: page, + Limit: limit, + } + mock.lockTopIPs.Lock() + mock.calls.TopIPs = append(mock.calls.TopIPs, callInfo) + mock.lockTopIPs.Unlock() + return mock.TopIPsFunc(start, end, sites, page, limit) +} + +// TopIPsCalls gets all the calls that were made to TopIPs. +// Check the length with: +// +// len(mockedWebsiteStatRepo.TopIPsCalls()) +func (mock *WebsiteStatRepo) TopIPsCalls() []struct { + Start string + End string + Sites []string + Page uint + Limit uint +} { + var calls []struct { + Start string + End string + Sites []string + Page uint + Limit uint + } + mock.lockTopIPs.RLock() + calls = mock.calls.TopIPs + mock.lockTopIPs.RUnlock() + return calls +} + +// TopSlowURIs calls TopSlowURIsFunc. +func (mock *WebsiteStatRepo) TopSlowURIs(start string, end string, sites []string, threshold uint, page uint, limit uint) ([]*biz.WebsiteStatURIRank, uint, error) { + if mock.TopSlowURIsFunc == nil { + panic("WebsiteStatRepo.TopSlowURIsFunc: method is nil but WebsiteStatRepo.TopSlowURIs was just called") + } + callInfo := struct { + Start string + End string + Sites []string + Threshold uint + Page uint + Limit uint + }{ + Start: start, + End: end, + Sites: sites, + Threshold: threshold, + Page: page, + Limit: limit, + } + mock.lockTopSlowURIs.Lock() + mock.calls.TopSlowURIs = append(mock.calls.TopSlowURIs, callInfo) + mock.lockTopSlowURIs.Unlock() + return mock.TopSlowURIsFunc(start, end, sites, threshold, page, limit) +} + +// TopSlowURIsCalls gets all the calls that were made to TopSlowURIs. +// Check the length with: +// +// len(mockedWebsiteStatRepo.TopSlowURIsCalls()) +func (mock *WebsiteStatRepo) TopSlowURIsCalls() []struct { + Start string + End string + Sites []string + Threshold uint + Page uint + Limit uint +} { + var calls []struct { + Start string + End string + Sites []string + Threshold uint + Page uint + Limit uint + } + mock.lockTopSlowURIs.RLock() + calls = mock.calls.TopSlowURIs + mock.lockTopSlowURIs.RUnlock() + return calls +} + +// TopSpiders calls TopSpidersFunc. +func (mock *WebsiteStatRepo) TopSpiders(start string, end string, sites []string, limit uint) ([]*biz.WebsiteStatSpiderRank, error) { + if mock.TopSpidersFunc == nil { + panic("WebsiteStatRepo.TopSpidersFunc: method is nil but WebsiteStatRepo.TopSpiders was just called") + } + callInfo := struct { + Start string + End string + Sites []string + Limit uint + }{ + Start: start, + End: end, + Sites: sites, + Limit: limit, + } + mock.lockTopSpiders.Lock() + mock.calls.TopSpiders = append(mock.calls.TopSpiders, callInfo) + mock.lockTopSpiders.Unlock() + return mock.TopSpidersFunc(start, end, sites, limit) +} + +// TopSpidersCalls gets all the calls that were made to TopSpiders. +// Check the length with: +// +// len(mockedWebsiteStatRepo.TopSpidersCalls()) +func (mock *WebsiteStatRepo) TopSpidersCalls() []struct { + Start string + End string + Sites []string + Limit uint +} { + var calls []struct { + Start string + End string + Sites []string + Limit uint + } + mock.lockTopSpiders.RLock() + calls = mock.calls.TopSpiders + mock.lockTopSpiders.RUnlock() + return calls +} + +// TopURIs calls TopURIsFunc. +func (mock *WebsiteStatRepo) TopURIs(start string, end string, sites []string, page uint, limit uint) ([]*biz.WebsiteStatURIRank, uint, error) { + if mock.TopURIsFunc == nil { + panic("WebsiteStatRepo.TopURIsFunc: method is nil but WebsiteStatRepo.TopURIs was just called") + } + callInfo := struct { + Start string + End string + Sites []string + Page uint + Limit uint + }{ + Start: start, + End: end, + Sites: sites, + Page: page, + Limit: limit, + } + mock.lockTopURIs.Lock() + mock.calls.TopURIs = append(mock.calls.TopURIs, callInfo) + mock.lockTopURIs.Unlock() + return mock.TopURIsFunc(start, end, sites, page, limit) +} + +// TopURIsCalls gets all the calls that were made to TopURIs. +// Check the length with: +// +// len(mockedWebsiteStatRepo.TopURIsCalls()) +func (mock *WebsiteStatRepo) TopURIsCalls() []struct { + Start string + End string + Sites []string + Page uint + Limit uint +} { + var calls []struct { + Start string + End string + Sites []string + Page uint + Limit uint + } + mock.lockTopURIs.RLock() + calls = mock.calls.TopURIs + mock.lockTopURIs.RUnlock() + return calls +} + +// Upsert calls UpsertFunc. +func (mock *WebsiteStatRepo) Upsert(stats []*biz.WebsiteStat) error { + if mock.UpsertFunc == nil { + panic("WebsiteStatRepo.UpsertFunc: method is nil but WebsiteStatRepo.Upsert was just called") + } + callInfo := struct { + Stats []*biz.WebsiteStat + }{ + Stats: stats, + } + mock.lockUpsert.Lock() + mock.calls.Upsert = append(mock.calls.Upsert, callInfo) + mock.lockUpsert.Unlock() + return mock.UpsertFunc(stats) +} + +// UpsertCalls gets all the calls that were made to Upsert. +// Check the length with: +// +// len(mockedWebsiteStatRepo.UpsertCalls()) +func (mock *WebsiteStatRepo) UpsertCalls() []struct { + Stats []*biz.WebsiteStat +} { + var calls []struct { + Stats []*biz.WebsiteStat + } + mock.lockUpsert.RLock() + calls = mock.calls.Upsert + mock.lockUpsert.RUnlock() + return calls +} + +// UpsertClients calls UpsertClientsFunc. +func (mock *WebsiteStatRepo) UpsertClients(stats []*biz.WebsiteStatClient) error { + if mock.UpsertClientsFunc == nil { + panic("WebsiteStatRepo.UpsertClientsFunc: method is nil but WebsiteStatRepo.UpsertClients was just called") + } + callInfo := struct { + Stats []*biz.WebsiteStatClient + }{ + Stats: stats, + } + mock.lockUpsertClients.Lock() + mock.calls.UpsertClients = append(mock.calls.UpsertClients, callInfo) + mock.lockUpsertClients.Unlock() + return mock.UpsertClientsFunc(stats) +} + +// UpsertClientsCalls gets all the calls that were made to UpsertClients. +// Check the length with: +// +// len(mockedWebsiteStatRepo.UpsertClientsCalls()) +func (mock *WebsiteStatRepo) UpsertClientsCalls() []struct { + Stats []*biz.WebsiteStatClient +} { + var calls []struct { + Stats []*biz.WebsiteStatClient + } + mock.lockUpsertClients.RLock() + calls = mock.calls.UpsertClients + mock.lockUpsertClients.RUnlock() + return calls +} + +// UpsertIPs calls UpsertIPsFunc. +func (mock *WebsiteStatRepo) UpsertIPs(stats []*biz.WebsiteStatIP) error { + if mock.UpsertIPsFunc == nil { + panic("WebsiteStatRepo.UpsertIPsFunc: method is nil but WebsiteStatRepo.UpsertIPs was just called") + } + callInfo := struct { + Stats []*biz.WebsiteStatIP + }{ + Stats: stats, + } + mock.lockUpsertIPs.Lock() + mock.calls.UpsertIPs = append(mock.calls.UpsertIPs, callInfo) + mock.lockUpsertIPs.Unlock() + return mock.UpsertIPsFunc(stats) +} + +// UpsertIPsCalls gets all the calls that were made to UpsertIPs. +// Check the length with: +// +// len(mockedWebsiteStatRepo.UpsertIPsCalls()) +func (mock *WebsiteStatRepo) UpsertIPsCalls() []struct { + Stats []*biz.WebsiteStatIP +} { + var calls []struct { + Stats []*biz.WebsiteStatIP + } + mock.lockUpsertIPs.RLock() + calls = mock.calls.UpsertIPs + mock.lockUpsertIPs.RUnlock() + return calls +} + +// UpsertSpiders calls UpsertSpidersFunc. +func (mock *WebsiteStatRepo) UpsertSpiders(stats []*biz.WebsiteStatSpider) error { + if mock.UpsertSpidersFunc == nil { + panic("WebsiteStatRepo.UpsertSpidersFunc: method is nil but WebsiteStatRepo.UpsertSpiders was just called") + } + callInfo := struct { + Stats []*biz.WebsiteStatSpider + }{ + Stats: stats, + } + mock.lockUpsertSpiders.Lock() + mock.calls.UpsertSpiders = append(mock.calls.UpsertSpiders, callInfo) + mock.lockUpsertSpiders.Unlock() + return mock.UpsertSpidersFunc(stats) +} + +// UpsertSpidersCalls gets all the calls that were made to UpsertSpiders. +// Check the length with: +// +// len(mockedWebsiteStatRepo.UpsertSpidersCalls()) +func (mock *WebsiteStatRepo) UpsertSpidersCalls() []struct { + Stats []*biz.WebsiteStatSpider +} { + var calls []struct { + Stats []*biz.WebsiteStatSpider + } + mock.lockUpsertSpiders.RLock() + calls = mock.calls.UpsertSpiders + mock.lockUpsertSpiders.RUnlock() + return calls +} + +// UpsertURIs calls UpsertURIsFunc. +func (mock *WebsiteStatRepo) UpsertURIs(stats []*biz.WebsiteStatURI) error { + if mock.UpsertURIsFunc == nil { + panic("WebsiteStatRepo.UpsertURIsFunc: method is nil but WebsiteStatRepo.UpsertURIs was just called") + } + callInfo := struct { + Stats []*biz.WebsiteStatURI + }{ + Stats: stats, + } + mock.lockUpsertURIs.Lock() + mock.calls.UpsertURIs = append(mock.calls.UpsertURIs, callInfo) + mock.lockUpsertURIs.Unlock() + return mock.UpsertURIsFunc(stats) +} + +// UpsertURIsCalls gets all the calls that were made to UpsertURIs. +// Check the length with: +// +// len(mockedWebsiteStatRepo.UpsertURIsCalls()) +func (mock *WebsiteStatRepo) UpsertURIsCalls() []struct { + Stats []*biz.WebsiteStatURI +} { + var calls []struct { + Stats []*biz.WebsiteStatURI + } + mock.lockUpsertURIs.RLock() + calls = mock.calls.UpsertURIs + mock.lockUpsertURIs.RUnlock() + return calls +} + +// VacuumDB calls VacuumDBFunc. +func (mock *WebsiteStatRepo) VacuumDB() error { + if mock.VacuumDBFunc == nil { + panic("WebsiteStatRepo.VacuumDBFunc: method is nil but WebsiteStatRepo.VacuumDB was just called") + } + callInfo := struct { + }{} + mock.lockVacuumDB.Lock() + mock.calls.VacuumDB = append(mock.calls.VacuumDB, callInfo) + mock.lockVacuumDB.Unlock() + return mock.VacuumDBFunc() +} + +// VacuumDBCalls gets all the calls that were made to VacuumDB. +// Check the length with: +// +// len(mockedWebsiteStatRepo.VacuumDBCalls()) +func (mock *WebsiteStatRepo) VacuumDBCalls() []struct { +} { + var calls []struct { + } + mock.lockVacuumDB.RLock() + calls = mock.calls.VacuumDB + mock.lockVacuumDB.RUnlock() + return calls +} diff --git a/internal/route/route.go b/internal/route/route.go index 6b2263a13..71d68d0eb 100644 --- a/internal/route/route.go +++ b/internal/route/route.go @@ -6,7 +6,6 @@ import ( "time" "github.com/go-chi/chi/v5" - "github.com/google/wire" "github.com/libtnb/validator" "github.com/libtnb/validator/contrib/openapi" @@ -15,8 +14,6 @@ import ( "github.com/acepanel/panel/v3/pkg/config" ) -var ProviderSet = wire.NewSet(wire.Struct(new(Services), "*"), NewEndpoints) - // Services 汇总所有路由所需的服务,Wire 会在生成期校验依赖完整性。 type Services struct { Alert *service.AlertService diff --git a/internal/route/wire.go b/internal/route/wire.go new file mode 100644 index 000000000..22a84523c --- /dev/null +++ b/internal/route/wire.go @@ -0,0 +1,11 @@ +//go:build wireinject + +package route + +import "github.com/libtnb/wire" + +// Module 装配路由层 +var Module = wire.New(). + Struct[Services](). + Provide(NewEndpoints). + Export[[]Endpoints]() diff --git a/internal/service/cert.go b/internal/service/cert.go index e6efbfc72..748855680 100644 --- a/internal/service/cert.go +++ b/internal/service/cert.go @@ -51,7 +51,6 @@ func (s *CertService) CAProviders(w http.ResponseWriter, r *http.Request) { Value: "google", }, }) - } func (s *CertService) DNSProviders(w http.ResponseWriter, r *http.Request) { @@ -114,7 +113,6 @@ func (s *CertService) Algorithms(w http.ResponseWriter, r *http.Request) { Value: string(acme.KeyRSA4096), }, }) - } func (s *CertService) List(w http.ResponseWriter, r *http.Request) { @@ -222,7 +220,7 @@ func (s *CertService) ObtainAuto(w http.ResponseWriter, r *http.Request) { return } - if _, err = s.certRepo.ObtainAuto(req.ID); err != nil { + if _, err = s.certRepo.ObtainAutoWithProgressCallback(r.Context(), req.ID, nil); err != nil { Error(w, http.StatusInternalServerError, "%v", err) return } @@ -252,7 +250,7 @@ func (s *CertService) Renew(w http.ResponseWriter, r *http.Request) { return } - _, err = s.certRepo.Renew(req.ID) + _, err = s.certRepo.RenewWithProgressCallback(r.Context(), req.ID, nil) if err != nil { Error(w, http.StatusInternalServerError, "%v", err) return diff --git a/internal/service/cli.go b/internal/service/cli.go index 60518f38b..a992f0cd9 100644 --- a/internal/service/cli.go +++ b/internal/service/cli.go @@ -243,10 +243,12 @@ func (s *CliService) Info(ctx context.Context, cmd *cli.Command) error { fmt.Println(s.t.Get("Port: %d", port)) fmt.Println(s.t.Get("Entrance: %s", entrance)) + //nolint:contextcheck lv4, err := tools.GetLocalIPv4() if err == nil { fmt.Println(s.t.Get("Local IPv4: %s://%s:%d%s", protocol, lv4, port, entrance)) } + //nolint:contextcheck lv6, err := tools.GetLocalIPv6() if err == nil { fmt.Println(s.t.Get("Local IPv6: %s://[%s]:%d%s", protocol, lv6, port, entrance)) @@ -491,6 +493,7 @@ func (s *CliService) HTTPSOff(ctx context.Context, cmd *cli.Command) error { } func (s *CliService) HTTPSGenerate(ctx context.Context, cmd *cli.Command) error { + //nolint:contextcheck names := tools.CollectLocalNames() var crt, key []byte @@ -515,7 +518,7 @@ func (s *CliService) HTTPSGenerate(ctx context.Context, cmd *cli.Command) error if err = s.db.First(&user).Error; err != nil { return errors.New(s.t.Get("Failed to get a panel user: %v", err)) } - account, err := s.certAccountRepo.GetDefault(user.ID) + account, err := s.certAccountRepo.GetDefault(ctx, user.ID) if err != nil { return errors.New(s.t.Get("Failed to get ACME account: %v", err)) } @@ -711,6 +714,7 @@ func (s *CliService) Port(ctx context.Context, cmd *cli.Command) error { } if port != conf.HTTP.Port { + //nolint:contextcheck if os.TCPPortInUse(port) { return errors.New(s.t.Get("Port already in use")) } @@ -1614,7 +1618,9 @@ func (s *CliService) Init(ctx context.Context, cmd *cli.Command) error { // 随机默认端口 checkPort: - port := uint(rand.IntN(50000) + 10000) // 10000-60000 + // 10000-60000 + port := uint(rand.IntN(50000) + 10000) //nolint:gosec + //nolint:contextcheck if os.TCPPortInUse(port) { goto checkPort } diff --git a/internal/service/container_volume.go b/internal/service/container_volume.go index 070f722b0..269f52f57 100644 --- a/internal/service/container_volume.go +++ b/internal/service/container_volume.go @@ -48,7 +48,6 @@ func (s *ContainerVolumeService) Create(w http.ResponseWriter, r *http.Request) } Success(w, name) - } func (s *ContainerVolumeService) Remove(w http.ResponseWriter, r *http.Request) { diff --git a/internal/service/file.go b/internal/service/file.go index e76e9d2dd..93edf6a18 100644 --- a/internal/service/file.go +++ b/internal/service/file.go @@ -573,7 +573,7 @@ func (s *FileService) Permission(w http.ResponseWriter, r *http.Request) { } // 解析成8进制 - mode, err := strconv.ParseUint(req.Mode, 8, 64) + mode, err := strconv.ParseUint(req.Mode, 8, 32) if err != nil { Error(w, http.StatusInternalServerError, "%v", err) return @@ -758,10 +758,11 @@ func (s *FileService) ChunkUploadStart(w http.ResponseWriter, r *http.Request) { // 分块数或分块大小对不上(换了分块参数或不是同一次上传),从头开始 part, mapPath := s.chunkTempPaths(req.Path, req.FileName, req.FileHash) bitmap, _ := stdos.ReadFile(mapPath) + //nolint:gosec if len(bitmap) != chunkMapHeader+req.ChunkCount || binary.LittleEndian.Uint64(bitmap) != uint64(req.ChunkSize) { bitmap = make([]byte, chunkMapHeader+req.ChunkCount) - binary.LittleEndian.PutUint64(bitmap, uint64(req.ChunkSize)) + binary.LittleEndian.PutUint64(bitmap, uint64(req.ChunkSize)) //nolint:gosec if err = stdos.WriteFile(mapPath, bitmap, 0644); err != nil { Error(w, http.StatusInternalServerError, s.t.Get("save chunk error: %v", err)) return @@ -797,7 +798,7 @@ func (s *FileService) ChunkUploadChunk(w http.ResponseWriter, r *http.Request) { return } chunkCount := len(bitmap) - chunkMapHeader - chunkSize := int64(binary.LittleEndian.Uint64(bitmap)) + chunkSize := int64(binary.LittleEndian.Uint64(bitmap)) //nolint:gosec if req.ChunkIndex >= chunkCount { Error(w, http.StatusBadRequest, s.t.Get("chunk index out of range")) return @@ -918,7 +919,11 @@ func (s *FileService) formatDir(base string, entries []stdos.DirEntry) []any { base = filepath.Dir(de.Path()) } - stat := info.Sys().(*syscall.Stat_t) + // Linux 下 Sys() 必定是 *syscall.Stat_t + stat, ok := info.Sys().(*syscall.Stat_t) + if !ok { + stat = &syscall.Stat_t{} + } // 对于目录,size 返回空字符串,需要用户手动计算 size := "" if !info.IsDir() { diff --git a/internal/service/firewall.go b/internal/service/firewall.go index 3fa3ed248..428616bee 100644 --- a/internal/service/firewall.go +++ b/internal/service/firewall.go @@ -75,6 +75,7 @@ func (s *FirewallService) GetRules(w http.ResponseWriter, r *http.Request) { } var filledRules []map[string]any + //nolint:contextcheck for rule := range slices.Values(rules) { // 去除IP规则 if rule.PortStart == 1 && rule.PortEnd == 65535 { @@ -230,6 +231,7 @@ func (s *FirewallService) ExportRules(w http.ResponseWriter, r *http.Request) { // ImportRules 从 xlsx 导入端口规则 func (s *FirewallService) ImportRules(w http.ResponseWriter, r *http.Request) { + //nolint:gosec if err := r.ParseMultipartForm(10 << 20); err != nil { Error(w, http.StatusUnprocessableEntity, "%v", err) return diff --git a/internal/service/service.go b/internal/service/service.go deleted file mode 100644 index 1e60f12bc..000000000 --- a/internal/service/service.go +++ /dev/null @@ -1,24 +0,0 @@ -package service - -import "github.com/google/wire" - -var ProviderSet = wire.NewSet( - NewAlertService, NewAppService, NewBackupService, NewBackupStorageService, - NewCertService, NewCertAccountService, NewCertDNSService, - NewCliService, NewContainerService, NewContainerComposeService, - NewContainerImageService, NewContainerNetworkService, NewContainerVolumeService, - NewCronService, NewDatabaseService, NewDatabaseRedisService, - NewDatabaseElasticsearchService, NewDatabaseServerService, NewDatabaseUserService, - NewEnvironmentService, NewEnvironmentGoService, NewEnvironmentJavaService, - NewEnvironmentNodejsService, NewEnvironmentPHPService, NewEnvironmentPythonService, - NewEnvironmentDotnetService, NewFileService, NewFileShareService, NewFirewallService, - NewFirewallScanService, NewHomeService, NewLogService, - NewMonitorService, NewNotifyService, NewProcessService, NewProjectService, - NewSafeService, NewSettingService, NewSSHService, - NewSystemctlService, NewTamperService, NewTaskService, NewTemplateService, - NewUserService, NewUserPasskeyService, NewUserTokenService, - NewWebHookService, NewWebsiteService, NewWebsiteStatService, - NewToolboxNetworkService, NewToolboxSystemService, NewToolboxBenchmarkService, - NewToolboxSSHService, NewToolboxDiskService, NewToolboxLogService, - NewToolboxMigrationService, NewWsService, -) diff --git a/internal/service/setting.go b/internal/service/setting.go index a5a3a1d91..234dea72d 100644 --- a/internal/service/setting.go +++ b/internal/service/setting.go @@ -72,6 +72,7 @@ func (s *SettingService) ObtainCert(w http.ResponseWriter, r *http.Request) { return } if conf.HTTP.TLS == "self-signed" { + //nolint:contextcheck crt, key, err := cert.GenerateSelfSigned(tools.CollectLocalNames()) if err != nil { Error(w, http.StatusInternalServerError, "%v", err) @@ -95,7 +96,7 @@ func (s *SettingService) ObtainCert(w http.ResponseWriter, r *http.Request) { return } - account, err := s.certAccountRepo.GetDefault(user.ID) + account, err := s.certAccountRepo.GetDefault(r.Context(), user.ID) if err != nil { Error(w, http.StatusInternalServerError, "%v", err) return diff --git a/internal/service/tamper.go b/internal/service/tamper.go index 589d890c9..6806fbed1 100644 --- a/internal/service/tamper.go +++ b/internal/service/tamper.go @@ -1,7 +1,9 @@ package service import ( + "context" "net/http" + "time" "github.com/go-chi/chi/v5" "github.com/leonelquinteros/gotext" @@ -203,7 +205,9 @@ func (s *TamperService) ClearLogs(w http.ResponseWriter, r *http.Request) { // ActivateEBPF 修改 grub 激活 bpf LSM 并重启系统 func (s *TamperService) ActivateEBPF(w http.ResponseWriter, r *http.Request) { - if err := s.tamperRepo.EnableBPFLSMGrub(); err != nil { + ctx, cancel := context.WithTimeout(context.WithoutCancel(r.Context()), 5*time.Minute) + defer cancel() + if err := s.tamperRepo.EnableBPFLSMGrub(ctx); err != nil { Error(w, http.StatusInternalServerError, "%v", err) return } diff --git a/internal/service/toolbox_benchmark.go b/internal/service/toolbox_benchmark.go index 7ae2b4bca..9a826a027 100644 --- a/internal/service/toolbox_benchmark.go +++ b/internal/service/toolbox_benchmark.go @@ -93,14 +93,12 @@ func (s *ToolboxBenchmarkService) calculateScore(duration time.Duration) int { func (s *ToolboxBenchmarkService) imageProcessing() int { start := time.Now() - if err := s.imageProcessingTask(); err != nil { - return 0 - } + s.imageProcessingTask() duration := time.Since(start) return s.calculateCpuScore(duration) } -func (s *ToolboxBenchmarkService) imageProcessingTask() error { +func (s *ToolboxBenchmarkService) imageProcessingTask() { img := image.NewRGBA(image.Rect(0, 0, 4000, 4000)) for x := range 4000 { for y := range 4000 { @@ -129,8 +127,6 @@ func (s *ToolboxBenchmarkService) imageProcessingTask() error { img.Set(x, y, color.RGBA{R: rAvg, G: gAvg, B: bAvg, A: 255}) } } - - return nil } // 机器学习(矩阵乘法) @@ -149,6 +145,7 @@ func (s *ToolboxBenchmarkService) machineLearningTask() { for i := range size { a[i] = make([]float64, size) b[i] = make([]float64, size) + //nolint:gosec for j := range size { a[i][j] = rand.Float64() b[i][j] = rand.Float64() @@ -258,7 +255,7 @@ func (s *ToolboxBenchmarkService) compressionTestTask() { if err != nil { return } - _, err = io.Copy(io.Discard, r) + _, err = io.Copy(io.Discard, r) //nolint:gosec if err != nil { return } @@ -285,6 +282,7 @@ func (s *ToolboxBenchmarkService) physicsSimulationTask() { } bodies := make([]Body, numBodies) + //nolint:gosec for i := range numBodies { bodies[i] = Body{ x: rand.Float64(), @@ -397,7 +395,7 @@ func (s *ToolboxBenchmarkService) memoryBandwidthTest(data []byte) string { func (s *ToolboxBenchmarkService) memoryLatencyTest(data []byte) string { dataSize := len(data) - indices := rand.Perm(dataSize) + indices := rand.Perm(dataSize) //nolint:gosec startTime := time.Now() sum := byte(0) diff --git a/internal/service/toolbox_log.go b/internal/service/toolbox_log.go index 218d8366c..46e8ad441 100644 --- a/internal/service/toolbox_log.go +++ b/internal/service/toolbox_log.go @@ -90,11 +90,11 @@ func (s *ToolboxLogService) Clean(w http.ResponseWriter, r *http.Request) { case "website": cleaned, cleanErr = s.cleanWebsiteLogs() case "mysql": - cleaned, cleanErr = s.cleanMySQLLogs() + cleaned = s.cleanMySQLLogs() case "docker": - cleaned, cleanErr = s.cleanDockerLogs() + cleaned = s.cleanDockerLogs() case "system": - cleaned, cleanErr = s.cleanSystemLogs() + cleaned = s.cleanSystemLogs() default: Error(w, http.StatusUnprocessableEntity, s.t.Get("unknown log type")) return @@ -479,12 +479,12 @@ func (s *ToolboxLogService) cleanWebsiteLogs() (int64, error) { } // cleanMySQLLogs 清理 MySQL 日志 -func (s *ToolboxLogService) cleanMySQLLogs() (int64, error) { +func (s *ToolboxLogService) cleanMySQLLogs() int64 { var cleaned int64 mysqlPath := filepath.Join(app.Root, "server/mysql") if !io.Exists(mysqlPath) { - return 0, nil + return 0 } // 清空慢查询日志 @@ -499,7 +499,7 @@ func (s *ToolboxLogService) cleanMySQLLogs() (int64, error) { // 清理二进制日志 entries, err := os.ReadDir(mysqlPath) if err != nil { - return cleaned, nil + return cleaned } binLogRegex := regexp.MustCompile(`^mysql-bin\.\d+$`) @@ -523,11 +523,11 @@ func (s *ToolboxLogService) cleanMySQLLogs() (int64, error) { _, _ = shell.ExecfWithEnv([]string{"MYSQL_PWD=" + rootPassword}, "mysql -u root -e 'PURGE BINARY LOGS BEFORE NOW()' 2>/dev/null") } - return cleaned, nil + return cleaned } // cleanDockerLogs 清理 Docker/Podman 相关内容 -func (s *ToolboxLogService) cleanDockerLogs() (int64, error) { +func (s *ToolboxLogService) cleanDockerLogs() int64 { var cleaned int64 // 清理未使用的镜像 (Docker) @@ -552,7 +552,7 @@ func (s *ToolboxLogService) cleanDockerLogs() (int64, error) { // 清理 Podman 系统 _, _ = shell.Execf("podman system prune -f 2>/dev/null") - return cleaned, nil + return cleaned } // cleanContainerLogDir 清理容器日志目录 @@ -600,7 +600,7 @@ func (s *ToolboxLogService) cleanContainerLogDir(logPath string) int64 { } // cleanSystemLogs 清理系统日志 -func (s *ToolboxLogService) cleanSystemLogs() (int64, error) { +func (s *ToolboxLogService) cleanSystemLogs() int64 { var cleaned int64 // 清理 journal 日志 (保留最近 1 天) @@ -644,5 +644,5 @@ func (s *ToolboxLogService) cleanSystemLogs() (int64, error) { _, _ = shell.Execf("cat /dev/null > '%s'", match) } - return cleaned, nil + return cleaned } diff --git a/internal/service/toolbox_migration.go b/internal/service/toolbox_migration.go index 00cc98a84..fe70e62db 100644 --- a/internal/service/toolbox_migration.go +++ b/internal/service/toolbox_migration.go @@ -78,6 +78,7 @@ func (s *ToolboxMigrationService) Start(w http.ResponseWriter, r *http.Request) return } + //nolint:contextcheck if err = s.migrationRepo.Start(req); err != nil { Error(w, http.StatusConflict, "%v", err) return @@ -147,10 +148,14 @@ func (s *ToolboxMigrationService) Progress(w http.ResponseWriter, r *http.Reques case <-ticker.C: step, results, logs, startedAt, endedAt := s.migrationRepo.Status(sent) sent += len(logs) - data, _ := json.Marshal(chix.M{ + data, err := json.Marshal(chix.M{ "step": step, "results": results, "new_logs": logs, "started_at": startedAt, "ended_at": endedAt, }) + if err != nil { + s.log.Warn("marshal migration progress error", slog.Any("err", err)) + return + } if err = ws.Write(ctx, websocket.MessageText, data); err != nil { return } diff --git a/internal/service/toolbox_system.go b/internal/service/toolbox_system.go index 3ba1cf5a2..60c27ab56 100644 --- a/internal/service/toolbox_system.go +++ b/internal/service/toolbox_system.go @@ -124,6 +124,7 @@ func (s *ToolboxSystemService) UpdateSWAP(w http.ResponseWriter, r *http.Request Error(w, http.StatusInternalServerError, "%v", err) return } + //nolint:dupword if _, err = shell.Execf("echo '%s swap swap defaults 0 0' >> /etc/fstab", filepath.Join(app.Root, "swap")); err != nil { Error(w, http.StatusInternalServerError, "%v", err) return @@ -191,7 +192,6 @@ func (s *ToolboxSystemService) UpdateTime(w http.ResponseWriter, r *http.Request } Success(w, nil) - } // SyncTime 同步时间 diff --git a/internal/service/user_passkey.go b/internal/service/user_passkey.go index 32b32dd03..ef69b435b 100644 --- a/internal/service/user_passkey.go +++ b/internal/service/user_passkey.go @@ -282,7 +282,11 @@ func (s *UserPasskeyService) FinishLogin(w http.ResponseWriter, r *http.Request) _ = s.userPasskeyRepo.UpdateSignCount(credential.ID, credential.Authenticator.SignCount) _ = s.userPasskeyRepo.UpdateLastUsed(credential.ID) - wUser := returnedUser.(*passkey.User) + wUser, ok := returnedUser.(*passkey.User) + if !ok { + ErrorSystem(w) + return + } // 重新生成会话 ID if err = sess.Regenerate(true); err != nil { diff --git a/internal/service/wire.go b/internal/service/wire.go new file mode 100644 index 000000000..e57322708 --- /dev/null +++ b/internal/service/wire.go @@ -0,0 +1,122 @@ +//go:build wireinject + +package service + +import "github.com/libtnb/wire" + +// Module 装配服务层 +var Module = wire.New(). + Provide(NewAlertService). + Provide(NewAppService). + Provide(NewBackupService). + Provide(NewBackupStorageService). + Provide(NewCertService). + Provide(NewCertAccountService). + Provide(NewCertDNSService). + Provide(NewCliService). + Provide(NewContainerService). + Provide(NewContainerComposeService). + Provide(NewContainerImageService). + Provide(NewContainerNetworkService). + Provide(NewContainerVolumeService). + Provide(NewCronService). + Provide(NewDatabaseService). + Provide(NewDatabaseRedisService). + Provide(NewDatabaseElasticsearchService). + Provide(NewDatabaseServerService). + Provide(NewDatabaseUserService). + Provide(NewEnvironmentService). + Provide(NewEnvironmentGoService). + Provide(NewEnvironmentJavaService). + Provide(NewEnvironmentNodejsService). + Provide(NewEnvironmentPHPService). + Provide(NewEnvironmentPythonService). + Provide(NewEnvironmentDotnetService). + Provide(NewFileService). + Provide(NewFileShareService). + Provide(NewFirewallService). + Provide(NewFirewallScanService). + Provide(NewHomeService). + Provide(NewLogService). + Provide(NewMonitorService). + Provide(NewNotifyService). + Provide(NewProcessService). + Provide(NewProjectService). + Provide(NewSafeService). + Provide(NewSettingService). + Provide(NewSSHService). + Provide(NewSystemctlService). + Provide(NewTamperService). + Provide(NewTaskService). + Provide(NewTemplateService). + Provide(NewUserService). + Provide(NewUserPasskeyService). + Provide(NewUserTokenService). + Provide(NewWebHookService). + Provide(NewWebsiteService). + Provide(NewWebsiteStatService). + Provide(NewToolboxNetworkService). + Provide(NewToolboxSystemService). + Provide(NewToolboxBenchmarkService). + Provide(NewToolboxSSHService). + Provide(NewToolboxDiskService). + Provide(NewToolboxLogService). + Provide(NewToolboxMigrationService). + Provide(NewWsService). + Export[*AlertService](). + Export[*AppService](). + Export[*BackupService](). + Export[*BackupStorageService](). + Export[*CertService](). + Export[*CertAccountService](). + Export[*CertDNSService](). + Export[*CliService](). + Export[*ContainerService](). + Export[*ContainerComposeService](). + Export[*ContainerImageService](). + Export[*ContainerNetworkService](). + Export[*ContainerVolumeService](). + Export[*CronService](). + Export[*DatabaseService](). + Export[*DatabaseRedisService](). + Export[*DatabaseElasticsearchService](). + Export[*DatabaseServerService](). + Export[*DatabaseUserService](). + Export[*EnvironmentService](). + Export[*EnvironmentGoService](). + Export[*EnvironmentJavaService](). + Export[*EnvironmentNodejsService](). + Export[*EnvironmentPHPService](). + Export[*EnvironmentPythonService](). + Export[*EnvironmentDotnetService](). + Export[*FileService](). + Export[*FileShareService](). + Export[*FirewallService](). + Export[*FirewallScanService](). + Export[*HomeService](). + Export[*LogService](). + Export[*MonitorService](). + Export[*NotifyService](). + Export[*ProcessService](). + Export[*ProjectService](). + Export[*SafeService](). + Export[*SettingService](). + Export[*SSHService](). + Export[*SystemctlService](). + Export[*TamperService](). + Export[*TaskService](). + Export[*TemplateService](). + Export[*UserService](). + Export[*UserPasskeyService](). + Export[*UserTokenService](). + Export[*WebHookService](). + Export[*WebsiteService](). + Export[*WebsiteStatService](). + Export[*ToolboxNetworkService](). + Export[*ToolboxSystemService](). + Export[*ToolboxBenchmarkService](). + Export[*ToolboxSSHService](). + Export[*ToolboxDiskService](). + Export[*ToolboxLogService](). + Export[*ToolboxMigrationService](). + Export[*WsService]() diff --git a/internal/service/ws.go b/internal/service/ws.go index 0a47dd31e..b49597239 100644 --- a/internal/service/ws.go +++ b/internal/service/ws.go @@ -123,12 +123,13 @@ func (s *WsService) Follow(w http.ResponseWriter, r *http.Request) { } var cmd *exec.Cmd - if req.Service != "" { + switch { + case req.Service != "": cmd = exec.CommandContext(ctx, "journalctl", "--no-pager", "-n", "0", "-f", "-u", req.Service) - } else if req.Offset > 0 { + case req.Offset > 0: // 从首屏锚点接着跟踪,补上首屏读取到建立连接之间写入的日志(-c 的字节偏移从 1 开始) cmd = exec.CommandContext(ctx, "tail", "-c", fmt.Sprintf("+%d", req.Offset+1), "-F", req.Path) - } else { + default: cmd = exec.CommandContext(ctx, "tail", "-n", "0", "-F", req.Path) } shell.ApplyEnv(cmd) @@ -311,26 +312,23 @@ func (s *WsService) SSHTransfer(w http.ResponseWriter, r *http.Request) { return } lastPush = time.Now() - data, _ := json.Marshal(map[string]any{ + _ = s.writeJSON(ctx, ws, map[string]any{ "status": "progress", "transferred": transferred, "total": total, }) - _ = ws.Write(ctx, websocket.MessageText, data) } if err = s.sshRepo.TransferFile(ctx, req.SrcID, req.SrcPath, req.DstID, req.DstPath, progress); err != nil { - errMsg, _ := json.Marshal(map[string]any{ + _ = s.writeJSON(ctx, ws, map[string]any{ "status": "error", "msg": err.Error(), }) - _ = ws.Write(ctx, websocket.MessageText, errMsg) _ = ws.Close(websocket.StatusNormalClosure, "") return } - successMsg, _ := json.Marshal(map[string]any{"status": "success"}) - _ = ws.Write(ctx, websocket.MessageText, successMsg) + _ = s.writeJSON(ctx, ws, map[string]any{"status": "success"}) _ = ws.Close(websocket.StatusNormalClosure, "") } @@ -362,6 +360,7 @@ func (s *WsService) ContainerTerminal(w http.ResponseWriter, r *http.Request) { } go func() { + //nolint:contextcheck defer turn.Close() _ = turn.Handle(ctx) }() @@ -407,6 +406,7 @@ func (s *WsService) ContainerImagePull(w http.ResponseWriter, r *http.Request) { Username: req.Username, Password: req.Password, } + //nolint:gosec encodedJSON, err := json.Marshal(authConfig) if err != nil { _ = ws.Close(websocket.StatusNormalClosure, s.t.Get("failed to encode auth: %v", err)) @@ -426,38 +426,34 @@ func (s *WsService) ContainerImagePull(w http.ResponseWriter, r *http.Request) { for msg, err := range resp.JSONMessages(ctx) { if err != nil { s.log.Warn("image pull error", slog.Any("err", err)) - errorMsg, _ := json.Marshal(map[string]any{ + _ = s.writeJSON(ctx, ws, map[string]any{ "status": "error", "error": err.Error(), }) - _ = ws.Write(ctx, websocket.MessageText, errorMsg) return } // 如果有错误,发送错误消息 if msg.Error != nil { - errorMsg, _ := json.Marshal(map[string]any{ + _ = s.writeJSON(ctx, ws, map[string]any{ "status": "error", "error": msg.Error.Message, }) - _ = ws.Write(ctx, websocket.MessageText, errorMsg) return } // 转发进度信息 - progressMsg, _ := json.Marshal(msg) - if err = ws.Write(ctx, websocket.MessageText, progressMsg); err != nil { + if err = s.writeJSON(ctx, ws, msg); err != nil { s.log.Warn("write image pull progress error", slog.Any("err", err)) return } } // 拉取完成 - completeMsg, _ := json.Marshal(map[string]any{ + _ = s.writeJSON(ctx, ws, map[string]any{ "status": "complete", "complete": true, }) - _ = ws.Write(ctx, websocket.MessageText, completeMsg) _ = ws.Close(websocket.StatusNormalClosure, "") } @@ -511,11 +507,11 @@ func (s *WsService) PanelUpdate(w http.ResponseWriter, r *http.Request) { // 写入用带超时的独立 context:与请求/WS 生命周期解耦, // 用户关闭页面导致连接断开也不会中断升级(升级内部 shell 执行不带 ctx) + //nolint:contextcheck write := func(status, msg string) { - data, _ := json.Marshal(map[string]any{"status": status, "msg": msg}) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - _ = ws.Write(ctx, websocket.MessageText, data) + _ = s.writeJSON(ctx, ws, map[string]any{"status": status, "msg": msg}) } if err = s.backupRepo.UpdatePanel(panel.Version, url, checksum, func(msg string) { write("progress", msg) }); err != nil { @@ -563,31 +559,28 @@ func (s *WsService) handleCertWs(w http.ResponseWriter, r *http.Request, action if ctx.Err() != nil { return } - data, _ := json.Marshal(map[string]any{ + if err = s.writeJSON(ctx, ws, map[string]any{ "status": "progress", "msg": msg, - }) - if err = ws.Write(ctx, websocket.MessageText, data); err != nil { + }); err != nil { s.log.Warn("write cert progress error", slog.Any("err", err), slog.String("action", action)) } } if err = fn(ctx, req.ID, progressCallback); err != nil { - errMsg, _ := json.Marshal(map[string]any{ + _ = s.writeJSON(ctx, ws, map[string]any{ "status": "error", "msg": err.Error(), }) - _ = ws.Write(ctx, websocket.MessageText, errMsg) _ = ws.Close(websocket.StatusNormalClosure, "") return } - completeMsg, _ := json.Marshal(map[string]any{ + _ = s.writeJSON(ctx, ws, map[string]any{ "status": "success", "msg": "success", "data": nil, }) - _ = ws.Write(ctx, websocket.MessageText, completeMsg) _ = ws.Close(websocket.StatusNormalClosure, "") } @@ -682,6 +675,16 @@ func (s *WsService) upgrade(w http.ResponseWriter, r *http.Request) (*websocket. return websocket.Accept(w, r, opts) } +// writeJSON 序列化后写入一条文本消息 +func (s *WsService) writeJSON(ctx context.Context, c *websocket.Conn, v any) error { + data, err := json.Marshal(v) + if err != nil { + return err + } + + return c.Write(ctx, websocket.MessageText, data) +} + // readLoop 阻塞直到客户端关闭连接 func (s *WsService) readLoop(ctx context.Context, c *websocket.Conn) { for { diff --git a/internal/taskqueue/runner.go b/internal/taskqueue/runner.go index 093932923..d4e645dfd 100644 --- a/internal/taskqueue/runner.go +++ b/internal/taskqueue/runner.go @@ -159,7 +159,7 @@ func (r *Runner) execute(ctx context.Context, task *biz.Task) { status := biz.TaskStatusFailed if taskCtx.Err() != nil && ctx.Err() == nil { status = biz.TaskStatusCanceled - r.runCancelShell(task, logFile) + r.runCancelShell(ctx, task, logFile) } r.log.Warn("background task did not finish", slog.Any("task_id", task.ID), slog.Any("status", status), slog.Any("err", err)) _ = r.db.Model(task).Update("status", status).Error @@ -182,12 +182,12 @@ func (r *Runner) execute(ctx context.Context, task *biz.Task) { } // runCancelShell 任务被取消后执行清理命令,输出追加到任务日志 -func (r *Runner) runCancelShell(task *biz.Task, logFile string) { +func (r *Runner) runCancelShell(ctx context.Context, task *biz.Task, logFile string) { if task.CancelShell == "" { return } - cleanupCtx, cancel := context.WithTimeout(context.Background(), time.Minute) + cleanupCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), time.Minute) defer cancel() f, err := os.OpenFile(logFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644) diff --git a/mocks/biz/AlertRepo.go b/mocks/biz/AlertRepo.go deleted file mode 100644 index fcb9e1260..000000000 --- a/mocks/biz/AlertRepo.go +++ /dev/null @@ -1,887 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "time" - - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewAlertRepo creates a new instance of AlertRepo. 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 NewAlertRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *AlertRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &AlertRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// AlertRepo is an autogenerated mock type for the AlertRepo type -type AlertRepo struct { - mock.Mock -} - -type AlertRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *AlertRepo) EXPECT() *AlertRepo_Expecter { - return &AlertRepo_Expecter{mock: &_m.Mock} -} - -// AddAlert provides a mock function for the type AlertRepo -func (_mock *AlertRepo) AddAlert(alert *biz.Alert) error { - ret := _mock.Called(alert) - - if len(ret) == 0 { - panic("no return value specified for AddAlert") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Alert) error); ok { - r0 = returnFunc(alert) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AlertRepo_AddAlert_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddAlert' -type AlertRepo_AddAlert_Call struct { - *mock.Call -} - -// AddAlert is a helper method to define mock.On call -// - alert *biz.Alert -func (_e *AlertRepo_Expecter) AddAlert(alert any) *AlertRepo_AddAlert_Call { - return &AlertRepo_AddAlert_Call{Call: _e.mock.On("AddAlert", alert)} -} - -func (_c *AlertRepo_AddAlert_Call) Run(run func(alert *biz.Alert)) *AlertRepo_AddAlert_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Alert - if args[0] != nil { - arg0 = args[0].(*biz.Alert) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *AlertRepo_AddAlert_Call) Return(err error) *AlertRepo_AddAlert_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AlertRepo_AddAlert_Call) RunAndReturn(run func(alert *biz.Alert) error) *AlertRepo_AddAlert_Call { - _c.Call.Return(run) - return _c -} - -// AllRules provides a mock function for the type AlertRepo -func (_mock *AlertRepo) AllRules() ([]*biz.AlertRule, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for AllRules") - } - - var r0 []*biz.AlertRule - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]*biz.AlertRule, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []*biz.AlertRule); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.AlertRule) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AlertRepo_AllRules_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllRules' -type AlertRepo_AllRules_Call struct { - *mock.Call -} - -// AllRules is a helper method to define mock.On call -func (_e *AlertRepo_Expecter) AllRules() *AlertRepo_AllRules_Call { - return &AlertRepo_AllRules_Call{Call: _e.mock.On("AllRules")} -} - -func (_c *AlertRepo_AllRules_Call) Run(run func()) *AlertRepo_AllRules_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *AlertRepo_AllRules_Call) Return(alertRules []*biz.AlertRule, err error) *AlertRepo_AllRules_Call { - _c.Call.Return(alertRules, err) - return _c -} - -func (_c *AlertRepo_AllRules_Call) RunAndReturn(run func() ([]*biz.AlertRule, error)) *AlertRepo_AllRules_Call { - _c.Call.Return(run) - return _c -} - -// CertExpiry provides a mock function for the type AlertRepo -func (_mock *AlertRepo) CertExpiry() ([]*biz.AlertMetric, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for CertExpiry") - } - - var r0 []*biz.AlertMetric - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]*biz.AlertMetric, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []*biz.AlertMetric); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.AlertMetric) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AlertRepo_CertExpiry_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CertExpiry' -type AlertRepo_CertExpiry_Call struct { - *mock.Call -} - -// CertExpiry is a helper method to define mock.On call -func (_e *AlertRepo_Expecter) CertExpiry() *AlertRepo_CertExpiry_Call { - return &AlertRepo_CertExpiry_Call{Call: _e.mock.On("CertExpiry")} -} - -func (_c *AlertRepo_CertExpiry_Call) Run(run func()) *AlertRepo_CertExpiry_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *AlertRepo_CertExpiry_Call) Return(alertMetrics []*biz.AlertMetric, err error) *AlertRepo_CertExpiry_Call { - _c.Call.Return(alertMetrics, err) - return _c -} - -func (_c *AlertRepo_CertExpiry_Call) RunAndReturn(run func() ([]*biz.AlertMetric, error)) *AlertRepo_CertExpiry_Call { - _c.Call.Return(run) - return _c -} - -// ClearAlerts provides a mock function for the type AlertRepo -func (_mock *AlertRepo) ClearAlerts() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for ClearAlerts") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AlertRepo_ClearAlerts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearAlerts' -type AlertRepo_ClearAlerts_Call struct { - *mock.Call -} - -// ClearAlerts is a helper method to define mock.On call -func (_e *AlertRepo_Expecter) ClearAlerts() *AlertRepo_ClearAlerts_Call { - return &AlertRepo_ClearAlerts_Call{Call: _e.mock.On("ClearAlerts")} -} - -func (_c *AlertRepo_ClearAlerts_Call) Run(run func()) *AlertRepo_ClearAlerts_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *AlertRepo_ClearAlerts_Call) Return(err error) *AlertRepo_ClearAlerts_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AlertRepo_ClearAlerts_Call) RunAndReturn(run func() error) *AlertRepo_ClearAlerts_Call { - _c.Call.Return(run) - return _c -} - -// ClearAlertsBefore provides a mock function for the type AlertRepo -func (_mock *AlertRepo) ClearAlertsBefore(t time.Time) error { - ret := _mock.Called(t) - - if len(ret) == 0 { - panic("no return value specified for ClearAlertsBefore") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(time.Time) error); ok { - r0 = returnFunc(t) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AlertRepo_ClearAlertsBefore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearAlertsBefore' -type AlertRepo_ClearAlertsBefore_Call struct { - *mock.Call -} - -// ClearAlertsBefore is a helper method to define mock.On call -// - t time.Time -func (_e *AlertRepo_Expecter) ClearAlertsBefore(t any) *AlertRepo_ClearAlertsBefore_Call { - return &AlertRepo_ClearAlertsBefore_Call{Call: _e.mock.On("ClearAlertsBefore", t)} -} - -func (_c *AlertRepo_ClearAlertsBefore_Call) Run(run func(t time.Time)) *AlertRepo_ClearAlertsBefore_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 time.Time - if args[0] != nil { - arg0 = args[0].(time.Time) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *AlertRepo_ClearAlertsBefore_Call) Return(err error) *AlertRepo_ClearAlertsBefore_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AlertRepo_ClearAlertsBefore_Call) RunAndReturn(run func(t time.Time) error) *AlertRepo_ClearAlertsBefore_Call { - _c.Call.Return(run) - return _c -} - -// CreateRule provides a mock function for the type AlertRepo -func (_mock *AlertRepo) CreateRule(rule *biz.AlertRule) error { - ret := _mock.Called(rule) - - if len(ret) == 0 { - panic("no return value specified for CreateRule") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.AlertRule) error); ok { - r0 = returnFunc(rule) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AlertRepo_CreateRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateRule' -type AlertRepo_CreateRule_Call struct { - *mock.Call -} - -// CreateRule is a helper method to define mock.On call -// - rule *biz.AlertRule -func (_e *AlertRepo_Expecter) CreateRule(rule any) *AlertRepo_CreateRule_Call { - return &AlertRepo_CreateRule_Call{Call: _e.mock.On("CreateRule", rule)} -} - -func (_c *AlertRepo_CreateRule_Call) Run(run func(rule *biz.AlertRule)) *AlertRepo_CreateRule_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.AlertRule - if args[0] != nil { - arg0 = args[0].(*biz.AlertRule) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *AlertRepo_CreateRule_Call) Return(err error) *AlertRepo_CreateRule_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AlertRepo_CreateRule_Call) RunAndReturn(run func(rule *biz.AlertRule) error) *AlertRepo_CreateRule_Call { - _c.Call.Return(run) - return _c -} - -// DatabaseServers provides a mock function for the type AlertRepo -func (_mock *AlertRepo) DatabaseServers() ([]*biz.DatabaseServer, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for DatabaseServers") - } - - var r0 []*biz.DatabaseServer - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]*biz.DatabaseServer, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []*biz.DatabaseServer); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.DatabaseServer) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AlertRepo_DatabaseServers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DatabaseServers' -type AlertRepo_DatabaseServers_Call struct { - *mock.Call -} - -// DatabaseServers is a helper method to define mock.On call -func (_e *AlertRepo_Expecter) DatabaseServers() *AlertRepo_DatabaseServers_Call { - return &AlertRepo_DatabaseServers_Call{Call: _e.mock.On("DatabaseServers")} -} - -func (_c *AlertRepo_DatabaseServers_Call) Run(run func()) *AlertRepo_DatabaseServers_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *AlertRepo_DatabaseServers_Call) Return(databaseServers []*biz.DatabaseServer, err error) *AlertRepo_DatabaseServers_Call { - _c.Call.Return(databaseServers, err) - return _c -} - -func (_c *AlertRepo_DatabaseServers_Call) RunAndReturn(run func() ([]*biz.DatabaseServer, error)) *AlertRepo_DatabaseServers_Call { - _c.Call.Return(run) - return _c -} - -// DeleteRule provides a mock function for the type AlertRepo -func (_mock *AlertRepo) DeleteRule(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for DeleteRule") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AlertRepo_DeleteRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteRule' -type AlertRepo_DeleteRule_Call struct { - *mock.Call -} - -// DeleteRule is a helper method to define mock.On call -// - id uint -func (_e *AlertRepo_Expecter) DeleteRule(id any) *AlertRepo_DeleteRule_Call { - return &AlertRepo_DeleteRule_Call{Call: _e.mock.On("DeleteRule", id)} -} - -func (_c *AlertRepo_DeleteRule_Call) Run(run func(id uint)) *AlertRepo_DeleteRule_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *AlertRepo_DeleteRule_Call) Return(err error) *AlertRepo_DeleteRule_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AlertRepo_DeleteRule_Call) RunAndReturn(run func(id uint) error) *AlertRepo_DeleteRule_Call { - _c.Call.Return(run) - return _c -} - -// GetRule provides a mock function for the type AlertRepo -func (_mock *AlertRepo) GetRule(id uint) (*biz.AlertRule, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for GetRule") - } - - var r0 *biz.AlertRule - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.AlertRule, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.AlertRule); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.AlertRule) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AlertRepo_GetRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRule' -type AlertRepo_GetRule_Call struct { - *mock.Call -} - -// GetRule is a helper method to define mock.On call -// - id uint -func (_e *AlertRepo_Expecter) GetRule(id any) *AlertRepo_GetRule_Call { - return &AlertRepo_GetRule_Call{Call: _e.mock.On("GetRule", id)} -} - -func (_c *AlertRepo_GetRule_Call) Run(run func(id uint)) *AlertRepo_GetRule_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *AlertRepo_GetRule_Call) Return(alertRule *biz.AlertRule, err error) *AlertRepo_GetRule_Call { - _c.Call.Return(alertRule, err) - return _c -} - -func (_c *AlertRepo_GetRule_Call) RunAndReturn(run func(id uint) (*biz.AlertRule, error)) *AlertRepo_GetRule_Call { - _c.Call.Return(run) - return _c -} - -// ListAlerts provides a mock function for the type AlertRepo -func (_mock *AlertRepo) ListAlerts(page uint, limit uint) ([]*biz.Alert, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for ListAlerts") - } - - var r0 []*biz.Alert - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.Alert, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.Alert); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.Alert) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// AlertRepo_ListAlerts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAlerts' -type AlertRepo_ListAlerts_Call struct { - *mock.Call -} - -// ListAlerts is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *AlertRepo_Expecter) ListAlerts(page any, limit any) *AlertRepo_ListAlerts_Call { - return &AlertRepo_ListAlerts_Call{Call: _e.mock.On("ListAlerts", page, limit)} -} - -func (_c *AlertRepo_ListAlerts_Call) Run(run func(page uint, limit uint)) *AlertRepo_ListAlerts_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *AlertRepo_ListAlerts_Call) Return(alerts []*biz.Alert, n int64, err error) *AlertRepo_ListAlerts_Call { - _c.Call.Return(alerts, n, err) - return _c -} - -func (_c *AlertRepo_ListAlerts_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.Alert, int64, error)) *AlertRepo_ListAlerts_Call { - _c.Call.Return(run) - return _c -} - -// ListRules provides a mock function for the type AlertRepo -func (_mock *AlertRepo) ListRules(page uint, limit uint) ([]*biz.AlertRule, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for ListRules") - } - - var r0 []*biz.AlertRule - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.AlertRule, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.AlertRule); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.AlertRule) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// AlertRepo_ListRules_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListRules' -type AlertRepo_ListRules_Call struct { - *mock.Call -} - -// ListRules is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *AlertRepo_Expecter) ListRules(page any, limit any) *AlertRepo_ListRules_Call { - return &AlertRepo_ListRules_Call{Call: _e.mock.On("ListRules", page, limit)} -} - -func (_c *AlertRepo_ListRules_Call) Run(run func(page uint, limit uint)) *AlertRepo_ListRules_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *AlertRepo_ListRules_Call) Return(alertRules []*biz.AlertRule, n int64, err error) *AlertRepo_ListRules_Call { - _c.Call.Return(alertRules, n, err) - return _c -} - -func (_c *AlertRepo_ListRules_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.AlertRule, int64, error)) *AlertRepo_ListRules_Call { - _c.Call.Return(run) - return _c -} - -// ProjectNames provides a mock function for the type AlertRepo -func (_mock *AlertRepo) ProjectNames() ([]string, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for ProjectNames") - } - - var r0 []string - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]string, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []string); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]string) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AlertRepo_ProjectNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProjectNames' -type AlertRepo_ProjectNames_Call struct { - *mock.Call -} - -// ProjectNames is a helper method to define mock.On call -func (_e *AlertRepo_Expecter) ProjectNames() *AlertRepo_ProjectNames_Call { - return &AlertRepo_ProjectNames_Call{Call: _e.mock.On("ProjectNames")} -} - -func (_c *AlertRepo_ProjectNames_Call) Run(run func()) *AlertRepo_ProjectNames_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *AlertRepo_ProjectNames_Call) Return(strings []string, err error) *AlertRepo_ProjectNames_Call { - _c.Call.Return(strings, err) - return _c -} - -func (_c *AlertRepo_ProjectNames_Call) RunAndReturn(run func() ([]string, error)) *AlertRepo_ProjectNames_Call { - _c.Call.Return(run) - return _c -} - -// UpdateRule provides a mock function for the type AlertRepo -func (_mock *AlertRepo) UpdateRule(rule *biz.AlertRule) error { - ret := _mock.Called(rule) - - if len(ret) == 0 { - panic("no return value specified for UpdateRule") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.AlertRule) error); ok { - r0 = returnFunc(rule) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AlertRepo_UpdateRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRule' -type AlertRepo_UpdateRule_Call struct { - *mock.Call -} - -// UpdateRule is a helper method to define mock.On call -// - rule *biz.AlertRule -func (_e *AlertRepo_Expecter) UpdateRule(rule any) *AlertRepo_UpdateRule_Call { - return &AlertRepo_UpdateRule_Call{Call: _e.mock.On("UpdateRule", rule)} -} - -func (_c *AlertRepo_UpdateRule_Call) Run(run func(rule *biz.AlertRule)) *AlertRepo_UpdateRule_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.AlertRule - if args[0] != nil { - arg0 = args[0].(*biz.AlertRule) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *AlertRepo_UpdateRule_Call) Return(err error) *AlertRepo_UpdateRule_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AlertRepo_UpdateRule_Call) RunAndReturn(run func(rule *biz.AlertRule) error) *AlertRepo_UpdateRule_Call { - _c.Call.Return(run) - return _c -} - -// WebsiteExpiry provides a mock function for the type AlertRepo -func (_mock *AlertRepo) WebsiteExpiry() ([]*biz.AlertMetric, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for WebsiteExpiry") - } - - var r0 []*biz.AlertMetric - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]*biz.AlertMetric, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []*biz.AlertMetric); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.AlertMetric) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AlertRepo_WebsiteExpiry_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WebsiteExpiry' -type AlertRepo_WebsiteExpiry_Call struct { - *mock.Call -} - -// WebsiteExpiry is a helper method to define mock.On call -func (_e *AlertRepo_Expecter) WebsiteExpiry() *AlertRepo_WebsiteExpiry_Call { - return &AlertRepo_WebsiteExpiry_Call{Call: _e.mock.On("WebsiteExpiry")} -} - -func (_c *AlertRepo_WebsiteExpiry_Call) Run(run func()) *AlertRepo_WebsiteExpiry_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *AlertRepo_WebsiteExpiry_Call) Return(alertMetrics []*biz.AlertMetric, err error) *AlertRepo_WebsiteExpiry_Call { - _c.Call.Return(alertMetrics, err) - return _c -} - -func (_c *AlertRepo_WebsiteExpiry_Call) RunAndReturn(run func() ([]*biz.AlertMetric, error)) *AlertRepo_WebsiteExpiry_Call { - _c.Call.Return(run) - return _c -} - -// WebsiteHourStats provides a mock function for the type AlertRepo -func (_mock *AlertRepo) WebsiteHourStats() ([]*biz.WebsiteHourStat, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for WebsiteHourStats") - } - - var r0 []*biz.WebsiteHourStat - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]*biz.WebsiteHourStat, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []*biz.WebsiteHourStat); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteHourStat) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AlertRepo_WebsiteHourStats_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WebsiteHourStats' -type AlertRepo_WebsiteHourStats_Call struct { - *mock.Call -} - -// WebsiteHourStats is a helper method to define mock.On call -func (_e *AlertRepo_Expecter) WebsiteHourStats() *AlertRepo_WebsiteHourStats_Call { - return &AlertRepo_WebsiteHourStats_Call{Call: _e.mock.On("WebsiteHourStats")} -} - -func (_c *AlertRepo_WebsiteHourStats_Call) Run(run func()) *AlertRepo_WebsiteHourStats_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *AlertRepo_WebsiteHourStats_Call) Return(websiteHourStats []*biz.WebsiteHourStat, err error) *AlertRepo_WebsiteHourStats_Call { - _c.Call.Return(websiteHourStats, err) - return _c -} - -func (_c *AlertRepo_WebsiteHourStats_Call) RunAndReturn(run func() ([]*biz.WebsiteHourStat, error)) *AlertRepo_WebsiteHourStats_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/AppRepo.go b/mocks/biz/AppRepo.go deleted file mode 100644 index d0dc1670b..000000000 --- a/mocks/biz/AppRepo.go +++ /dev/null @@ -1,868 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/pkg/api" - mock "github.com/stretchr/testify/mock" -) - -// NewAppRepo creates a new instance of AppRepo. 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 NewAppRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *AppRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &AppRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// AppRepo is an autogenerated mock type for the AppRepo type -type AppRepo struct { - mock.Mock -} - -type AppRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *AppRepo) EXPECT() *AppRepo_Expecter { - return &AppRepo_Expecter{mock: &_m.Mock} -} - -// CheckPanelVersion provides a mock function for the type AppRepo -func (_mock *AppRepo) CheckPanelVersion() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for CheckPanelVersion") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AppRepo_CheckPanelVersion_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckPanelVersion' -type AppRepo_CheckPanelVersion_Call struct { - *mock.Call -} - -// CheckPanelVersion is a helper method to define mock.On call -func (_e *AppRepo_Expecter) CheckPanelVersion() *AppRepo_CheckPanelVersion_Call { - return &AppRepo_CheckPanelVersion_Call{Call: _e.mock.On("CheckPanelVersion")} -} - -func (_c *AppRepo_CheckPanelVersion_Call) Run(run func()) *AppRepo_CheckPanelVersion_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *AppRepo_CheckPanelVersion_Call) Return(err error) *AppRepo_CheckPanelVersion_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AppRepo_CheckPanelVersion_Call) RunAndReturn(run func() error) *AppRepo_CheckPanelVersion_Call { - _c.Call.Return(run) - return _c -} - -// DownloadCallback provides a mock function for the type AppRepo -func (_mock *AppRepo) DownloadCallback(slug string) { - _mock.Called(slug) - return -} - -// AppRepo_DownloadCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DownloadCallback' -type AppRepo_DownloadCallback_Call struct { - *mock.Call -} - -// DownloadCallback is a helper method to define mock.On call -// - slug string -func (_e *AppRepo_Expecter) DownloadCallback(slug any) *AppRepo_DownloadCallback_Call { - return &AppRepo_DownloadCallback_Call{Call: _e.mock.On("DownloadCallback", slug)} -} - -func (_c *AppRepo_DownloadCallback_Call) Run(run func(slug string)) *AppRepo_DownloadCallback_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *AppRepo_DownloadCallback_Call) Return() *AppRepo_DownloadCallback_Call { - _c.Call.Return() - return _c -} - -func (_c *AppRepo_DownloadCallback_Call) RunAndReturn(run func(slug string)) *AppRepo_DownloadCallback_Call { - _c.Run(run) - return _c -} - -// ExecScript provides a mock function for the type AppRepo -func (_mock *AppRepo) ExecScript(script string) error { - ret := _mock.Called(script) - - if len(ret) == 0 { - panic("no return value specified for ExecScript") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(script) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AppRepo_ExecScript_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExecScript' -type AppRepo_ExecScript_Call struct { - *mock.Call -} - -// ExecScript is a helper method to define mock.On call -// - script string -func (_e *AppRepo_Expecter) ExecScript(script any) *AppRepo_ExecScript_Call { - return &AppRepo_ExecScript_Call{Call: _e.mock.On("ExecScript", script)} -} - -func (_c *AppRepo_ExecScript_Call) Run(run func(script string)) *AppRepo_ExecScript_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *AppRepo_ExecScript_Call) Return(err error) *AppRepo_ExecScript_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AppRepo_ExecScript_Call) RunAndReturn(run func(script string) error) *AppRepo_ExecScript_Call { - _c.Call.Return(run) - return _c -} - -// GetCustom provides a mock function for the type AppRepo -func (_mock *AppRepo) GetCustom(slug string) (*biz.AppCustom, error) { - ret := _mock.Called(slug) - - if len(ret) == 0 { - panic("no return value specified for GetCustom") - } - - var r0 *biz.AppCustom - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) (*biz.AppCustom, error)); ok { - return returnFunc(slug) - } - if returnFunc, ok := ret.Get(0).(func(string) *biz.AppCustom); ok { - r0 = returnFunc(slug) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.AppCustom) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(slug) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AppRepo_GetCustom_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCustom' -type AppRepo_GetCustom_Call struct { - *mock.Call -} - -// GetCustom is a helper method to define mock.On call -// - slug string -func (_e *AppRepo_Expecter) GetCustom(slug any) *AppRepo_GetCustom_Call { - return &AppRepo_GetCustom_Call{Call: _e.mock.On("GetCustom", slug)} -} - -func (_c *AppRepo_GetCustom_Call) Run(run func(slug string)) *AppRepo_GetCustom_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *AppRepo_GetCustom_Call) Return(appCustom *biz.AppCustom, err error) *AppRepo_GetCustom_Call { - _c.Call.Return(appCustom, err) - return _c -} - -func (_c *AppRepo_GetCustom_Call) RunAndReturn(run func(slug string) (*biz.AppCustom, error)) *AppRepo_GetCustom_Call { - _c.Call.Return(run) - return _c -} - -// GetInstalled provides a mock function for the type AppRepo -func (_mock *AppRepo) GetInstalled(slug string) (*biz.App, error) { - ret := _mock.Called(slug) - - if len(ret) == 0 { - panic("no return value specified for GetInstalled") - } - - var r0 *biz.App - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) (*biz.App, error)); ok { - return returnFunc(slug) - } - if returnFunc, ok := ret.Get(0).(func(string) *biz.App); ok { - r0 = returnFunc(slug) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.App) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(slug) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AppRepo_GetInstalled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetInstalled' -type AppRepo_GetInstalled_Call struct { - *mock.Call -} - -// GetInstalled is a helper method to define mock.On call -// - slug string -func (_e *AppRepo_Expecter) GetInstalled(slug any) *AppRepo_GetInstalled_Call { - return &AppRepo_GetInstalled_Call{Call: _e.mock.On("GetInstalled", slug)} -} - -func (_c *AppRepo_GetInstalled_Call) Run(run func(slug string)) *AppRepo_GetInstalled_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *AppRepo_GetInstalled_Call) Return(app *biz.App, err error) *AppRepo_GetInstalled_Call { - _c.Call.Return(app, err) - return _c -} - -func (_c *AppRepo_GetInstalled_Call) RunAndReturn(run func(slug string) (*biz.App, error)) *AppRepo_GetInstalled_Call { - _c.Call.Return(run) - return _c -} - -// GetInstalledAll provides a mock function for the type AppRepo -func (_mock *AppRepo) GetInstalledAll(query string, cond ...string) ([]*biz.App, error) { - var tmpRet mock.Arguments - if len(cond) > 0 { - tmpRet = _mock.Called(query, cond) - } else { - tmpRet = _mock.Called(query) - } - ret := tmpRet - - if len(ret) == 0 { - panic("no return value specified for GetInstalledAll") - } - - var r0 []*biz.App - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, ...string) ([]*biz.App, error)); ok { - return returnFunc(query, cond...) - } - if returnFunc, ok := ret.Get(0).(func(string, ...string) []*biz.App); ok { - r0 = returnFunc(query, cond...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.App) - } - } - if returnFunc, ok := ret.Get(1).(func(string, ...string) error); ok { - r1 = returnFunc(query, cond...) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AppRepo_GetInstalledAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetInstalledAll' -type AppRepo_GetInstalledAll_Call struct { - *mock.Call -} - -// GetInstalledAll is a helper method to define mock.On call -// - query string -// - cond ...string -func (_e *AppRepo_Expecter) GetInstalledAll(query any, cond ...any) *AppRepo_GetInstalledAll_Call { - return &AppRepo_GetInstalledAll_Call{Call: _e.mock.On("GetInstalledAll", - append([]any{query}, cond...)...)} -} - -func (_c *AppRepo_GetInstalledAll_Call) Run(run func(query string, cond ...string)) *AppRepo_GetInstalledAll_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 []string - var variadicArgs []string - if len(args) > 1 { - variadicArgs = args[1].([]string) - } - arg1 = variadicArgs - run( - arg0, - arg1..., - ) - }) - return _c -} - -func (_c *AppRepo_GetInstalledAll_Call) Return(apps []*biz.App, err error) *AppRepo_GetInstalledAll_Call { - _c.Call.Return(apps, err) - return _c -} - -func (_c *AppRepo_GetInstalledAll_Call) RunAndReturn(run func(query string, cond ...string) ([]*biz.App, error)) *AppRepo_GetInstalledAll_Call { - _c.Call.Return(run) - return _c -} - -// Installed provides a mock function for the type AppRepo -func (_mock *AppRepo) Installed() ([]*biz.App, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for Installed") - } - - var r0 []*biz.App - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]*biz.App, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []*biz.App); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.App) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AppRepo_Installed_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Installed' -type AppRepo_Installed_Call struct { - *mock.Call -} - -// Installed is a helper method to define mock.On call -func (_e *AppRepo_Expecter) Installed() *AppRepo_Installed_Call { - return &AppRepo_Installed_Call{Call: _e.mock.On("Installed")} -} - -func (_c *AppRepo_Installed_Call) Run(run func()) *AppRepo_Installed_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *AppRepo_Installed_Call) Return(apps []*biz.App, err error) *AppRepo_Installed_Call { - _c.Call.Return(apps, err) - return _c -} - -func (_c *AppRepo_Installed_Call) RunAndReturn(run func() ([]*biz.App, error)) *AppRepo_Installed_Call { - _c.Call.Return(run) - return _c -} - -// IsInstalled provides a mock function for the type AppRepo -func (_mock *AppRepo) IsInstalled(query string, cond ...any) (bool, error) { - var tmpRet mock.Arguments - if len(cond) > 0 { - tmpRet = _mock.Called(query, cond) - } else { - tmpRet = _mock.Called(query) - } - ret := tmpRet - - if len(ret) == 0 { - panic("no return value specified for IsInstalled") - } - - var r0 bool - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, ...any) (bool, error)); ok { - return returnFunc(query, cond...) - } - if returnFunc, ok := ret.Get(0).(func(string, ...any) bool); ok { - r0 = returnFunc(query, cond...) - } else { - r0 = ret.Get(0).(bool) - } - if returnFunc, ok := ret.Get(1).(func(string, ...any) error); ok { - r1 = returnFunc(query, cond...) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AppRepo_IsInstalled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsInstalled' -type AppRepo_IsInstalled_Call struct { - *mock.Call -} - -// IsInstalled is a helper method to define mock.On call -// - query string -// - cond ...any -func (_e *AppRepo_Expecter) IsInstalled(query any, cond ...any) *AppRepo_IsInstalled_Call { - return &AppRepo_IsInstalled_Call{Call: _e.mock.On("IsInstalled", - append([]any{query}, cond...)...)} -} - -func (_c *AppRepo_IsInstalled_Call) Run(run func(query string, cond ...any)) *AppRepo_IsInstalled_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 []any - var variadicArgs []any - if len(args) > 1 { - variadicArgs = args[1].([]any) - } - arg1 = variadicArgs - run( - arg0, - arg1..., - ) - }) - return _c -} - -func (_c *AppRepo_IsInstalled_Call) Return(b bool, err error) *AppRepo_IsInstalled_Call { - _c.Call.Return(b, err) - return _c -} - -func (_c *AppRepo_IsInstalled_Call) RunAndReturn(run func(query string, cond ...any) (bool, error)) *AppRepo_IsInstalled_Call { - _c.Call.Return(run) - return _c -} - -// ListHomeShow provides a mock function for the type AppRepo -func (_mock *AppRepo) ListHomeShow() ([]*biz.App, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for ListHomeShow") - } - - var r0 []*biz.App - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]*biz.App, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []*biz.App); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.App) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AppRepo_ListHomeShow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListHomeShow' -type AppRepo_ListHomeShow_Call struct { - *mock.Call -} - -// ListHomeShow is a helper method to define mock.On call -func (_e *AppRepo_Expecter) ListHomeShow() *AppRepo_ListHomeShow_Call { - return &AppRepo_ListHomeShow_Call{Call: _e.mock.On("ListHomeShow")} -} - -func (_c *AppRepo_ListHomeShow_Call) Run(run func()) *AppRepo_ListHomeShow_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *AppRepo_ListHomeShow_Call) Return(apps []*biz.App, err error) *AppRepo_ListHomeShow_Call { - _c.Call.Return(apps, err) - return _c -} - -func (_c *AppRepo_ListHomeShow_Call) RunAndReturn(run func() ([]*biz.App, error)) *AppRepo_ListHomeShow_Call { - _c.Call.Return(run) - return _c -} - -// PreCheck provides a mock function for the type AppRepo -func (_mock *AppRepo) PreCheck(item *api.App, catalog api.Apps) error { - ret := _mock.Called(item, catalog) - - if len(ret) == 0 { - panic("no return value specified for PreCheck") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*api.App, api.Apps) error); ok { - r0 = returnFunc(item, catalog) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AppRepo_PreCheck_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PreCheck' -type AppRepo_PreCheck_Call struct { - *mock.Call -} - -// PreCheck is a helper method to define mock.On call -// - item *api.App -// - catalog api.Apps -func (_e *AppRepo_Expecter) PreCheck(item any, catalog any) *AppRepo_PreCheck_Call { - return &AppRepo_PreCheck_Call{Call: _e.mock.On("PreCheck", item, catalog)} -} - -func (_c *AppRepo_PreCheck_Call) Run(run func(item *api.App, catalog api.Apps)) *AppRepo_PreCheck_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *api.App - if args[0] != nil { - arg0 = args[0].(*api.App) - } - var arg1 api.Apps - if args[1] != nil { - arg1 = args[1].(api.Apps) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *AppRepo_PreCheck_Call) Return(err error) *AppRepo_PreCheck_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AppRepo_PreCheck_Call) RunAndReturn(run func(item *api.App, catalog api.Apps) error) *AppRepo_PreCheck_Call { - _c.Call.Return(run) - return _c -} - -// ResolveScript provides a mock function for the type AppRepo -func (_mock *AppRepo) ResolveScript(item *api.App, matchChannel string, action string, execVersion string) (string, error) { - ret := _mock.Called(item, matchChannel, action, execVersion) - - if len(ret) == 0 { - panic("no return value specified for ResolveScript") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(*api.App, string, string, string) (string, error)); ok { - return returnFunc(item, matchChannel, action, execVersion) - } - if returnFunc, ok := ret.Get(0).(func(*api.App, string, string, string) string); ok { - r0 = returnFunc(item, matchChannel, action, execVersion) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(*api.App, string, string, string) error); ok { - r1 = returnFunc(item, matchChannel, action, execVersion) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// AppRepo_ResolveScript_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResolveScript' -type AppRepo_ResolveScript_Call struct { - *mock.Call -} - -// ResolveScript is a helper method to define mock.On call -// - item *api.App -// - matchChannel string -// - action string -// - execVersion string -func (_e *AppRepo_Expecter) ResolveScript(item any, matchChannel any, action any, execVersion any) *AppRepo_ResolveScript_Call { - return &AppRepo_ResolveScript_Call{Call: _e.mock.On("ResolveScript", item, matchChannel, action, execVersion)} -} - -func (_c *AppRepo_ResolveScript_Call) Run(run func(item *api.App, matchChannel string, action string, execVersion string)) *AppRepo_ResolveScript_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *api.App - if args[0] != nil { - arg0 = args[0].(*api.App) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *AppRepo_ResolveScript_Call) Return(s string, err error) *AppRepo_ResolveScript_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *AppRepo_ResolveScript_Call) RunAndReturn(run func(item *api.App, matchChannel string, action string, execVersion string) (string, error)) *AppRepo_ResolveScript_Call { - _c.Call.Return(run) - return _c -} - -// SaveCustom provides a mock function for the type AppRepo -func (_mock *AppRepo) SaveCustom(slug string, custom *biz.AppCustom) error { - ret := _mock.Called(slug, custom) - - if len(ret) == 0 { - panic("no return value specified for SaveCustom") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, *biz.AppCustom) error); ok { - r0 = returnFunc(slug, custom) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AppRepo_SaveCustom_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SaveCustom' -type AppRepo_SaveCustom_Call struct { - *mock.Call -} - -// SaveCustom is a helper method to define mock.On call -// - slug string -// - custom *biz.AppCustom -func (_e *AppRepo_Expecter) SaveCustom(slug any, custom any) *AppRepo_SaveCustom_Call { - return &AppRepo_SaveCustom_Call{Call: _e.mock.On("SaveCustom", slug, custom)} -} - -func (_c *AppRepo_SaveCustom_Call) Run(run func(slug string, custom *biz.AppCustom)) *AppRepo_SaveCustom_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 *biz.AppCustom - if args[1] != nil { - arg1 = args[1].(*biz.AppCustom) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *AppRepo_SaveCustom_Call) Return(err error) *AppRepo_SaveCustom_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AppRepo_SaveCustom_Call) RunAndReturn(run func(slug string, custom *biz.AppCustom) error) *AppRepo_SaveCustom_Call { - _c.Call.Return(run) - return _c -} - -// UpdateOrder provides a mock function for the type AppRepo -func (_mock *AppRepo) UpdateOrder(slugs []string) error { - ret := _mock.Called(slugs) - - if len(ret) == 0 { - panic("no return value specified for UpdateOrder") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func([]string) error); ok { - r0 = returnFunc(slugs) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AppRepo_UpdateOrder_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateOrder' -type AppRepo_UpdateOrder_Call struct { - *mock.Call -} - -// UpdateOrder is a helper method to define mock.On call -// - slugs []string -func (_e *AppRepo_Expecter) UpdateOrder(slugs any) *AppRepo_UpdateOrder_Call { - return &AppRepo_UpdateOrder_Call{Call: _e.mock.On("UpdateOrder", slugs)} -} - -func (_c *AppRepo_UpdateOrder_Call) Run(run func(slugs []string)) *AppRepo_UpdateOrder_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []string - if args[0] != nil { - arg0 = args[0].([]string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *AppRepo_UpdateOrder_Call) Return(err error) *AppRepo_UpdateOrder_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AppRepo_UpdateOrder_Call) RunAndReturn(run func(slugs []string) error) *AppRepo_UpdateOrder_Call { - _c.Call.Return(run) - return _c -} - -// UpdateShow provides a mock function for the type AppRepo -func (_mock *AppRepo) UpdateShow(slug string, show bool) error { - ret := _mock.Called(slug, show) - - if len(ret) == 0 { - panic("no return value specified for UpdateShow") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, bool) error); ok { - r0 = returnFunc(slug, show) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// AppRepo_UpdateShow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateShow' -type AppRepo_UpdateShow_Call struct { - *mock.Call -} - -// UpdateShow is a helper method to define mock.On call -// - slug string -// - show bool -func (_e *AppRepo_Expecter) UpdateShow(slug any, show any) *AppRepo_UpdateShow_Call { - return &AppRepo_UpdateShow_Call{Call: _e.mock.On("UpdateShow", slug, show)} -} - -func (_c *AppRepo_UpdateShow_Call) Run(run func(slug string, show bool)) *AppRepo_UpdateShow_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 bool - if args[1] != nil { - arg1 = args[1].(bool) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *AppRepo_UpdateShow_Call) Return(err error) *AppRepo_UpdateShow_Call { - _c.Call.Return(err) - return _c -} - -func (_c *AppRepo_UpdateShow_Call) RunAndReturn(run func(slug string, show bool) error) *AppRepo_UpdateShow_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/BackupAccountRepo.go b/mocks/biz/BackupAccountRepo.go deleted file mode 100644 index 1404c3bf5..000000000 --- a/mocks/biz/BackupAccountRepo.go +++ /dev/null @@ -1,335 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewBackupAccountRepo creates a new instance of BackupAccountRepo. 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 NewBackupAccountRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *BackupAccountRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &BackupAccountRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// BackupAccountRepo is an autogenerated mock type for the BackupAccountRepo type -type BackupAccountRepo struct { - mock.Mock -} - -type BackupAccountRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *BackupAccountRepo) EXPECT() *BackupAccountRepo_Expecter { - return &BackupAccountRepo_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function for the type BackupAccountRepo -func (_mock *BackupAccountRepo) Create(account *biz.BackupStorage) error { - ret := _mock.Called(account) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.BackupStorage) error); ok { - r0 = returnFunc(account) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupAccountRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type BackupAccountRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - account *biz.BackupStorage -func (_e *BackupAccountRepo_Expecter) Create(account any) *BackupAccountRepo_Create_Call { - return &BackupAccountRepo_Create_Call{Call: _e.mock.On("Create", account)} -} - -func (_c *BackupAccountRepo_Create_Call) Run(run func(account *biz.BackupStorage)) *BackupAccountRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.BackupStorage - if args[0] != nil { - arg0 = args[0].(*biz.BackupStorage) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *BackupAccountRepo_Create_Call) Return(err error) *BackupAccountRepo_Create_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupAccountRepo_Create_Call) RunAndReturn(run func(account *biz.BackupStorage) error) *BackupAccountRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type BackupAccountRepo -func (_mock *BackupAccountRepo) Delete(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupAccountRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type BackupAccountRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *BackupAccountRepo_Expecter) Delete(id any) *BackupAccountRepo_Delete_Call { - return &BackupAccountRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *BackupAccountRepo_Delete_Call) Run(run func(id uint)) *BackupAccountRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *BackupAccountRepo_Delete_Call) Return(err error) *BackupAccountRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupAccountRepo_Delete_Call) RunAndReturn(run func(id uint) error) *BackupAccountRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// GetByID provides a mock function for the type BackupAccountRepo -func (_mock *BackupAccountRepo) GetByID(id uint) (*biz.BackupStorage, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for GetByID") - } - - var r0 *biz.BackupStorage - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.BackupStorage, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.BackupStorage); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.BackupStorage) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// BackupAccountRepo_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID' -type BackupAccountRepo_GetByID_Call struct { - *mock.Call -} - -// GetByID is a helper method to define mock.On call -// - id uint -func (_e *BackupAccountRepo_Expecter) GetByID(id any) *BackupAccountRepo_GetByID_Call { - return &BackupAccountRepo_GetByID_Call{Call: _e.mock.On("GetByID", id)} -} - -func (_c *BackupAccountRepo_GetByID_Call) Run(run func(id uint)) *BackupAccountRepo_GetByID_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *BackupAccountRepo_GetByID_Call) Return(backupStorage *biz.BackupStorage, err error) *BackupAccountRepo_GetByID_Call { - _c.Call.Return(backupStorage, err) - return _c -} - -func (_c *BackupAccountRepo_GetByID_Call) RunAndReturn(run func(id uint) (*biz.BackupStorage, error)) *BackupAccountRepo_GetByID_Call { - _c.Call.Return(run) - return _c -} - -// ListPaged provides a mock function for the type BackupAccountRepo -func (_mock *BackupAccountRepo) ListPaged(page uint, limit uint) ([]*biz.BackupStorage, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for ListPaged") - } - - var r0 []*biz.BackupStorage - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.BackupStorage, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.BackupStorage); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.BackupStorage) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// BackupAccountRepo_ListPaged_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListPaged' -type BackupAccountRepo_ListPaged_Call struct { - *mock.Call -} - -// ListPaged is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *BackupAccountRepo_Expecter) ListPaged(page any, limit any) *BackupAccountRepo_ListPaged_Call { - return &BackupAccountRepo_ListPaged_Call{Call: _e.mock.On("ListPaged", page, limit)} -} - -func (_c *BackupAccountRepo_ListPaged_Call) Run(run func(page uint, limit uint)) *BackupAccountRepo_ListPaged_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *BackupAccountRepo_ListPaged_Call) Return(backupStorages []*biz.BackupStorage, n int64, err error) *BackupAccountRepo_ListPaged_Call { - _c.Call.Return(backupStorages, n, err) - return _c -} - -func (_c *BackupAccountRepo_ListPaged_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.BackupStorage, int64, error)) *BackupAccountRepo_ListPaged_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function for the type BackupAccountRepo -func (_mock *BackupAccountRepo) Update(account *biz.BackupStorage) error { - ret := _mock.Called(account) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.BackupStorage) error); ok { - r0 = returnFunc(account) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupAccountRepo_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type BackupAccountRepo_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - account *biz.BackupStorage -func (_e *BackupAccountRepo_Expecter) Update(account any) *BackupAccountRepo_Update_Call { - return &BackupAccountRepo_Update_Call{Call: _e.mock.On("Update", account)} -} - -func (_c *BackupAccountRepo_Update_Call) Run(run func(account *biz.BackupStorage)) *BackupAccountRepo_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.BackupStorage - if args[0] != nil { - arg0 = args[0].(*biz.BackupStorage) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *BackupAccountRepo_Update_Call) Return(err error) *BackupAccountRepo_Update_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupAccountRepo_Update_Call) RunAndReturn(run func(account *biz.BackupStorage) error) *BackupAccountRepo_Update_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/BackupRepo.go b/mocks/biz/BackupRepo.go deleted file mode 100644 index 476068b4c..000000000 --- a/mocks/biz/BackupRepo.go +++ /dev/null @@ -1,837 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "context" - - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewBackupRepo creates a new instance of BackupRepo. 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 NewBackupRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *BackupRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &BackupRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// BackupRepo is an autogenerated mock type for the BackupRepo type -type BackupRepo struct { - mock.Mock -} - -type BackupRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *BackupRepo) EXPECT() *BackupRepo_Expecter { - return &BackupRepo_Expecter{mock: &_m.Mock} -} - -// ClearExpired provides a mock function for the type BackupRepo -func (_mock *BackupRepo) ClearExpired(path string, prefix string, save uint) error { - ret := _mock.Called(path, prefix, save) - - if len(ret) == 0 { - panic("no return value specified for ClearExpired") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string, uint) error); ok { - r0 = returnFunc(path, prefix, save) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupRepo_ClearExpired_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearExpired' -type BackupRepo_ClearExpired_Call struct { - *mock.Call -} - -// ClearExpired is a helper method to define mock.On call -// - path string -// - prefix string -// - save uint -func (_e *BackupRepo_Expecter) ClearExpired(path any, prefix any, save any) *BackupRepo_ClearExpired_Call { - return &BackupRepo_ClearExpired_Call{Call: _e.mock.On("ClearExpired", path, prefix, save)} -} - -func (_c *BackupRepo_ClearExpired_Call) Run(run func(path string, prefix string, save uint)) *BackupRepo_ClearExpired_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 uint - if args[2] != nil { - arg2 = args[2].(uint) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *BackupRepo_ClearExpired_Call) Return(err error) *BackupRepo_ClearExpired_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupRepo_ClearExpired_Call) RunAndReturn(run func(path string, prefix string, save uint) error) *BackupRepo_ClearExpired_Call { - _c.Call.Return(run) - return _c -} - -// ClearStorageExpired provides a mock function for the type BackupRepo -func (_mock *BackupRepo) ClearStorageExpired(account uint, dir string, prefix string, save uint) error { - ret := _mock.Called(account, dir, prefix, save) - - if len(ret) == 0 { - panic("no return value specified for ClearStorageExpired") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, string, string, uint) error); ok { - r0 = returnFunc(account, dir, prefix, save) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupRepo_ClearStorageExpired_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearStorageExpired' -type BackupRepo_ClearStorageExpired_Call struct { - *mock.Call -} - -// ClearStorageExpired is a helper method to define mock.On call -// - account uint -// - dir string -// - prefix string -// - save uint -func (_e *BackupRepo_Expecter) ClearStorageExpired(account any, dir any, prefix any, save any) *BackupRepo_ClearStorageExpired_Call { - return &BackupRepo_ClearStorageExpired_Call{Call: _e.mock.On("ClearStorageExpired", account, dir, prefix, save)} -} - -func (_c *BackupRepo_ClearStorageExpired_Call) Run(run func(account uint, dir string, prefix string, save uint)) *BackupRepo_ClearStorageExpired_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 uint - if args[3] != nil { - arg3 = args[3].(uint) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *BackupRepo_ClearStorageExpired_Call) Return(err error) *BackupRepo_ClearStorageExpired_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupRepo_ClearStorageExpired_Call) RunAndReturn(run func(account uint, dir string, prefix string, save uint) error) *BackupRepo_ClearStorageExpired_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function for the type BackupRepo -func (_mock *BackupRepo) Create(ctx context.Context, typ biz.BackupType, target string, account uint) error { - ret := _mock.Called(ctx, typ, target, account) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, biz.BackupType, string, uint) error); ok { - r0 = returnFunc(ctx, typ, target, account) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type BackupRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - typ biz.BackupType -// - target string -// - account uint -func (_e *BackupRepo_Expecter) Create(ctx any, typ any, target any, account any) *BackupRepo_Create_Call { - return &BackupRepo_Create_Call{Call: _e.mock.On("Create", ctx, typ, target, account)} -} - -func (_c *BackupRepo_Create_Call) Run(run func(ctx context.Context, typ biz.BackupType, target string, account uint)) *BackupRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 biz.BackupType - if args[1] != nil { - arg1 = args[1].(biz.BackupType) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 uint - if args[3] != nil { - arg3 = args[3].(uint) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *BackupRepo_Create_Call) Return(err error) *BackupRepo_Create_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupRepo_Create_Call) RunAndReturn(run func(ctx context.Context, typ biz.BackupType, target string, account uint) error) *BackupRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// CreatePanel provides a mock function for the type BackupRepo -func (_mock *BackupRepo) CreatePanel() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for CreatePanel") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupRepo_CreatePanel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreatePanel' -type BackupRepo_CreatePanel_Call struct { - *mock.Call -} - -// CreatePanel is a helper method to define mock.On call -func (_e *BackupRepo_Expecter) CreatePanel() *BackupRepo_CreatePanel_Call { - return &BackupRepo_CreatePanel_Call{Call: _e.mock.On("CreatePanel")} -} - -func (_c *BackupRepo_CreatePanel_Call) Run(run func()) *BackupRepo_CreatePanel_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *BackupRepo_CreatePanel_Call) Return(err error) *BackupRepo_CreatePanel_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupRepo_CreatePanel_Call) RunAndReturn(run func() error) *BackupRepo_CreatePanel_Call { - _c.Call.Return(run) - return _c -} - -// CutoffLog provides a mock function for the type BackupRepo -func (_mock *BackupRepo) CutoffLog(path string, target string) (string, error) { - ret := _mock.Called(path, target) - - if len(ret) == 0 { - panic("no return value specified for CutoffLog") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string) (string, error)); ok { - return returnFunc(path, target) - } - if returnFunc, ok := ret.Get(0).(func(string, string) string); ok { - r0 = returnFunc(path, target) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(string, string) error); ok { - r1 = returnFunc(path, target) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// BackupRepo_CutoffLog_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CutoffLog' -type BackupRepo_CutoffLog_Call struct { - *mock.Call -} - -// CutoffLog is a helper method to define mock.On call -// - path string -// - target string -func (_e *BackupRepo_Expecter) CutoffLog(path any, target any) *BackupRepo_CutoffLog_Call { - return &BackupRepo_CutoffLog_Call{Call: _e.mock.On("CutoffLog", path, target)} -} - -func (_c *BackupRepo_CutoffLog_Call) Run(run func(path string, target string)) *BackupRepo_CutoffLog_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *BackupRepo_CutoffLog_Call) Return(s string, err error) *BackupRepo_CutoffLog_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *BackupRepo_CutoffLog_Call) RunAndReturn(run func(path string, target string) (string, error)) *BackupRepo_CutoffLog_Call { - _c.Call.Return(run) - return _c -} - -// CutoffUpload provides a mock function for the type BackupRepo -func (_mock *BackupRepo) CutoffUpload(account uint, typ biz.BackupType, name string, files []string) error { - ret := _mock.Called(account, typ, name, files) - - if len(ret) == 0 { - panic("no return value specified for CutoffUpload") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, biz.BackupType, string, []string) error); ok { - r0 = returnFunc(account, typ, name, files) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupRepo_CutoffUpload_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CutoffUpload' -type BackupRepo_CutoffUpload_Call struct { - *mock.Call -} - -// CutoffUpload is a helper method to define mock.On call -// - account uint -// - typ biz.BackupType -// - name string -// - files []string -func (_e *BackupRepo_Expecter) CutoffUpload(account any, typ any, name any, files any) *BackupRepo_CutoffUpload_Call { - return &BackupRepo_CutoffUpload_Call{Call: _e.mock.On("CutoffUpload", account, typ, name, files)} -} - -func (_c *BackupRepo_CutoffUpload_Call) Run(run func(account uint, typ biz.BackupType, name string, files []string)) *BackupRepo_CutoffUpload_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 biz.BackupType - if args[1] != nil { - arg1 = args[1].(biz.BackupType) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 []string - if args[3] != nil { - arg3 = args[3].([]string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *BackupRepo_CutoffUpload_Call) Return(err error) *BackupRepo_CutoffUpload_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupRepo_CutoffUpload_Call) RunAndReturn(run func(account uint, typ biz.BackupType, name string, files []string) error) *BackupRepo_CutoffUpload_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type BackupRepo -func (_mock *BackupRepo) Delete(typ biz.BackupType, name string) error { - ret := _mock.Called(typ, name) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(biz.BackupType, string) error); ok { - r0 = returnFunc(typ, name) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type BackupRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - typ biz.BackupType -// - name string -func (_e *BackupRepo_Expecter) Delete(typ any, name any) *BackupRepo_Delete_Call { - return &BackupRepo_Delete_Call{Call: _e.mock.On("Delete", typ, name)} -} - -func (_c *BackupRepo_Delete_Call) Run(run func(typ biz.BackupType, name string)) *BackupRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.BackupType - if args[0] != nil { - arg0 = args[0].(biz.BackupType) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *BackupRepo_Delete_Call) Return(err error) *BackupRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupRepo_Delete_Call) RunAndReturn(run func(typ biz.BackupType, name string) error) *BackupRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// FixPanel provides a mock function for the type BackupRepo -func (_mock *BackupRepo) FixPanel() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for FixPanel") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupRepo_FixPanel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FixPanel' -type BackupRepo_FixPanel_Call struct { - *mock.Call -} - -// FixPanel is a helper method to define mock.On call -func (_e *BackupRepo_Expecter) FixPanel() *BackupRepo_FixPanel_Call { - return &BackupRepo_FixPanel_Call{Call: _e.mock.On("FixPanel")} -} - -func (_c *BackupRepo_FixPanel_Call) Run(run func()) *BackupRepo_FixPanel_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *BackupRepo_FixPanel_Call) Return(err error) *BackupRepo_FixPanel_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupRepo_FixPanel_Call) RunAndReturn(run func() error) *BackupRepo_FixPanel_Call { - _c.Call.Return(run) - return _c -} - -// GetDefaultPath provides a mock function for the type BackupRepo -func (_mock *BackupRepo) GetDefaultPath(typ biz.BackupType) string { - ret := _mock.Called(typ) - - if len(ret) == 0 { - panic("no return value specified for GetDefaultPath") - } - - var r0 string - if returnFunc, ok := ret.Get(0).(func(biz.BackupType) string); ok { - r0 = returnFunc(typ) - } else { - r0 = ret.Get(0).(string) - } - return r0 -} - -// BackupRepo_GetDefaultPath_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDefaultPath' -type BackupRepo_GetDefaultPath_Call struct { - *mock.Call -} - -// GetDefaultPath is a helper method to define mock.On call -// - typ biz.BackupType -func (_e *BackupRepo_Expecter) GetDefaultPath(typ any) *BackupRepo_GetDefaultPath_Call { - return &BackupRepo_GetDefaultPath_Call{Call: _e.mock.On("GetDefaultPath", typ)} -} - -func (_c *BackupRepo_GetDefaultPath_Call) Run(run func(typ biz.BackupType)) *BackupRepo_GetDefaultPath_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.BackupType - if args[0] != nil { - arg0 = args[0].(biz.BackupType) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *BackupRepo_GetDefaultPath_Call) Return(s string) *BackupRepo_GetDefaultPath_Call { - _c.Call.Return(s) - return _c -} - -func (_c *BackupRepo_GetDefaultPath_Call) RunAndReturn(run func(typ biz.BackupType) string) *BackupRepo_GetDefaultPath_Call { - _c.Call.Return(run) - return _c -} - -// GetStorage provides a mock function for the type BackupRepo -func (_mock *BackupRepo) GetStorage(id uint) (*biz.BackupStorage, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for GetStorage") - } - - var r0 *biz.BackupStorage - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.BackupStorage, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.BackupStorage); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.BackupStorage) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// BackupRepo_GetStorage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStorage' -type BackupRepo_GetStorage_Call struct { - *mock.Call -} - -// GetStorage is a helper method to define mock.On call -// - id uint -func (_e *BackupRepo_Expecter) GetStorage(id any) *BackupRepo_GetStorage_Call { - return &BackupRepo_GetStorage_Call{Call: _e.mock.On("GetStorage", id)} -} - -func (_c *BackupRepo_GetStorage_Call) Run(run func(id uint)) *BackupRepo_GetStorage_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *BackupRepo_GetStorage_Call) Return(backupStorage *biz.BackupStorage, err error) *BackupRepo_GetStorage_Call { - _c.Call.Return(backupStorage, err) - return _c -} - -func (_c *BackupRepo_GetStorage_Call) RunAndReturn(run func(id uint) (*biz.BackupStorage, error)) *BackupRepo_GetStorage_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type BackupRepo -func (_mock *BackupRepo) List(typ biz.BackupType) ([]*types.BackupFile, error) { - ret := _mock.Called(typ) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*types.BackupFile - var r1 error - if returnFunc, ok := ret.Get(0).(func(biz.BackupType) ([]*types.BackupFile, error)); ok { - return returnFunc(typ) - } - if returnFunc, ok := ret.Get(0).(func(biz.BackupType) []*types.BackupFile); ok { - r0 = returnFunc(typ) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*types.BackupFile) - } - } - if returnFunc, ok := ret.Get(1).(func(biz.BackupType) error); ok { - r1 = returnFunc(typ) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// BackupRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type BackupRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - typ biz.BackupType -func (_e *BackupRepo_Expecter) List(typ any) *BackupRepo_List_Call { - return &BackupRepo_List_Call{Call: _e.mock.On("List", typ)} -} - -func (_c *BackupRepo_List_Call) Run(run func(typ biz.BackupType)) *BackupRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.BackupType - if args[0] != nil { - arg0 = args[0].(biz.BackupType) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *BackupRepo_List_Call) Return(backupFiles []*types.BackupFile, err error) *BackupRepo_List_Call { - _c.Call.Return(backupFiles, err) - return _c -} - -func (_c *BackupRepo_List_Call) RunAndReturn(run func(typ biz.BackupType) ([]*types.BackupFile, error)) *BackupRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// Restore provides a mock function for the type BackupRepo -func (_mock *BackupRepo) Restore(typ biz.BackupType, backup string, target string) error { - ret := _mock.Called(typ, backup, target) - - if len(ret) == 0 { - panic("no return value specified for Restore") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(biz.BackupType, string, string) error); ok { - r0 = returnFunc(typ, backup, target) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupRepo_Restore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Restore' -type BackupRepo_Restore_Call struct { - *mock.Call -} - -// Restore is a helper method to define mock.On call -// - typ biz.BackupType -// - backup string -// - target string -func (_e *BackupRepo_Expecter) Restore(typ any, backup any, target any) *BackupRepo_Restore_Call { - return &BackupRepo_Restore_Call{Call: _e.mock.On("Restore", typ, backup, target)} -} - -func (_c *BackupRepo_Restore_Call) Run(run func(typ biz.BackupType, backup string, target string)) *BackupRepo_Restore_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.BackupType - if args[0] != nil { - arg0 = args[0].(biz.BackupType) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *BackupRepo_Restore_Call) Return(err error) *BackupRepo_Restore_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupRepo_Restore_Call) RunAndReturn(run func(typ biz.BackupType, backup string, target string) error) *BackupRepo_Restore_Call { - _c.Call.Return(run) - return _c -} - -// UpdatePanel provides a mock function for the type BackupRepo -func (_mock *BackupRepo) UpdatePanel(version string, url string, checksum string, progress func(string)) error { - ret := _mock.Called(version, url, checksum, progress) - - if len(ret) == 0 { - panic("no return value specified for UpdatePanel") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string, string, func(string)) error); ok { - r0 = returnFunc(version, url, checksum, progress) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// BackupRepo_UpdatePanel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdatePanel' -type BackupRepo_UpdatePanel_Call struct { - *mock.Call -} - -// UpdatePanel is a helper method to define mock.On call -// - version string -// - url string -// - checksum string -// - progress func(string) -func (_e *BackupRepo_Expecter) UpdatePanel(version any, url any, checksum any, progress any) *BackupRepo_UpdatePanel_Call { - return &BackupRepo_UpdatePanel_Call{Call: _e.mock.On("UpdatePanel", version, url, checksum, progress)} -} - -func (_c *BackupRepo_UpdatePanel_Call) Run(run func(version string, url string, checksum string, progress func(string))) *BackupRepo_UpdatePanel_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 func(string) - if args[3] != nil { - arg3 = args[3].(func(string)) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *BackupRepo_UpdatePanel_Call) Return(err error) *BackupRepo_UpdatePanel_Call { - _c.Call.Return(err) - return _c -} - -func (_c *BackupRepo_UpdatePanel_Call) RunAndReturn(run func(version string, url string, checksum string, progress func(string)) error) *BackupRepo_UpdatePanel_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/CacheRepo.go b/mocks/biz/CacheRepo.go deleted file mode 100644 index 7c02a9af8..000000000 --- a/mocks/biz/CacheRepo.go +++ /dev/null @@ -1,399 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/pkg/api" - mock "github.com/stretchr/testify/mock" -) - -// NewCacheRepo creates a new instance of CacheRepo. 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 NewCacheRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *CacheRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &CacheRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// CacheRepo is an autogenerated mock type for the CacheRepo type -type CacheRepo struct { - mock.Mock -} - -type CacheRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *CacheRepo) EXPECT() *CacheRepo_Expecter { - return &CacheRepo_Expecter{mock: &_m.Mock} -} - -// FetchApps provides a mock function for the type CacheRepo -func (_mock *CacheRepo) FetchApps() (*api.Apps, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for FetchApps") - } - - var r0 *api.Apps - var r1 error - if returnFunc, ok := ret.Get(0).(func() (*api.Apps, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() *api.Apps); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*api.Apps) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CacheRepo_FetchApps_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FetchApps' -type CacheRepo_FetchApps_Call struct { - *mock.Call -} - -// FetchApps is a helper method to define mock.On call -func (_e *CacheRepo_Expecter) FetchApps() *CacheRepo_FetchApps_Call { - return &CacheRepo_FetchApps_Call{Call: _e.mock.On("FetchApps")} -} - -func (_c *CacheRepo_FetchApps_Call) Run(run func()) *CacheRepo_FetchApps_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *CacheRepo_FetchApps_Call) Return(apps *api.Apps, err error) *CacheRepo_FetchApps_Call { - _c.Call.Return(apps, err) - return _c -} - -func (_c *CacheRepo_FetchApps_Call) RunAndReturn(run func() (*api.Apps, error)) *CacheRepo_FetchApps_Call { - _c.Call.Return(run) - return _c -} - -// FetchCategories provides a mock function for the type CacheRepo -func (_mock *CacheRepo) FetchCategories() (*api.Categories, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for FetchCategories") - } - - var r0 *api.Categories - var r1 error - if returnFunc, ok := ret.Get(0).(func() (*api.Categories, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() *api.Categories); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*api.Categories) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CacheRepo_FetchCategories_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FetchCategories' -type CacheRepo_FetchCategories_Call struct { - *mock.Call -} - -// FetchCategories is a helper method to define mock.On call -func (_e *CacheRepo_Expecter) FetchCategories() *CacheRepo_FetchCategories_Call { - return &CacheRepo_FetchCategories_Call{Call: _e.mock.On("FetchCategories")} -} - -func (_c *CacheRepo_FetchCategories_Call) Run(run func()) *CacheRepo_FetchCategories_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *CacheRepo_FetchCategories_Call) Return(categories *api.Categories, err error) *CacheRepo_FetchCategories_Call { - _c.Call.Return(categories, err) - return _c -} - -func (_c *CacheRepo_FetchCategories_Call) RunAndReturn(run func() (*api.Categories, error)) *CacheRepo_FetchCategories_Call { - _c.Call.Return(run) - return _c -} - -// FetchEnvironments provides a mock function for the type CacheRepo -func (_mock *CacheRepo) FetchEnvironments() (*api.Environments, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for FetchEnvironments") - } - - var r0 *api.Environments - var r1 error - if returnFunc, ok := ret.Get(0).(func() (*api.Environments, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() *api.Environments); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*api.Environments) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CacheRepo_FetchEnvironments_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FetchEnvironments' -type CacheRepo_FetchEnvironments_Call struct { - *mock.Call -} - -// FetchEnvironments is a helper method to define mock.On call -func (_e *CacheRepo_Expecter) FetchEnvironments() *CacheRepo_FetchEnvironments_Call { - return &CacheRepo_FetchEnvironments_Call{Call: _e.mock.On("FetchEnvironments")} -} - -func (_c *CacheRepo_FetchEnvironments_Call) Run(run func()) *CacheRepo_FetchEnvironments_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *CacheRepo_FetchEnvironments_Call) Return(environments *api.Environments, err error) *CacheRepo_FetchEnvironments_Call { - _c.Call.Return(environments, err) - return _c -} - -func (_c *CacheRepo_FetchEnvironments_Call) RunAndReturn(run func() (*api.Environments, error)) *CacheRepo_FetchEnvironments_Call { - _c.Call.Return(run) - return _c -} - -// FetchTemplates provides a mock function for the type CacheRepo -func (_mock *CacheRepo) FetchTemplates() (*api.Templates, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for FetchTemplates") - } - - var r0 *api.Templates - var r1 error - if returnFunc, ok := ret.Get(0).(func() (*api.Templates, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() *api.Templates); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*api.Templates) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CacheRepo_FetchTemplates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FetchTemplates' -type CacheRepo_FetchTemplates_Call struct { - *mock.Call -} - -// FetchTemplates is a helper method to define mock.On call -func (_e *CacheRepo_Expecter) FetchTemplates() *CacheRepo_FetchTemplates_Call { - return &CacheRepo_FetchTemplates_Call{Call: _e.mock.On("FetchTemplates")} -} - -func (_c *CacheRepo_FetchTemplates_Call) Run(run func()) *CacheRepo_FetchTemplates_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *CacheRepo_FetchTemplates_Call) Return(templates *api.Templates, err error) *CacheRepo_FetchTemplates_Call { - _c.Call.Return(templates, err) - return _c -} - -func (_c *CacheRepo_FetchTemplates_Call) RunAndReturn(run func() (*api.Templates, error)) *CacheRepo_FetchTemplates_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type CacheRepo -func (_mock *CacheRepo) Get(key biz.CacheKey, defaultValue ...string) (string, error) { - var tmpRet mock.Arguments - if len(defaultValue) > 0 { - tmpRet = _mock.Called(key, defaultValue) - } else { - tmpRet = _mock.Called(key) - } - ret := tmpRet - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(biz.CacheKey, ...string) (string, error)); ok { - return returnFunc(key, defaultValue...) - } - if returnFunc, ok := ret.Get(0).(func(biz.CacheKey, ...string) string); ok { - r0 = returnFunc(key, defaultValue...) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(biz.CacheKey, ...string) error); ok { - r1 = returnFunc(key, defaultValue...) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CacheRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type CacheRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - key biz.CacheKey -// - defaultValue ...string -func (_e *CacheRepo_Expecter) Get(key any, defaultValue ...any) *CacheRepo_Get_Call { - return &CacheRepo_Get_Call{Call: _e.mock.On("Get", - append([]any{key}, defaultValue...)...)} -} - -func (_c *CacheRepo_Get_Call) Run(run func(key biz.CacheKey, defaultValue ...string)) *CacheRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.CacheKey - if args[0] != nil { - arg0 = args[0].(biz.CacheKey) - } - var arg1 []string - var variadicArgs []string - if len(args) > 1 { - variadicArgs = args[1].([]string) - } - arg1 = variadicArgs - run( - arg0, - arg1..., - ) - }) - return _c -} - -func (_c *CacheRepo_Get_Call) Return(s string, err error) *CacheRepo_Get_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *CacheRepo_Get_Call) RunAndReturn(run func(key biz.CacheKey, defaultValue ...string) (string, error)) *CacheRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// Set provides a mock function for the type CacheRepo -func (_mock *CacheRepo) Set(key biz.CacheKey, value string) error { - ret := _mock.Called(key, value) - - if len(ret) == 0 { - panic("no return value specified for Set") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(biz.CacheKey, string) error); ok { - r0 = returnFunc(key, value) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CacheRepo_Set_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Set' -type CacheRepo_Set_Call struct { - *mock.Call -} - -// Set is a helper method to define mock.On call -// - key biz.CacheKey -// - value string -func (_e *CacheRepo_Expecter) Set(key any, value any) *CacheRepo_Set_Call { - return &CacheRepo_Set_Call{Call: _e.mock.On("Set", key, value)} -} - -func (_c *CacheRepo_Set_Call) Run(run func(key biz.CacheKey, value string)) *CacheRepo_Set_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.CacheKey - if args[0] != nil { - arg0 = args[0].(biz.CacheKey) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *CacheRepo_Set_Call) Return(err error) *CacheRepo_Set_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CacheRepo_Set_Call) RunAndReturn(run func(key biz.CacheKey, value string) error) *CacheRepo_Set_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/CertAccountRepo.go b/mocks/biz/CertAccountRepo.go deleted file mode 100644 index 7ee1982d2..000000000 --- a/mocks/biz/CertAccountRepo.go +++ /dev/null @@ -1,601 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/pkg/acme" - mock "github.com/stretchr/testify/mock" -) - -// NewCertAccountRepo creates a new instance of CertAccountRepo. 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 NewCertAccountRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *CertAccountRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &CertAccountRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// CertAccountRepo is an autogenerated mock type for the CertAccountRepo type -type CertAccountRepo struct { - mock.Mock -} - -type CertAccountRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *CertAccountRepo) EXPECT() *CertAccountRepo_Expecter { - return &CertAccountRepo_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function for the type CertAccountRepo -func (_mock *CertAccountRepo) Create(account *biz.CertAccount) error { - ret := _mock.Called(account) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.CertAccount) error); ok { - r0 = returnFunc(account) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertAccountRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type CertAccountRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - account *biz.CertAccount -func (_e *CertAccountRepo_Expecter) Create(account any) *CertAccountRepo_Create_Call { - return &CertAccountRepo_Create_Call{Call: _e.mock.On("Create", account)} -} - -func (_c *CertAccountRepo_Create_Call) Run(run func(account *biz.CertAccount)) *CertAccountRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.CertAccount - if args[0] != nil { - arg0 = args[0].(*biz.CertAccount) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertAccountRepo_Create_Call) Return(err error) *CertAccountRepo_Create_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertAccountRepo_Create_Call) RunAndReturn(run func(account *biz.CertAccount) error) *CertAccountRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type CertAccountRepo -func (_mock *CertAccountRepo) Delete(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertAccountRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type CertAccountRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *CertAccountRepo_Expecter) Delete(id any) *CertAccountRepo_Delete_Call { - return &CertAccountRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *CertAccountRepo_Delete_Call) Run(run func(id uint)) *CertAccountRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertAccountRepo_Delete_Call) Return(err error) *CertAccountRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertAccountRepo_Delete_Call) RunAndReturn(run func(id uint) error) *CertAccountRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type CertAccountRepo -func (_mock *CertAccountRepo) Get(id uint) (*biz.CertAccount, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.CertAccount - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.CertAccount, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.CertAccount); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.CertAccount) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertAccountRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type CertAccountRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *CertAccountRepo_Expecter) Get(id any) *CertAccountRepo_Get_Call { - return &CertAccountRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *CertAccountRepo_Get_Call) Run(run func(id uint)) *CertAccountRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertAccountRepo_Get_Call) Return(certAccount *biz.CertAccount, err error) *CertAccountRepo_Get_Call { - _c.Call.Return(certAccount, err) - return _c -} - -func (_c *CertAccountRepo_Get_Call) RunAndReturn(run func(id uint) (*biz.CertAccount, error)) *CertAccountRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// GetByCAEmail provides a mock function for the type CertAccountRepo -func (_mock *CertAccountRepo) GetByCAEmail(ca string, email string) (*biz.CertAccount, error) { - ret := _mock.Called(ca, email) - - if len(ret) == 0 { - panic("no return value specified for GetByCAEmail") - } - - var r0 *biz.CertAccount - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string) (*biz.CertAccount, error)); ok { - return returnFunc(ca, email) - } - if returnFunc, ok := ret.Get(0).(func(string, string) *biz.CertAccount); ok { - r0 = returnFunc(ca, email) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.CertAccount) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string) error); ok { - r1 = returnFunc(ca, email) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertAccountRepo_GetByCAEmail_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByCAEmail' -type CertAccountRepo_GetByCAEmail_Call struct { - *mock.Call -} - -// GetByCAEmail is a helper method to define mock.On call -// - ca string -// - email string -func (_e *CertAccountRepo_Expecter) GetByCAEmail(ca any, email any) *CertAccountRepo_GetByCAEmail_Call { - return &CertAccountRepo_GetByCAEmail_Call{Call: _e.mock.On("GetByCAEmail", ca, email)} -} - -func (_c *CertAccountRepo_GetByCAEmail_Call) Run(run func(ca string, email string)) *CertAccountRepo_GetByCAEmail_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *CertAccountRepo_GetByCAEmail_Call) Return(certAccount *biz.CertAccount, err error) *CertAccountRepo_GetByCAEmail_Call { - _c.Call.Return(certAccount, err) - return _c -} - -func (_c *CertAccountRepo_GetByCAEmail_Call) RunAndReturn(run func(ca string, email string) (*biz.CertAccount, error)) *CertAccountRepo_GetByCAEmail_Call { - _c.Call.Return(run) - return _c -} - -// GetGoogleEAB provides a mock function for the type CertAccountRepo -func (_mock *CertAccountRepo) GetGoogleEAB() (*acme.EAB, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for GetGoogleEAB") - } - - var r0 *acme.EAB - var r1 error - if returnFunc, ok := ret.Get(0).(func() (*acme.EAB, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() *acme.EAB); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*acme.EAB) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertAccountRepo_GetGoogleEAB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetGoogleEAB' -type CertAccountRepo_GetGoogleEAB_Call struct { - *mock.Call -} - -// GetGoogleEAB is a helper method to define mock.On call -func (_e *CertAccountRepo_Expecter) GetGoogleEAB() *CertAccountRepo_GetGoogleEAB_Call { - return &CertAccountRepo_GetGoogleEAB_Call{Call: _e.mock.On("GetGoogleEAB")} -} - -func (_c *CertAccountRepo_GetGoogleEAB_Call) Run(run func()) *CertAccountRepo_GetGoogleEAB_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *CertAccountRepo_GetGoogleEAB_Call) Return(eAB *acme.EAB, err error) *CertAccountRepo_GetGoogleEAB_Call { - _c.Call.Return(eAB, err) - return _c -} - -func (_c *CertAccountRepo_GetGoogleEAB_Call) RunAndReturn(run func() (*acme.EAB, error)) *CertAccountRepo_GetGoogleEAB_Call { - _c.Call.Return(run) - return _c -} - -// GetZeroSSLEAB provides a mock function for the type CertAccountRepo -func (_mock *CertAccountRepo) GetZeroSSLEAB(email string) (*acme.EAB, error) { - ret := _mock.Called(email) - - if len(ret) == 0 { - panic("no return value specified for GetZeroSSLEAB") - } - - var r0 *acme.EAB - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) (*acme.EAB, error)); ok { - return returnFunc(email) - } - if returnFunc, ok := ret.Get(0).(func(string) *acme.EAB); ok { - r0 = returnFunc(email) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*acme.EAB) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(email) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertAccountRepo_GetZeroSSLEAB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetZeroSSLEAB' -type CertAccountRepo_GetZeroSSLEAB_Call struct { - *mock.Call -} - -// GetZeroSSLEAB is a helper method to define mock.On call -// - email string -func (_e *CertAccountRepo_Expecter) GetZeroSSLEAB(email any) *CertAccountRepo_GetZeroSSLEAB_Call { - return &CertAccountRepo_GetZeroSSLEAB_Call{Call: _e.mock.On("GetZeroSSLEAB", email)} -} - -func (_c *CertAccountRepo_GetZeroSSLEAB_Call) Run(run func(email string)) *CertAccountRepo_GetZeroSSLEAB_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertAccountRepo_GetZeroSSLEAB_Call) Return(eAB *acme.EAB, err error) *CertAccountRepo_GetZeroSSLEAB_Call { - _c.Call.Return(eAB, err) - return _c -} - -func (_c *CertAccountRepo_GetZeroSSLEAB_Call) RunAndReturn(run func(email string) (*acme.EAB, error)) *CertAccountRepo_GetZeroSSLEAB_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type CertAccountRepo -func (_mock *CertAccountRepo) List(page uint, limit uint) ([]*biz.CertAccount, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.CertAccount - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.CertAccount, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.CertAccount); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.CertAccount) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// CertAccountRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type CertAccountRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *CertAccountRepo_Expecter) List(page any, limit any) *CertAccountRepo_List_Call { - return &CertAccountRepo_List_Call{Call: _e.mock.On("List", page, limit)} -} - -func (_c *CertAccountRepo_List_Call) Run(run func(page uint, limit uint)) *CertAccountRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *CertAccountRepo_List_Call) Return(certAccounts []*biz.CertAccount, n int64, err error) *CertAccountRepo_List_Call { - _c.Call.Return(certAccounts, n, err) - return _c -} - -func (_c *CertAccountRepo_List_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.CertAccount, int64, error)) *CertAccountRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// RegisterAccount provides a mock function for the type CertAccountRepo -func (_mock *CertAccountRepo) RegisterAccount(email string, ca string, eab *acme.EAB, keyType acme.KeyType) (*acme.Client, error) { - ret := _mock.Called(email, ca, eab, keyType) - - if len(ret) == 0 { - panic("no return value specified for RegisterAccount") - } - - var r0 *acme.Client - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, *acme.EAB, acme.KeyType) (*acme.Client, error)); ok { - return returnFunc(email, ca, eab, keyType) - } - if returnFunc, ok := ret.Get(0).(func(string, string, *acme.EAB, acme.KeyType) *acme.Client); ok { - r0 = returnFunc(email, ca, eab, keyType) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*acme.Client) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, *acme.EAB, acme.KeyType) error); ok { - r1 = returnFunc(email, ca, eab, keyType) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertAccountRepo_RegisterAccount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RegisterAccount' -type CertAccountRepo_RegisterAccount_Call struct { - *mock.Call -} - -// RegisterAccount is a helper method to define mock.On call -// - email string -// - ca string -// - eab *acme.EAB -// - keyType acme.KeyType -func (_e *CertAccountRepo_Expecter) RegisterAccount(email any, ca any, eab any, keyType any) *CertAccountRepo_RegisterAccount_Call { - return &CertAccountRepo_RegisterAccount_Call{Call: _e.mock.On("RegisterAccount", email, ca, eab, keyType)} -} - -func (_c *CertAccountRepo_RegisterAccount_Call) Run(run func(email string, ca string, eab *acme.EAB, keyType acme.KeyType)) *CertAccountRepo_RegisterAccount_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 *acme.EAB - if args[2] != nil { - arg2 = args[2].(*acme.EAB) - } - var arg3 acme.KeyType - if args[3] != nil { - arg3 = args[3].(acme.KeyType) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *CertAccountRepo_RegisterAccount_Call) Return(client *acme.Client, err error) *CertAccountRepo_RegisterAccount_Call { - _c.Call.Return(client, err) - return _c -} - -func (_c *CertAccountRepo_RegisterAccount_Call) RunAndReturn(run func(email string, ca string, eab *acme.EAB, keyType acme.KeyType) (*acme.Client, error)) *CertAccountRepo_RegisterAccount_Call { - _c.Call.Return(run) - return _c -} - -// Save provides a mock function for the type CertAccountRepo -func (_mock *CertAccountRepo) Save(account *biz.CertAccount) error { - ret := _mock.Called(account) - - if len(ret) == 0 { - panic("no return value specified for Save") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.CertAccount) error); ok { - r0 = returnFunc(account) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertAccountRepo_Save_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Save' -type CertAccountRepo_Save_Call struct { - *mock.Call -} - -// Save is a helper method to define mock.On call -// - account *biz.CertAccount -func (_e *CertAccountRepo_Expecter) Save(account any) *CertAccountRepo_Save_Call { - return &CertAccountRepo_Save_Call{Call: _e.mock.On("Save", account)} -} - -func (_c *CertAccountRepo_Save_Call) Run(run func(account *biz.CertAccount)) *CertAccountRepo_Save_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.CertAccount - if args[0] != nil { - arg0 = args[0].(*biz.CertAccount) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertAccountRepo_Save_Call) Return(err error) *CertAccountRepo_Save_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertAccountRepo_Save_Call) RunAndReturn(run func(account *biz.CertAccount) error) *CertAccountRepo_Save_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/CertDNSRepo.go b/mocks/biz/CertDNSRepo.go deleted file mode 100644 index 9af86ac3a..000000000 --- a/mocks/biz/CertDNSRepo.go +++ /dev/null @@ -1,347 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/internal/request" - mock "github.com/stretchr/testify/mock" -) - -// NewCertDNSRepo creates a new instance of CertDNSRepo. 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 NewCertDNSRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *CertDNSRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &CertDNSRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// CertDNSRepo is an autogenerated mock type for the CertDNSRepo type -type CertDNSRepo struct { - mock.Mock -} - -type CertDNSRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *CertDNSRepo) EXPECT() *CertDNSRepo_Expecter { - return &CertDNSRepo_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function for the type CertDNSRepo -func (_mock *CertDNSRepo) Create(req *request.CertDNSCreate) (*biz.CertDNS, error) { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *biz.CertDNS - var r1 error - if returnFunc, ok := ret.Get(0).(func(*request.CertDNSCreate) (*biz.CertDNS, error)); ok { - return returnFunc(req) - } - if returnFunc, ok := ret.Get(0).(func(*request.CertDNSCreate) *biz.CertDNS); ok { - r0 = returnFunc(req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.CertDNS) - } - } - if returnFunc, ok := ret.Get(1).(func(*request.CertDNSCreate) error); ok { - r1 = returnFunc(req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertDNSRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type CertDNSRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - req *request.CertDNSCreate -func (_e *CertDNSRepo_Expecter) Create(req any) *CertDNSRepo_Create_Call { - return &CertDNSRepo_Create_Call{Call: _e.mock.On("Create", req)} -} - -func (_c *CertDNSRepo_Create_Call) Run(run func(req *request.CertDNSCreate)) *CertDNSRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.CertDNSCreate - if args[0] != nil { - arg0 = args[0].(*request.CertDNSCreate) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertDNSRepo_Create_Call) Return(certDNS *biz.CertDNS, err error) *CertDNSRepo_Create_Call { - _c.Call.Return(certDNS, err) - return _c -} - -func (_c *CertDNSRepo_Create_Call) RunAndReturn(run func(req *request.CertDNSCreate) (*biz.CertDNS, error)) *CertDNSRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type CertDNSRepo -func (_mock *CertDNSRepo) Delete(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertDNSRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type CertDNSRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *CertDNSRepo_Expecter) Delete(id any) *CertDNSRepo_Delete_Call { - return &CertDNSRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *CertDNSRepo_Delete_Call) Run(run func(id uint)) *CertDNSRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertDNSRepo_Delete_Call) Return(err error) *CertDNSRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertDNSRepo_Delete_Call) RunAndReturn(run func(id uint) error) *CertDNSRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type CertDNSRepo -func (_mock *CertDNSRepo) Get(id uint) (*biz.CertDNS, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.CertDNS - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.CertDNS, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.CertDNS); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.CertDNS) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertDNSRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type CertDNSRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *CertDNSRepo_Expecter) Get(id any) *CertDNSRepo_Get_Call { - return &CertDNSRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *CertDNSRepo_Get_Call) Run(run func(id uint)) *CertDNSRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertDNSRepo_Get_Call) Return(certDNS *biz.CertDNS, err error) *CertDNSRepo_Get_Call { - _c.Call.Return(certDNS, err) - return _c -} - -func (_c *CertDNSRepo_Get_Call) RunAndReturn(run func(id uint) (*biz.CertDNS, error)) *CertDNSRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type CertDNSRepo -func (_mock *CertDNSRepo) List(page uint, limit uint) ([]*biz.CertDNS, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.CertDNS - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.CertDNS, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.CertDNS); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.CertDNS) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// CertDNSRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type CertDNSRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *CertDNSRepo_Expecter) List(page any, limit any) *CertDNSRepo_List_Call { - return &CertDNSRepo_List_Call{Call: _e.mock.On("List", page, limit)} -} - -func (_c *CertDNSRepo_List_Call) Run(run func(page uint, limit uint)) *CertDNSRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *CertDNSRepo_List_Call) Return(certDNSs []*biz.CertDNS, n int64, err error) *CertDNSRepo_List_Call { - _c.Call.Return(certDNSs, n, err) - return _c -} - -func (_c *CertDNSRepo_List_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.CertDNS, int64, error)) *CertDNSRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function for the type CertDNSRepo -func (_mock *CertDNSRepo) Update(req *request.CertDNSUpdate) error { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*request.CertDNSUpdate) error); ok { - r0 = returnFunc(req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertDNSRepo_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type CertDNSRepo_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - req *request.CertDNSUpdate -func (_e *CertDNSRepo_Expecter) Update(req any) *CertDNSRepo_Update_Call { - return &CertDNSRepo_Update_Call{Call: _e.mock.On("Update", req)} -} - -func (_c *CertDNSRepo_Update_Call) Run(run func(req *request.CertDNSUpdate)) *CertDNSRepo_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.CertDNSUpdate - if args[0] != nil { - arg0 = args[0].(*request.CertDNSUpdate) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertDNSRepo_Update_Call) Return(err error) *CertDNSRepo_Update_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertDNSRepo_Update_Call) RunAndReturn(run func(req *request.CertDNSUpdate) error) *CertDNSRepo_Update_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/CertRepo.go b/mocks/biz/CertRepo.go deleted file mode 100644 index 4a8f22fa5..000000000 --- a/mocks/biz/CertRepo.go +++ /dev/null @@ -1,1162 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/acme" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewCertRepo creates a new instance of CertRepo. 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 NewCertRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *CertRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &CertRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// CertRepo is an autogenerated mock type for the CertRepo type -type CertRepo struct { - mock.Mock -} - -type CertRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *CertRepo) EXPECT() *CertRepo_Expecter { - return &CertRepo_Expecter{mock: &_m.Mock} -} - -// BindWebsites provides a mock function for the type CertRepo -func (_mock *CertRepo) BindWebsites(certID uint, websiteIDs []uint) error { - ret := _mock.Called(certID, websiteIDs) - - if len(ret) == 0 { - panic("no return value specified for BindWebsites") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, []uint) error); ok { - r0 = returnFunc(certID, websiteIDs) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertRepo_BindWebsites_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BindWebsites' -type CertRepo_BindWebsites_Call struct { - *mock.Call -} - -// BindWebsites is a helper method to define mock.On call -// - certID uint -// - websiteIDs []uint -func (_e *CertRepo_Expecter) BindWebsites(certID any, websiteIDs any) *CertRepo_BindWebsites_Call { - return &CertRepo_BindWebsites_Call{Call: _e.mock.On("BindWebsites", certID, websiteIDs)} -} - -func (_c *CertRepo_BindWebsites_Call) Run(run func(certID uint, websiteIDs []uint)) *CertRepo_BindWebsites_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 []uint - if args[1] != nil { - arg1 = args[1].([]uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *CertRepo_BindWebsites_Call) Return(err error) *CertRepo_BindWebsites_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertRepo_BindWebsites_Call) RunAndReturn(run func(certID uint, websiteIDs []uint) error) *CertRepo_BindWebsites_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function for the type CertRepo -func (_mock *CertRepo) Create(req *request.CertCreate) (*biz.Cert, error) { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *biz.Cert - var r1 error - if returnFunc, ok := ret.Get(0).(func(*request.CertCreate) (*biz.Cert, error)); ok { - return returnFunc(req) - } - if returnFunc, ok := ret.Get(0).(func(*request.CertCreate) *biz.Cert); ok { - r0 = returnFunc(req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.Cert) - } - } - if returnFunc, ok := ret.Get(1).(func(*request.CertCreate) error); ok { - r1 = returnFunc(req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type CertRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - req *request.CertCreate -func (_e *CertRepo_Expecter) Create(req any) *CertRepo_Create_Call { - return &CertRepo_Create_Call{Call: _e.mock.On("Create", req)} -} - -func (_c *CertRepo_Create_Call) Run(run func(req *request.CertCreate)) *CertRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.CertCreate - if args[0] != nil { - arg0 = args[0].(*request.CertCreate) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_Create_Call) Return(cert *biz.Cert, err error) *CertRepo_Create_Call { - _c.Call.Return(cert, err) - return _c -} - -func (_c *CertRepo_Create_Call) RunAndReturn(run func(req *request.CertCreate) (*biz.Cert, error)) *CertRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// CreateUploaded provides a mock function for the type CertRepo -func (_mock *CertRepo) CreateUploaded(cert *biz.Cert) error { - ret := _mock.Called(cert) - - if len(ret) == 0 { - panic("no return value specified for CreateUploaded") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Cert) error); ok { - r0 = returnFunc(cert) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertRepo_CreateUploaded_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateUploaded' -type CertRepo_CreateUploaded_Call struct { - *mock.Call -} - -// CreateUploaded is a helper method to define mock.On call -// - cert *biz.Cert -func (_e *CertRepo_Expecter) CreateUploaded(cert any) *CertRepo_CreateUploaded_Call { - return &CertRepo_CreateUploaded_Call{Call: _e.mock.On("CreateUploaded", cert)} -} - -func (_c *CertRepo_CreateUploaded_Call) Run(run func(cert *biz.Cert)) *CertRepo_CreateUploaded_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Cert - if args[0] != nil { - arg0 = args[0].(*biz.Cert) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_CreateUploaded_Call) Return(err error) *CertRepo_CreateUploaded_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertRepo_CreateUploaded_Call) RunAndReturn(run func(cert *biz.Cert) error) *CertRepo_CreateUploaded_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type CertRepo -func (_mock *CertRepo) Delete(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type CertRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *CertRepo_Expecter) Delete(id any) *CertRepo_Delete_Call { - return &CertRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *CertRepo_Delete_Call) Run(run func(id uint)) *CertRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_Delete_Call) Return(err error) *CertRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertRepo_Delete_Call) RunAndReturn(run func(id uint) error) *CertRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// EnableWebsiteSSL provides a mock function for the type CertRepo -func (_mock *CertRepo) EnableWebsiteSSL(website *biz.Website, certPath string, keyPath string, webServer string, tlsVersions []string, listenIPv6 bool) error { - ret := _mock.Called(website, certPath, keyPath, webServer, tlsVersions, listenIPv6) - - if len(ret) == 0 { - panic("no return value specified for EnableWebsiteSSL") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Website, string, string, string, []string, bool) error); ok { - r0 = returnFunc(website, certPath, keyPath, webServer, tlsVersions, listenIPv6) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertRepo_EnableWebsiteSSL_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnableWebsiteSSL' -type CertRepo_EnableWebsiteSSL_Call struct { - *mock.Call -} - -// EnableWebsiteSSL is a helper method to define mock.On call -// - website *biz.Website -// - certPath string -// - keyPath string -// - webServer string -// - tlsVersions []string -// - listenIPv6 bool -func (_e *CertRepo_Expecter) EnableWebsiteSSL(website any, certPath any, keyPath any, webServer any, tlsVersions any, listenIPv6 any) *CertRepo_EnableWebsiteSSL_Call { - return &CertRepo_EnableWebsiteSSL_Call{Call: _e.mock.On("EnableWebsiteSSL", website, certPath, keyPath, webServer, tlsVersions, listenIPv6)} -} - -func (_c *CertRepo_EnableWebsiteSSL_Call) Run(run func(website *biz.Website, certPath string, keyPath string, webServer string, tlsVersions []string, listenIPv6 bool)) *CertRepo_EnableWebsiteSSL_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Website - if args[0] != nil { - arg0 = args[0].(*biz.Website) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - var arg4 []string - if args[4] != nil { - arg4 = args[4].([]string) - } - var arg5 bool - if args[5] != nil { - arg5 = args[5].(bool) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - ) - }) - return _c -} - -func (_c *CertRepo_EnableWebsiteSSL_Call) Return(err error) *CertRepo_EnableWebsiteSSL_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertRepo_EnableWebsiteSSL_Call) RunAndReturn(run func(website *biz.Website, certPath string, keyPath string, webServer string, tlsVersions []string, listenIPv6 bool) error) *CertRepo_EnableWebsiteSSL_Call { - _c.Call.Return(run) - return _c -} - -// GenerateSelfSigned provides a mock function for the type CertRepo -func (_mock *CertRepo) GenerateSelfSigned(domains []string) ([]byte, []byte, error) { - ret := _mock.Called(domains) - - if len(ret) == 0 { - panic("no return value specified for GenerateSelfSigned") - } - - var r0 []byte - var r1 []byte - var r2 error - if returnFunc, ok := ret.Get(0).(func([]string) ([]byte, []byte, error)); ok { - return returnFunc(domains) - } - if returnFunc, ok := ret.Get(0).(func([]string) []byte); ok { - r0 = returnFunc(domains) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - if returnFunc, ok := ret.Get(1).(func([]string) []byte); ok { - r1 = returnFunc(domains) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).([]byte) - } - } - if returnFunc, ok := ret.Get(2).(func([]string) error); ok { - r2 = returnFunc(domains) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// CertRepo_GenerateSelfSigned_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GenerateSelfSigned' -type CertRepo_GenerateSelfSigned_Call struct { - *mock.Call -} - -// GenerateSelfSigned is a helper method to define mock.On call -// - domains []string -func (_e *CertRepo_Expecter) GenerateSelfSigned(domains any) *CertRepo_GenerateSelfSigned_Call { - return &CertRepo_GenerateSelfSigned_Call{Call: _e.mock.On("GenerateSelfSigned", domains)} -} - -func (_c *CertRepo_GenerateSelfSigned_Call) Run(run func(domains []string)) *CertRepo_GenerateSelfSigned_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []string - if args[0] != nil { - arg0 = args[0].([]string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_GenerateSelfSigned_Call) Return(bytes []byte, bytes1 []byte, err error) *CertRepo_GenerateSelfSigned_Call { - _c.Call.Return(bytes, bytes1, err) - return _c -} - -func (_c *CertRepo_GenerateSelfSigned_Call) RunAndReturn(run func(domains []string) ([]byte, []byte, error)) *CertRepo_GenerateSelfSigned_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type CertRepo -func (_mock *CertRepo) Get(id uint) (*biz.Cert, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.Cert - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.Cert, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.Cert); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.Cert) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type CertRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *CertRepo_Expecter) Get(id any) *CertRepo_Get_Call { - return &CertRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *CertRepo_Get_Call) Run(run func(id uint)) *CertRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_Get_Call) Return(cert *biz.Cert, err error) *CertRepo_Get_Call { - _c.Call.Return(cert, err) - return _c -} - -func (_c *CertRepo_Get_Call) RunAndReturn(run func(id uint) (*biz.Cert, error)) *CertRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// GetByWebsite provides a mock function for the type CertRepo -func (_mock *CertRepo) GetByWebsite(WebsiteID uint) (*biz.Cert, error) { - ret := _mock.Called(WebsiteID) - - if len(ret) == 0 { - panic("no return value specified for GetByWebsite") - } - - var r0 *biz.Cert - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.Cert, error)); ok { - return returnFunc(WebsiteID) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.Cert); ok { - r0 = returnFunc(WebsiteID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.Cert) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(WebsiteID) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertRepo_GetByWebsite_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByWebsite' -type CertRepo_GetByWebsite_Call struct { - *mock.Call -} - -// GetByWebsite is a helper method to define mock.On call -// - WebsiteID uint -func (_e *CertRepo_Expecter) GetByWebsite(WebsiteID any) *CertRepo_GetByWebsite_Call { - return &CertRepo_GetByWebsite_Call{Call: _e.mock.On("GetByWebsite", WebsiteID)} -} - -func (_c *CertRepo_GetByWebsite_Call) Run(run func(WebsiteID uint)) *CertRepo_GetByWebsite_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_GetByWebsite_Call) Return(cert *biz.Cert, err error) *CertRepo_GetByWebsite_Call { - _c.Call.Return(cert, err) - return _c -} - -func (_c *CertRepo_GetByWebsite_Call) RunAndReturn(run func(WebsiteID uint) (*biz.Cert, error)) *CertRepo_GetByWebsite_Call { - _c.Call.Return(run) - return _c -} - -// GetClient provides a mock function for the type CertRepo -func (_mock *CertRepo) GetClient(cert *biz.Cert) (*acme.Client, error) { - ret := _mock.Called(cert) - - if len(ret) == 0 { - panic("no return value specified for GetClient") - } - - var r0 *acme.Client - var r1 error - if returnFunc, ok := ret.Get(0).(func(*biz.Cert) (*acme.Client, error)); ok { - return returnFunc(cert) - } - if returnFunc, ok := ret.Get(0).(func(*biz.Cert) *acme.Client); ok { - r0 = returnFunc(cert) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*acme.Client) - } - } - if returnFunc, ok := ret.Get(1).(func(*biz.Cert) error); ok { - r1 = returnFunc(cert) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertRepo_GetClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetClient' -type CertRepo_GetClient_Call struct { - *mock.Call -} - -// GetClient is a helper method to define mock.On call -// - cert *biz.Cert -func (_e *CertRepo_Expecter) GetClient(cert any) *CertRepo_GetClient_Call { - return &CertRepo_GetClient_Call{Call: _e.mock.On("GetClient", cert)} -} - -func (_c *CertRepo_GetClient_Call) Run(run func(cert *biz.Cert)) *CertRepo_GetClient_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Cert - if args[0] != nil { - arg0 = args[0].(*biz.Cert) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_GetClient_Call) Return(client *acme.Client, err error) *CertRepo_GetClient_Call { - _c.Call.Return(client, err) - return _c -} - -func (_c *CertRepo_GetClient_Call) RunAndReturn(run func(cert *biz.Cert) (*acme.Client, error)) *CertRepo_GetClient_Call { - _c.Call.Return(run) - return _c -} - -// HTTPConfs provides a mock function for the type CertRepo -func (_mock *CertRepo) HTTPConfs(cert *biz.Cert, webServer string) (map[string]string, []string) { - ret := _mock.Called(cert, webServer) - - if len(ret) == 0 { - panic("no return value specified for HTTPConfs") - } - - var r0 map[string]string - var r1 []string - if returnFunc, ok := ret.Get(0).(func(*biz.Cert, string) (map[string]string, []string)); ok { - return returnFunc(cert, webServer) - } - if returnFunc, ok := ret.Get(0).(func(*biz.Cert, string) map[string]string); ok { - r0 = returnFunc(cert, webServer) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(map[string]string) - } - } - if returnFunc, ok := ret.Get(1).(func(*biz.Cert, string) []string); ok { - r1 = returnFunc(cert, webServer) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).([]string) - } - } - return r0, r1 -} - -// CertRepo_HTTPConfs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HTTPConfs' -type CertRepo_HTTPConfs_Call struct { - *mock.Call -} - -// HTTPConfs is a helper method to define mock.On call -// - cert *biz.Cert -// - webServer string -func (_e *CertRepo_Expecter) HTTPConfs(cert any, webServer any) *CertRepo_HTTPConfs_Call { - return &CertRepo_HTTPConfs_Call{Call: _e.mock.On("HTTPConfs", cert, webServer)} -} - -func (_c *CertRepo_HTTPConfs_Call) Run(run func(cert *biz.Cert, webServer string)) *CertRepo_HTTPConfs_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Cert - if args[0] != nil { - arg0 = args[0].(*biz.Cert) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *CertRepo_HTTPConfs_Call) Return(stringToString map[string]string, strings []string) *CertRepo_HTTPConfs_Call { - _c.Call.Return(stringToString, strings) - return _c -} - -func (_c *CertRepo_HTTPConfs_Call) RunAndReturn(run func(cert *biz.Cert, webServer string) (map[string]string, []string)) *CertRepo_HTTPConfs_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type CertRepo -func (_mock *CertRepo) List(page uint, limit uint) ([]*types.CertList, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*types.CertList - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*types.CertList, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*types.CertList); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*types.CertList) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// CertRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type CertRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *CertRepo_Expecter) List(page any, limit any) *CertRepo_List_Call { - return &CertRepo_List_Call{Call: _e.mock.On("List", page, limit)} -} - -func (_c *CertRepo_List_Call) Run(run func(page uint, limit uint)) *CertRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *CertRepo_List_Call) Return(certLists []*types.CertList, n int64, err error) *CertRepo_List_Call { - _c.Call.Return(certLists, n, err) - return _c -} - -func (_c *CertRepo_List_Call) RunAndReturn(run func(page uint, limit uint) ([]*types.CertList, int64, error)) *CertRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// LoadWebsites provides a mock function for the type CertRepo -func (_mock *CertRepo) LoadWebsites(websiteIDs []uint) ([]*biz.Website, error) { - ret := _mock.Called(websiteIDs) - - if len(ret) == 0 { - panic("no return value specified for LoadWebsites") - } - - var r0 []*biz.Website - var r1 error - if returnFunc, ok := ret.Get(0).(func([]uint) ([]*biz.Website, error)); ok { - return returnFunc(websiteIDs) - } - if returnFunc, ok := ret.Get(0).(func([]uint) []*biz.Website); ok { - r0 = returnFunc(websiteIDs) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.Website) - } - } - if returnFunc, ok := ret.Get(1).(func([]uint) error); ok { - r1 = returnFunc(websiteIDs) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CertRepo_LoadWebsites_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadWebsites' -type CertRepo_LoadWebsites_Call struct { - *mock.Call -} - -// LoadWebsites is a helper method to define mock.On call -// - websiteIDs []uint -func (_e *CertRepo_Expecter) LoadWebsites(websiteIDs any) *CertRepo_LoadWebsites_Call { - return &CertRepo_LoadWebsites_Call{Call: _e.mock.On("LoadWebsites", websiteIDs)} -} - -func (_c *CertRepo_LoadWebsites_Call) Run(run func(websiteIDs []uint)) *CertRepo_LoadWebsites_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []uint - if args[0] != nil { - arg0 = args[0].([]uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_LoadWebsites_Call) Return(websites []*biz.Website, err error) *CertRepo_LoadWebsites_Call { - _c.Call.Return(websites, err) - return _c -} - -func (_c *CertRepo_LoadWebsites_Call) RunAndReturn(run func(websiteIDs []uint) ([]*biz.Website, error)) *CertRepo_LoadWebsites_Call { - _c.Call.Return(run) - return _c -} - -// ObtainPanel provides a mock function for the type CertRepo -func (_mock *CertRepo) ObtainPanel(account *biz.CertAccount, names []string, webServer string) ([]byte, []byte, error) { - ret := _mock.Called(account, names, webServer) - - if len(ret) == 0 { - panic("no return value specified for ObtainPanel") - } - - var r0 []byte - var r1 []byte - var r2 error - if returnFunc, ok := ret.Get(0).(func(*biz.CertAccount, []string, string) ([]byte, []byte, error)); ok { - return returnFunc(account, names, webServer) - } - if returnFunc, ok := ret.Get(0).(func(*biz.CertAccount, []string, string) []byte); ok { - r0 = returnFunc(account, names, webServer) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - if returnFunc, ok := ret.Get(1).(func(*biz.CertAccount, []string, string) []byte); ok { - r1 = returnFunc(account, names, webServer) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).([]byte) - } - } - if returnFunc, ok := ret.Get(2).(func(*biz.CertAccount, []string, string) error); ok { - r2 = returnFunc(account, names, webServer) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// CertRepo_ObtainPanel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ObtainPanel' -type CertRepo_ObtainPanel_Call struct { - *mock.Call -} - -// ObtainPanel is a helper method to define mock.On call -// - account *biz.CertAccount -// - names []string -// - webServer string -func (_e *CertRepo_Expecter) ObtainPanel(account any, names any, webServer any) *CertRepo_ObtainPanel_Call { - return &CertRepo_ObtainPanel_Call{Call: _e.mock.On("ObtainPanel", account, names, webServer)} -} - -func (_c *CertRepo_ObtainPanel_Call) Run(run func(account *biz.CertAccount, names []string, webServer string)) *CertRepo_ObtainPanel_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.CertAccount - if args[0] != nil { - arg0 = args[0].(*biz.CertAccount) - } - var arg1 []string - if args[1] != nil { - arg1 = args[1].([]string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *CertRepo_ObtainPanel_Call) Return(bytes []byte, bytes1 []byte, err error) *CertRepo_ObtainPanel_Call { - _c.Call.Return(bytes, bytes1, err) - return _c -} - -func (_c *CertRepo_ObtainPanel_Call) RunAndReturn(run func(account *biz.CertAccount, names []string, webServer string) ([]byte, []byte, error)) *CertRepo_ObtainPanel_Call { - _c.Call.Return(run) - return _c -} - -// ReloadWebserver provides a mock function for the type CertRepo -func (_mock *CertRepo) ReloadWebserver(webServer string) error { - ret := _mock.Called(webServer) - - if len(ret) == 0 { - panic("no return value specified for ReloadWebserver") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(webServer) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertRepo_ReloadWebserver_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReloadWebserver' -type CertRepo_ReloadWebserver_Call struct { - *mock.Call -} - -// ReloadWebserver is a helper method to define mock.On call -// - webServer string -func (_e *CertRepo_Expecter) ReloadWebserver(webServer any) *CertRepo_ReloadWebserver_Call { - return &CertRepo_ReloadWebserver_Call{Call: _e.mock.On("ReloadWebserver", webServer)} -} - -func (_c *CertRepo_ReloadWebserver_Call) Run(run func(webServer string)) *CertRepo_ReloadWebserver_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_ReloadWebserver_Call) Return(err error) *CertRepo_ReloadWebserver_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertRepo_ReloadWebserver_Call) RunAndReturn(run func(webServer string) error) *CertRepo_ReloadWebserver_Call { - _c.Call.Return(run) - return _c -} - -// RunScript provides a mock function for the type CertRepo -func (_mock *CertRepo) RunScript(cert *biz.Cert) error { - ret := _mock.Called(cert) - - if len(ret) == 0 { - panic("no return value specified for RunScript") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Cert) error); ok { - r0 = returnFunc(cert) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertRepo_RunScript_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RunScript' -type CertRepo_RunScript_Call struct { - *mock.Call -} - -// RunScript is a helper method to define mock.On call -// - cert *biz.Cert -func (_e *CertRepo_Expecter) RunScript(cert any) *CertRepo_RunScript_Call { - return &CertRepo_RunScript_Call{Call: _e.mock.On("RunScript", cert)} -} - -func (_c *CertRepo_RunScript_Call) Run(run func(cert *biz.Cert)) *CertRepo_RunScript_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Cert - if args[0] != nil { - arg0 = args[0].(*biz.Cert) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_RunScript_Call) Return(err error) *CertRepo_RunScript_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertRepo_RunScript_Call) RunAndReturn(run func(cert *biz.Cert) error) *CertRepo_RunScript_Call { - _c.Call.Return(run) - return _c -} - -// Save provides a mock function for the type CertRepo -func (_mock *CertRepo) Save(cert *biz.Cert) error { - ret := _mock.Called(cert) - - if len(ret) == 0 { - panic("no return value specified for Save") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Cert) error); ok { - r0 = returnFunc(cert) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertRepo_Save_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Save' -type CertRepo_Save_Call struct { - *mock.Call -} - -// Save is a helper method to define mock.On call -// - cert *biz.Cert -func (_e *CertRepo_Expecter) Save(cert any) *CertRepo_Save_Call { - return &CertRepo_Save_Call{Call: _e.mock.On("Save", cert)} -} - -func (_c *CertRepo_Save_Call) Run(run func(cert *biz.Cert)) *CertRepo_Save_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Cert - if args[0] != nil { - arg0 = args[0].(*biz.Cert) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_Save_Call) Return(err error) *CertRepo_Save_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertRepo_Save_Call) RunAndReturn(run func(cert *biz.Cert) error) *CertRepo_Save_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function for the type CertRepo -func (_mock *CertRepo) Update(req *request.CertUpdate) error { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*request.CertUpdate) error); ok { - r0 = returnFunc(req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertRepo_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type CertRepo_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - req *request.CertUpdate -func (_e *CertRepo_Expecter) Update(req any) *CertRepo_Update_Call { - return &CertRepo_Update_Call{Call: _e.mock.On("Update", req)} -} - -func (_c *CertRepo_Update_Call) Run(run func(req *request.CertUpdate)) *CertRepo_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.CertUpdate - if args[0] != nil { - arg0 = args[0].(*request.CertUpdate) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CertRepo_Update_Call) Return(err error) *CertRepo_Update_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertRepo_Update_Call) RunAndReturn(run func(req *request.CertUpdate) error) *CertRepo_Update_Call { - _c.Call.Return(run) - return _c -} - -// WriteCertFiles provides a mock function for the type CertRepo -func (_mock *CertRepo) WriteCertFiles(cert *biz.Cert, certPath string, keyPath string) error { - ret := _mock.Called(cert, certPath, keyPath) - - if len(ret) == 0 { - panic("no return value specified for WriteCertFiles") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Cert, string, string) error); ok { - r0 = returnFunc(cert, certPath, keyPath) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CertRepo_WriteCertFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteCertFiles' -type CertRepo_WriteCertFiles_Call struct { - *mock.Call -} - -// WriteCertFiles is a helper method to define mock.On call -// - cert *biz.Cert -// - certPath string -// - keyPath string -func (_e *CertRepo_Expecter) WriteCertFiles(cert any, certPath any, keyPath any) *CertRepo_WriteCertFiles_Call { - return &CertRepo_WriteCertFiles_Call{Call: _e.mock.On("WriteCertFiles", cert, certPath, keyPath)} -} - -func (_c *CertRepo_WriteCertFiles_Call) Run(run func(cert *biz.Cert, certPath string, keyPath string)) *CertRepo_WriteCertFiles_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Cert - if args[0] != nil { - arg0 = args[0].(*biz.Cert) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *CertRepo_WriteCertFiles_Call) Return(err error) *CertRepo_WriteCertFiles_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CertRepo_WriteCertFiles_Call) RunAndReturn(run func(cert *biz.Cert, certPath string, keyPath string) error) *CertRepo_WriteCertFiles_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/ContainerComposeRepo.go b/mocks/biz/ContainerComposeRepo.go deleted file mode 100644 index a1efb5dd4..000000000 --- a/mocks/biz/ContainerComposeRepo.go +++ /dev/null @@ -1,454 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewContainerComposeRepo creates a new instance of ContainerComposeRepo. 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 NewContainerComposeRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *ContainerComposeRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &ContainerComposeRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// ContainerComposeRepo is an autogenerated mock type for the ContainerComposeRepo type -type ContainerComposeRepo struct { - mock.Mock -} - -type ContainerComposeRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *ContainerComposeRepo) EXPECT() *ContainerComposeRepo_Expecter { - return &ContainerComposeRepo_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function for the type ContainerComposeRepo -func (_mock *ContainerComposeRepo) Create(name string, compose string, envs []types.KV) error { - ret := _mock.Called(name, compose, envs) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string, []types.KV) error); ok { - r0 = returnFunc(name, compose, envs) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerComposeRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type ContainerComposeRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - name string -// - compose string -// - envs []types.KV -func (_e *ContainerComposeRepo_Expecter) Create(name any, compose any, envs any) *ContainerComposeRepo_Create_Call { - return &ContainerComposeRepo_Create_Call{Call: _e.mock.On("Create", name, compose, envs)} -} - -func (_c *ContainerComposeRepo_Create_Call) Run(run func(name string, compose string, envs []types.KV)) *ContainerComposeRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []types.KV - if args[2] != nil { - arg2 = args[2].([]types.KV) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *ContainerComposeRepo_Create_Call) Return(err error) *ContainerComposeRepo_Create_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerComposeRepo_Create_Call) RunAndReturn(run func(name string, compose string, envs []types.KV) error) *ContainerComposeRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Down provides a mock function for the type ContainerComposeRepo -func (_mock *ContainerComposeRepo) Down(name string) error { - ret := _mock.Called(name) - - if len(ret) == 0 { - panic("no return value specified for Down") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(name) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerComposeRepo_Down_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Down' -type ContainerComposeRepo_Down_Call struct { - *mock.Call -} - -// Down is a helper method to define mock.On call -// - name string -func (_e *ContainerComposeRepo_Expecter) Down(name any) *ContainerComposeRepo_Down_Call { - return &ContainerComposeRepo_Down_Call{Call: _e.mock.On("Down", name)} -} - -func (_c *ContainerComposeRepo_Down_Call) Run(run func(name string)) *ContainerComposeRepo_Down_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ContainerComposeRepo_Down_Call) Return(err error) *ContainerComposeRepo_Down_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerComposeRepo_Down_Call) RunAndReturn(run func(name string) error) *ContainerComposeRepo_Down_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type ContainerComposeRepo -func (_mock *ContainerComposeRepo) Get(name string) (string, []types.KV, error) { - ret := _mock.Called(name) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 string - var r1 []types.KV - var r2 error - if returnFunc, ok := ret.Get(0).(func(string) (string, []types.KV, error)); ok { - return returnFunc(name) - } - if returnFunc, ok := ret.Get(0).(func(string) string); ok { - r0 = returnFunc(name) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(string) []types.KV); ok { - r1 = returnFunc(name) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).([]types.KV) - } - } - if returnFunc, ok := ret.Get(2).(func(string) error); ok { - r2 = returnFunc(name) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// ContainerComposeRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type ContainerComposeRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - name string -func (_e *ContainerComposeRepo_Expecter) Get(name any) *ContainerComposeRepo_Get_Call { - return &ContainerComposeRepo_Get_Call{Call: _e.mock.On("Get", name)} -} - -func (_c *ContainerComposeRepo_Get_Call) Run(run func(name string)) *ContainerComposeRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ContainerComposeRepo_Get_Call) Return(s string, kVs []types.KV, err error) *ContainerComposeRepo_Get_Call { - _c.Call.Return(s, kVs, err) - return _c -} - -func (_c *ContainerComposeRepo_Get_Call) RunAndReturn(run func(name string) (string, []types.KV, error)) *ContainerComposeRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type ContainerComposeRepo -func (_mock *ContainerComposeRepo) List() ([]types.ContainerCompose, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []types.ContainerCompose - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]types.ContainerCompose, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []types.ContainerCompose); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.ContainerCompose) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ContainerComposeRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type ContainerComposeRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -func (_e *ContainerComposeRepo_Expecter) List() *ContainerComposeRepo_List_Call { - return &ContainerComposeRepo_List_Call{Call: _e.mock.On("List")} -} - -func (_c *ContainerComposeRepo_List_Call) Run(run func()) *ContainerComposeRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *ContainerComposeRepo_List_Call) Return(containerComposes []types.ContainerCompose, err error) *ContainerComposeRepo_List_Call { - _c.Call.Return(containerComposes, err) - return _c -} - -func (_c *ContainerComposeRepo_List_Call) RunAndReturn(run func() ([]types.ContainerCompose, error)) *ContainerComposeRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// RemoveDir provides a mock function for the type ContainerComposeRepo -func (_mock *ContainerComposeRepo) RemoveDir(name string) error { - ret := _mock.Called(name) - - if len(ret) == 0 { - panic("no return value specified for RemoveDir") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(name) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerComposeRepo_RemoveDir_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveDir' -type ContainerComposeRepo_RemoveDir_Call struct { - *mock.Call -} - -// RemoveDir is a helper method to define mock.On call -// - name string -func (_e *ContainerComposeRepo_Expecter) RemoveDir(name any) *ContainerComposeRepo_RemoveDir_Call { - return &ContainerComposeRepo_RemoveDir_Call{Call: _e.mock.On("RemoveDir", name)} -} - -func (_c *ContainerComposeRepo_RemoveDir_Call) Run(run func(name string)) *ContainerComposeRepo_RemoveDir_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ContainerComposeRepo_RemoveDir_Call) Return(err error) *ContainerComposeRepo_RemoveDir_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerComposeRepo_RemoveDir_Call) RunAndReturn(run func(name string) error) *ContainerComposeRepo_RemoveDir_Call { - _c.Call.Return(run) - return _c -} - -// Up provides a mock function for the type ContainerComposeRepo -func (_mock *ContainerComposeRepo) Up(name string, force bool) error { - ret := _mock.Called(name, force) - - if len(ret) == 0 { - panic("no return value specified for Up") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, bool) error); ok { - r0 = returnFunc(name, force) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerComposeRepo_Up_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Up' -type ContainerComposeRepo_Up_Call struct { - *mock.Call -} - -// Up is a helper method to define mock.On call -// - name string -// - force bool -func (_e *ContainerComposeRepo_Expecter) Up(name any, force any) *ContainerComposeRepo_Up_Call { - return &ContainerComposeRepo_Up_Call{Call: _e.mock.On("Up", name, force)} -} - -func (_c *ContainerComposeRepo_Up_Call) Run(run func(name string, force bool)) *ContainerComposeRepo_Up_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 bool - if args[1] != nil { - arg1 = args[1].(bool) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerComposeRepo_Up_Call) Return(err error) *ContainerComposeRepo_Up_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerComposeRepo_Up_Call) RunAndReturn(run func(name string, force bool) error) *ContainerComposeRepo_Up_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function for the type ContainerComposeRepo -func (_mock *ContainerComposeRepo) Update(name string, compose string, envs []types.KV) error { - ret := _mock.Called(name, compose, envs) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string, []types.KV) error); ok { - r0 = returnFunc(name, compose, envs) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerComposeRepo_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type ContainerComposeRepo_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - name string -// - compose string -// - envs []types.KV -func (_e *ContainerComposeRepo_Expecter) Update(name any, compose any, envs any) *ContainerComposeRepo_Update_Call { - return &ContainerComposeRepo_Update_Call{Call: _e.mock.On("Update", name, compose, envs)} -} - -func (_c *ContainerComposeRepo_Update_Call) Run(run func(name string, compose string, envs []types.KV)) *ContainerComposeRepo_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []types.KV - if args[2] != nil { - arg2 = args[2].([]types.KV) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *ContainerComposeRepo_Update_Call) Return(err error) *ContainerComposeRepo_Update_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerComposeRepo_Update_Call) RunAndReturn(run func(name string, compose string, envs []types.KV) error) *ContainerComposeRepo_Update_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/ContainerImageRepo.go b/mocks/biz/ContainerImageRepo.go deleted file mode 100644 index b7ff3f2f8..000000000 --- a/mocks/biz/ContainerImageRepo.go +++ /dev/null @@ -1,340 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewContainerImageRepo creates a new instance of ContainerImageRepo. 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 NewContainerImageRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *ContainerImageRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &ContainerImageRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// ContainerImageRepo is an autogenerated mock type for the ContainerImageRepo type -type ContainerImageRepo struct { - mock.Mock -} - -type ContainerImageRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *ContainerImageRepo) EXPECT() *ContainerImageRepo_Expecter { - return &ContainerImageRepo_Expecter{mock: &_m.Mock} -} - -// Exist provides a mock function for the type ContainerImageRepo -func (_mock *ContainerImageRepo) Exist(sock string, name string) (bool, error) { - ret := _mock.Called(sock, name) - - if len(ret) == 0 { - panic("no return value specified for Exist") - } - - var r0 bool - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string) (bool, error)); ok { - return returnFunc(sock, name) - } - if returnFunc, ok := ret.Get(0).(func(string, string) bool); ok { - r0 = returnFunc(sock, name) - } else { - r0 = ret.Get(0).(bool) - } - if returnFunc, ok := ret.Get(1).(func(string, string) error); ok { - r1 = returnFunc(sock, name) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ContainerImageRepo_Exist_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exist' -type ContainerImageRepo_Exist_Call struct { - *mock.Call -} - -// Exist is a helper method to define mock.On call -// - sock string -// - name string -func (_e *ContainerImageRepo_Expecter) Exist(sock any, name any) *ContainerImageRepo_Exist_Call { - return &ContainerImageRepo_Exist_Call{Call: _e.mock.On("Exist", sock, name)} -} - -func (_c *ContainerImageRepo_Exist_Call) Run(run func(sock string, name string)) *ContainerImageRepo_Exist_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerImageRepo_Exist_Call) Return(b bool, err error) *ContainerImageRepo_Exist_Call { - _c.Call.Return(b, err) - return _c -} - -func (_c *ContainerImageRepo_Exist_Call) RunAndReturn(run func(sock string, name string) (bool, error)) *ContainerImageRepo_Exist_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type ContainerImageRepo -func (_mock *ContainerImageRepo) List(sock string) ([]types.ContainerImage, error) { - ret := _mock.Called(sock) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []types.ContainerImage - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) ([]types.ContainerImage, error)); ok { - return returnFunc(sock) - } - if returnFunc, ok := ret.Get(0).(func(string) []types.ContainerImage); ok { - r0 = returnFunc(sock) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.ContainerImage) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(sock) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ContainerImageRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type ContainerImageRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - sock string -func (_e *ContainerImageRepo_Expecter) List(sock any) *ContainerImageRepo_List_Call { - return &ContainerImageRepo_List_Call{Call: _e.mock.On("List", sock)} -} - -func (_c *ContainerImageRepo_List_Call) Run(run func(sock string)) *ContainerImageRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ContainerImageRepo_List_Call) Return(containerImages []types.ContainerImage, err error) *ContainerImageRepo_List_Call { - _c.Call.Return(containerImages, err) - return _c -} - -func (_c *ContainerImageRepo_List_Call) RunAndReturn(run func(sock string) ([]types.ContainerImage, error)) *ContainerImageRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// Prune provides a mock function for the type ContainerImageRepo -func (_mock *ContainerImageRepo) Prune(sock string) error { - ret := _mock.Called(sock) - - if len(ret) == 0 { - panic("no return value specified for Prune") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(sock) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerImageRepo_Prune_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Prune' -type ContainerImageRepo_Prune_Call struct { - *mock.Call -} - -// Prune is a helper method to define mock.On call -// - sock string -func (_e *ContainerImageRepo_Expecter) Prune(sock any) *ContainerImageRepo_Prune_Call { - return &ContainerImageRepo_Prune_Call{Call: _e.mock.On("Prune", sock)} -} - -func (_c *ContainerImageRepo_Prune_Call) Run(run func(sock string)) *ContainerImageRepo_Prune_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ContainerImageRepo_Prune_Call) Return(err error) *ContainerImageRepo_Prune_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerImageRepo_Prune_Call) RunAndReturn(run func(sock string) error) *ContainerImageRepo_Prune_Call { - _c.Call.Return(run) - return _c -} - -// Pull provides a mock function for the type ContainerImageRepo -func (_mock *ContainerImageRepo) Pull(sock string, req *request.ContainerImagePull) error { - ret := _mock.Called(sock, req) - - if len(ret) == 0 { - panic("no return value specified for Pull") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, *request.ContainerImagePull) error); ok { - r0 = returnFunc(sock, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerImageRepo_Pull_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Pull' -type ContainerImageRepo_Pull_Call struct { - *mock.Call -} - -// Pull is a helper method to define mock.On call -// - sock string -// - req *request.ContainerImagePull -func (_e *ContainerImageRepo_Expecter) Pull(sock any, req any) *ContainerImageRepo_Pull_Call { - return &ContainerImageRepo_Pull_Call{Call: _e.mock.On("Pull", sock, req)} -} - -func (_c *ContainerImageRepo_Pull_Call) Run(run func(sock string, req *request.ContainerImagePull)) *ContainerImageRepo_Pull_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 *request.ContainerImagePull - if args[1] != nil { - arg1 = args[1].(*request.ContainerImagePull) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerImageRepo_Pull_Call) Return(err error) *ContainerImageRepo_Pull_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerImageRepo_Pull_Call) RunAndReturn(run func(sock string, req *request.ContainerImagePull) error) *ContainerImageRepo_Pull_Call { - _c.Call.Return(run) - return _c -} - -// Remove provides a mock function for the type ContainerImageRepo -func (_mock *ContainerImageRepo) Remove(sock string, id string) error { - ret := _mock.Called(sock, id) - - if len(ret) == 0 { - panic("no return value specified for Remove") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(sock, id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerImageRepo_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove' -type ContainerImageRepo_Remove_Call struct { - *mock.Call -} - -// Remove is a helper method to define mock.On call -// - sock string -// - id string -func (_e *ContainerImageRepo_Expecter) Remove(sock any, id any) *ContainerImageRepo_Remove_Call { - return &ContainerImageRepo_Remove_Call{Call: _e.mock.On("Remove", sock, id)} -} - -func (_c *ContainerImageRepo_Remove_Call) Run(run func(sock string, id string)) *ContainerImageRepo_Remove_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerImageRepo_Remove_Call) Return(err error) *ContainerImageRepo_Remove_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerImageRepo_Remove_Call) RunAndReturn(run func(sock string, id string) error) *ContainerImageRepo_Remove_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/ContainerNetworkRepo.go b/mocks/biz/ContainerNetworkRepo.go deleted file mode 100644 index e292630cd..000000000 --- a/mocks/biz/ContainerNetworkRepo.go +++ /dev/null @@ -1,283 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewContainerNetworkRepo creates a new instance of ContainerNetworkRepo. 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 NewContainerNetworkRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *ContainerNetworkRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &ContainerNetworkRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// ContainerNetworkRepo is an autogenerated mock type for the ContainerNetworkRepo type -type ContainerNetworkRepo struct { - mock.Mock -} - -type ContainerNetworkRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *ContainerNetworkRepo) EXPECT() *ContainerNetworkRepo_Expecter { - return &ContainerNetworkRepo_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function for the type ContainerNetworkRepo -func (_mock *ContainerNetworkRepo) Create(sock string, req *request.ContainerNetworkCreate) (string, error) { - ret := _mock.Called(sock, req) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, *request.ContainerNetworkCreate) (string, error)); ok { - return returnFunc(sock, req) - } - if returnFunc, ok := ret.Get(0).(func(string, *request.ContainerNetworkCreate) string); ok { - r0 = returnFunc(sock, req) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(string, *request.ContainerNetworkCreate) error); ok { - r1 = returnFunc(sock, req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ContainerNetworkRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type ContainerNetworkRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - sock string -// - req *request.ContainerNetworkCreate -func (_e *ContainerNetworkRepo_Expecter) Create(sock any, req any) *ContainerNetworkRepo_Create_Call { - return &ContainerNetworkRepo_Create_Call{Call: _e.mock.On("Create", sock, req)} -} - -func (_c *ContainerNetworkRepo_Create_Call) Run(run func(sock string, req *request.ContainerNetworkCreate)) *ContainerNetworkRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 *request.ContainerNetworkCreate - if args[1] != nil { - arg1 = args[1].(*request.ContainerNetworkCreate) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerNetworkRepo_Create_Call) Return(s string, err error) *ContainerNetworkRepo_Create_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *ContainerNetworkRepo_Create_Call) RunAndReturn(run func(sock string, req *request.ContainerNetworkCreate) (string, error)) *ContainerNetworkRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type ContainerNetworkRepo -func (_mock *ContainerNetworkRepo) List(sock string) ([]types.ContainerNetwork, error) { - ret := _mock.Called(sock) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []types.ContainerNetwork - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) ([]types.ContainerNetwork, error)); ok { - return returnFunc(sock) - } - if returnFunc, ok := ret.Get(0).(func(string) []types.ContainerNetwork); ok { - r0 = returnFunc(sock) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.ContainerNetwork) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(sock) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ContainerNetworkRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type ContainerNetworkRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - sock string -func (_e *ContainerNetworkRepo_Expecter) List(sock any) *ContainerNetworkRepo_List_Call { - return &ContainerNetworkRepo_List_Call{Call: _e.mock.On("List", sock)} -} - -func (_c *ContainerNetworkRepo_List_Call) Run(run func(sock string)) *ContainerNetworkRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ContainerNetworkRepo_List_Call) Return(containerNetworks []types.ContainerNetwork, err error) *ContainerNetworkRepo_List_Call { - _c.Call.Return(containerNetworks, err) - return _c -} - -func (_c *ContainerNetworkRepo_List_Call) RunAndReturn(run func(sock string) ([]types.ContainerNetwork, error)) *ContainerNetworkRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// Prune provides a mock function for the type ContainerNetworkRepo -func (_mock *ContainerNetworkRepo) Prune(sock string) error { - ret := _mock.Called(sock) - - if len(ret) == 0 { - panic("no return value specified for Prune") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(sock) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerNetworkRepo_Prune_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Prune' -type ContainerNetworkRepo_Prune_Call struct { - *mock.Call -} - -// Prune is a helper method to define mock.On call -// - sock string -func (_e *ContainerNetworkRepo_Expecter) Prune(sock any) *ContainerNetworkRepo_Prune_Call { - return &ContainerNetworkRepo_Prune_Call{Call: _e.mock.On("Prune", sock)} -} - -func (_c *ContainerNetworkRepo_Prune_Call) Run(run func(sock string)) *ContainerNetworkRepo_Prune_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ContainerNetworkRepo_Prune_Call) Return(err error) *ContainerNetworkRepo_Prune_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerNetworkRepo_Prune_Call) RunAndReturn(run func(sock string) error) *ContainerNetworkRepo_Prune_Call { - _c.Call.Return(run) - return _c -} - -// Remove provides a mock function for the type ContainerNetworkRepo -func (_mock *ContainerNetworkRepo) Remove(sock string, id string) error { - ret := _mock.Called(sock, id) - - if len(ret) == 0 { - panic("no return value specified for Remove") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(sock, id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerNetworkRepo_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove' -type ContainerNetworkRepo_Remove_Call struct { - *mock.Call -} - -// Remove is a helper method to define mock.On call -// - sock string -// - id string -func (_e *ContainerNetworkRepo_Expecter) Remove(sock any, id any) *ContainerNetworkRepo_Remove_Call { - return &ContainerNetworkRepo_Remove_Call{Call: _e.mock.On("Remove", sock, id)} -} - -func (_c *ContainerNetworkRepo_Remove_Call) Run(run func(sock string, id string)) *ContainerNetworkRepo_Remove_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerNetworkRepo_Remove_Call) Return(err error) *ContainerNetworkRepo_Remove_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerNetworkRepo_Remove_Call) RunAndReturn(run func(sock string, id string) error) *ContainerNetworkRepo_Remove_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/ContainerRepo.go b/mocks/biz/ContainerRepo.go deleted file mode 100644 index ad8b50b6a..000000000 --- a/mocks/biz/ContainerRepo.go +++ /dev/null @@ -1,828 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewContainerRepo creates a new instance of ContainerRepo. 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 NewContainerRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *ContainerRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &ContainerRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// ContainerRepo is an autogenerated mock type for the ContainerRepo type -type ContainerRepo struct { - mock.Mock -} - -type ContainerRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *ContainerRepo) EXPECT() *ContainerRepo_Expecter { - return &ContainerRepo_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Create(sock string, req *request.ContainerCreate) (string, error) { - ret := _mock.Called(sock, req) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, *request.ContainerCreate) (string, error)); ok { - return returnFunc(sock, req) - } - if returnFunc, ok := ret.Get(0).(func(string, *request.ContainerCreate) string); ok { - r0 = returnFunc(sock, req) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(string, *request.ContainerCreate) error); ok { - r1 = returnFunc(sock, req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ContainerRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type ContainerRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - sock string -// - req *request.ContainerCreate -func (_e *ContainerRepo_Expecter) Create(sock any, req any) *ContainerRepo_Create_Call { - return &ContainerRepo_Create_Call{Call: _e.mock.On("Create", sock, req)} -} - -func (_c *ContainerRepo_Create_Call) Run(run func(sock string, req *request.ContainerCreate)) *ContainerRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 *request.ContainerCreate - if args[1] != nil { - arg1 = args[1].(*request.ContainerCreate) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerRepo_Create_Call) Return(s string, err error) *ContainerRepo_Create_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *ContainerRepo_Create_Call) RunAndReturn(run func(sock string, req *request.ContainerCreate) (string, error)) *ContainerRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Inspect provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Inspect(sock string, id string) (any, error) { - ret := _mock.Called(sock, id) - - if len(ret) == 0 { - panic("no return value specified for Inspect") - } - - var r0 any - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string) (any, error)); ok { - return returnFunc(sock, id) - } - if returnFunc, ok := ret.Get(0).(func(string, string) any); ok { - r0 = returnFunc(sock, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(any) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string) error); ok { - r1 = returnFunc(sock, id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ContainerRepo_Inspect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Inspect' -type ContainerRepo_Inspect_Call struct { - *mock.Call -} - -// Inspect is a helper method to define mock.On call -// - sock string -// - id string -func (_e *ContainerRepo_Expecter) Inspect(sock any, id any) *ContainerRepo_Inspect_Call { - return &ContainerRepo_Inspect_Call{Call: _e.mock.On("Inspect", sock, id)} -} - -func (_c *ContainerRepo_Inspect_Call) Run(run func(sock string, id string)) *ContainerRepo_Inspect_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerRepo_Inspect_Call) Return(anyMoqParam any, err error) *ContainerRepo_Inspect_Call { - _c.Call.Return(anyMoqParam, err) - return _c -} - -func (_c *ContainerRepo_Inspect_Call) RunAndReturn(run func(sock string, id string) (any, error)) *ContainerRepo_Inspect_Call { - _c.Call.Return(run) - return _c -} - -// Kill provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Kill(sock string, id string) error { - ret := _mock.Called(sock, id) - - if len(ret) == 0 { - panic("no return value specified for Kill") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(sock, id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerRepo_Kill_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Kill' -type ContainerRepo_Kill_Call struct { - *mock.Call -} - -// Kill is a helper method to define mock.On call -// - sock string -// - id string -func (_e *ContainerRepo_Expecter) Kill(sock any, id any) *ContainerRepo_Kill_Call { - return &ContainerRepo_Kill_Call{Call: _e.mock.On("Kill", sock, id)} -} - -func (_c *ContainerRepo_Kill_Call) Run(run func(sock string, id string)) *ContainerRepo_Kill_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerRepo_Kill_Call) Return(err error) *ContainerRepo_Kill_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerRepo_Kill_Call) RunAndReturn(run func(sock string, id string) error) *ContainerRepo_Kill_Call { - _c.Call.Return(run) - return _c -} - -// ListAll provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) ListAll(sock string) ([]types.Container, error) { - ret := _mock.Called(sock) - - if len(ret) == 0 { - panic("no return value specified for ListAll") - } - - var r0 []types.Container - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) ([]types.Container, error)); ok { - return returnFunc(sock) - } - if returnFunc, ok := ret.Get(0).(func(string) []types.Container); ok { - r0 = returnFunc(sock) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.Container) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(sock) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ContainerRepo_ListAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAll' -type ContainerRepo_ListAll_Call struct { - *mock.Call -} - -// ListAll is a helper method to define mock.On call -// - sock string -func (_e *ContainerRepo_Expecter) ListAll(sock any) *ContainerRepo_ListAll_Call { - return &ContainerRepo_ListAll_Call{Call: _e.mock.On("ListAll", sock)} -} - -func (_c *ContainerRepo_ListAll_Call) Run(run func(sock string)) *ContainerRepo_ListAll_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ContainerRepo_ListAll_Call) Return(containers []types.Container, err error) *ContainerRepo_ListAll_Call { - _c.Call.Return(containers, err) - return _c -} - -func (_c *ContainerRepo_ListAll_Call) RunAndReturn(run func(sock string) ([]types.Container, error)) *ContainerRepo_ListAll_Call { - _c.Call.Return(run) - return _c -} - -// Logs provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Logs(sock string, id string, tail int) (string, error) { - ret := _mock.Called(sock, id, tail) - - if len(ret) == 0 { - panic("no return value specified for Logs") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, int) (string, error)); ok { - return returnFunc(sock, id, tail) - } - if returnFunc, ok := ret.Get(0).(func(string, string, int) string); ok { - r0 = returnFunc(sock, id, tail) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(string, string, int) error); ok { - r1 = returnFunc(sock, id, tail) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ContainerRepo_Logs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Logs' -type ContainerRepo_Logs_Call struct { - *mock.Call -} - -// Logs is a helper method to define mock.On call -// - sock string -// - id string -// - tail int -func (_e *ContainerRepo_Expecter) Logs(sock any, id any, tail any) *ContainerRepo_Logs_Call { - return &ContainerRepo_Logs_Call{Call: _e.mock.On("Logs", sock, id, tail)} -} - -func (_c *ContainerRepo_Logs_Call) Run(run func(sock string, id string, tail int)) *ContainerRepo_Logs_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 int - if args[2] != nil { - arg2 = args[2].(int) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *ContainerRepo_Logs_Call) Return(s string, err error) *ContainerRepo_Logs_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *ContainerRepo_Logs_Call) RunAndReturn(run func(sock string, id string, tail int) (string, error)) *ContainerRepo_Logs_Call { - _c.Call.Return(run) - return _c -} - -// Pause provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Pause(sock string, id string) error { - ret := _mock.Called(sock, id) - - if len(ret) == 0 { - panic("no return value specified for Pause") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(sock, id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerRepo_Pause_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Pause' -type ContainerRepo_Pause_Call struct { - *mock.Call -} - -// Pause is a helper method to define mock.On call -// - sock string -// - id string -func (_e *ContainerRepo_Expecter) Pause(sock any, id any) *ContainerRepo_Pause_Call { - return &ContainerRepo_Pause_Call{Call: _e.mock.On("Pause", sock, id)} -} - -func (_c *ContainerRepo_Pause_Call) Run(run func(sock string, id string)) *ContainerRepo_Pause_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerRepo_Pause_Call) Return(err error) *ContainerRepo_Pause_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerRepo_Pause_Call) RunAndReturn(run func(sock string, id string) error) *ContainerRepo_Pause_Call { - _c.Call.Return(run) - return _c -} - -// Prune provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Prune(sock string) error { - ret := _mock.Called(sock) - - if len(ret) == 0 { - panic("no return value specified for Prune") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(sock) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerRepo_Prune_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Prune' -type ContainerRepo_Prune_Call struct { - *mock.Call -} - -// Prune is a helper method to define mock.On call -// - sock string -func (_e *ContainerRepo_Expecter) Prune(sock any) *ContainerRepo_Prune_Call { - return &ContainerRepo_Prune_Call{Call: _e.mock.On("Prune", sock)} -} - -func (_c *ContainerRepo_Prune_Call) Run(run func(sock string)) *ContainerRepo_Prune_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ContainerRepo_Prune_Call) Return(err error) *ContainerRepo_Prune_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerRepo_Prune_Call) RunAndReturn(run func(sock string) error) *ContainerRepo_Prune_Call { - _c.Call.Return(run) - return _c -} - -// Remove provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Remove(sock string, id string) error { - ret := _mock.Called(sock, id) - - if len(ret) == 0 { - panic("no return value specified for Remove") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(sock, id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerRepo_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove' -type ContainerRepo_Remove_Call struct { - *mock.Call -} - -// Remove is a helper method to define mock.On call -// - sock string -// - id string -func (_e *ContainerRepo_Expecter) Remove(sock any, id any) *ContainerRepo_Remove_Call { - return &ContainerRepo_Remove_Call{Call: _e.mock.On("Remove", sock, id)} -} - -func (_c *ContainerRepo_Remove_Call) Run(run func(sock string, id string)) *ContainerRepo_Remove_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerRepo_Remove_Call) Return(err error) *ContainerRepo_Remove_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerRepo_Remove_Call) RunAndReturn(run func(sock string, id string) error) *ContainerRepo_Remove_Call { - _c.Call.Return(run) - return _c -} - -// Rename provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Rename(sock string, id string, newName string) error { - ret := _mock.Called(sock, id, newName) - - if len(ret) == 0 { - panic("no return value specified for Rename") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string, string) error); ok { - r0 = returnFunc(sock, id, newName) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerRepo_Rename_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Rename' -type ContainerRepo_Rename_Call struct { - *mock.Call -} - -// Rename is a helper method to define mock.On call -// - sock string -// - id string -// - newName string -func (_e *ContainerRepo_Expecter) Rename(sock any, id any, newName any) *ContainerRepo_Rename_Call { - return &ContainerRepo_Rename_Call{Call: _e.mock.On("Rename", sock, id, newName)} -} - -func (_c *ContainerRepo_Rename_Call) Run(run func(sock string, id string, newName string)) *ContainerRepo_Rename_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *ContainerRepo_Rename_Call) Return(err error) *ContainerRepo_Rename_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerRepo_Rename_Call) RunAndReturn(run func(sock string, id string, newName string) error) *ContainerRepo_Rename_Call { - _c.Call.Return(run) - return _c -} - -// Restart provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Restart(sock string, id string) error { - ret := _mock.Called(sock, id) - - if len(ret) == 0 { - panic("no return value specified for Restart") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(sock, id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerRepo_Restart_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Restart' -type ContainerRepo_Restart_Call struct { - *mock.Call -} - -// Restart is a helper method to define mock.On call -// - sock string -// - id string -func (_e *ContainerRepo_Expecter) Restart(sock any, id any) *ContainerRepo_Restart_Call { - return &ContainerRepo_Restart_Call{Call: _e.mock.On("Restart", sock, id)} -} - -func (_c *ContainerRepo_Restart_Call) Run(run func(sock string, id string)) *ContainerRepo_Restart_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerRepo_Restart_Call) Return(err error) *ContainerRepo_Restart_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerRepo_Restart_Call) RunAndReturn(run func(sock string, id string) error) *ContainerRepo_Restart_Call { - _c.Call.Return(run) - return _c -} - -// Start provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Start(sock string, id string) error { - ret := _mock.Called(sock, id) - - if len(ret) == 0 { - panic("no return value specified for Start") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(sock, id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerRepo_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' -type ContainerRepo_Start_Call struct { - *mock.Call -} - -// Start is a helper method to define mock.On call -// - sock string -// - id string -func (_e *ContainerRepo_Expecter) Start(sock any, id any) *ContainerRepo_Start_Call { - return &ContainerRepo_Start_Call{Call: _e.mock.On("Start", sock, id)} -} - -func (_c *ContainerRepo_Start_Call) Run(run func(sock string, id string)) *ContainerRepo_Start_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerRepo_Start_Call) Return(err error) *ContainerRepo_Start_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerRepo_Start_Call) RunAndReturn(run func(sock string, id string) error) *ContainerRepo_Start_Call { - _c.Call.Return(run) - return _c -} - -// Stop provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Stop(sock string, id string) error { - ret := _mock.Called(sock, id) - - if len(ret) == 0 { - panic("no return value specified for Stop") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(sock, id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerRepo_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop' -type ContainerRepo_Stop_Call struct { - *mock.Call -} - -// Stop is a helper method to define mock.On call -// - sock string -// - id string -func (_e *ContainerRepo_Expecter) Stop(sock any, id any) *ContainerRepo_Stop_Call { - return &ContainerRepo_Stop_Call{Call: _e.mock.On("Stop", sock, id)} -} - -func (_c *ContainerRepo_Stop_Call) Run(run func(sock string, id string)) *ContainerRepo_Stop_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerRepo_Stop_Call) Return(err error) *ContainerRepo_Stop_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerRepo_Stop_Call) RunAndReturn(run func(sock string, id string) error) *ContainerRepo_Stop_Call { - _c.Call.Return(run) - return _c -} - -// Unpause provides a mock function for the type ContainerRepo -func (_mock *ContainerRepo) Unpause(sock string, id string) error { - ret := _mock.Called(sock, id) - - if len(ret) == 0 { - panic("no return value specified for Unpause") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(sock, id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerRepo_Unpause_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Unpause' -type ContainerRepo_Unpause_Call struct { - *mock.Call -} - -// Unpause is a helper method to define mock.On call -// - sock string -// - id string -func (_e *ContainerRepo_Expecter) Unpause(sock any, id any) *ContainerRepo_Unpause_Call { - return &ContainerRepo_Unpause_Call{Call: _e.mock.On("Unpause", sock, id)} -} - -func (_c *ContainerRepo_Unpause_Call) Run(run func(sock string, id string)) *ContainerRepo_Unpause_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerRepo_Unpause_Call) Return(err error) *ContainerRepo_Unpause_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerRepo_Unpause_Call) RunAndReturn(run func(sock string, id string) error) *ContainerRepo_Unpause_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/ContainerVolumeRepo.go b/mocks/biz/ContainerVolumeRepo.go deleted file mode 100644 index 4b154f5cd..000000000 --- a/mocks/biz/ContainerVolumeRepo.go +++ /dev/null @@ -1,283 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewContainerVolumeRepo creates a new instance of ContainerVolumeRepo. 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 NewContainerVolumeRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *ContainerVolumeRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &ContainerVolumeRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// ContainerVolumeRepo is an autogenerated mock type for the ContainerVolumeRepo type -type ContainerVolumeRepo struct { - mock.Mock -} - -type ContainerVolumeRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *ContainerVolumeRepo) EXPECT() *ContainerVolumeRepo_Expecter { - return &ContainerVolumeRepo_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function for the type ContainerVolumeRepo -func (_mock *ContainerVolumeRepo) Create(sock string, req *request.ContainerVolumeCreate) (string, error) { - ret := _mock.Called(sock, req) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, *request.ContainerVolumeCreate) (string, error)); ok { - return returnFunc(sock, req) - } - if returnFunc, ok := ret.Get(0).(func(string, *request.ContainerVolumeCreate) string); ok { - r0 = returnFunc(sock, req) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(string, *request.ContainerVolumeCreate) error); ok { - r1 = returnFunc(sock, req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ContainerVolumeRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type ContainerVolumeRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - sock string -// - req *request.ContainerVolumeCreate -func (_e *ContainerVolumeRepo_Expecter) Create(sock any, req any) *ContainerVolumeRepo_Create_Call { - return &ContainerVolumeRepo_Create_Call{Call: _e.mock.On("Create", sock, req)} -} - -func (_c *ContainerVolumeRepo_Create_Call) Run(run func(sock string, req *request.ContainerVolumeCreate)) *ContainerVolumeRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 *request.ContainerVolumeCreate - if args[1] != nil { - arg1 = args[1].(*request.ContainerVolumeCreate) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerVolumeRepo_Create_Call) Return(s string, err error) *ContainerVolumeRepo_Create_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *ContainerVolumeRepo_Create_Call) RunAndReturn(run func(sock string, req *request.ContainerVolumeCreate) (string, error)) *ContainerVolumeRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type ContainerVolumeRepo -func (_mock *ContainerVolumeRepo) List(sock string) ([]types.ContainerVolume, error) { - ret := _mock.Called(sock) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []types.ContainerVolume - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) ([]types.ContainerVolume, error)); ok { - return returnFunc(sock) - } - if returnFunc, ok := ret.Get(0).(func(string) []types.ContainerVolume); ok { - r0 = returnFunc(sock) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.ContainerVolume) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(sock) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ContainerVolumeRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type ContainerVolumeRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - sock string -func (_e *ContainerVolumeRepo_Expecter) List(sock any) *ContainerVolumeRepo_List_Call { - return &ContainerVolumeRepo_List_Call{Call: _e.mock.On("List", sock)} -} - -func (_c *ContainerVolumeRepo_List_Call) Run(run func(sock string)) *ContainerVolumeRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ContainerVolumeRepo_List_Call) Return(containerVolumes []types.ContainerVolume, err error) *ContainerVolumeRepo_List_Call { - _c.Call.Return(containerVolumes, err) - return _c -} - -func (_c *ContainerVolumeRepo_List_Call) RunAndReturn(run func(sock string) ([]types.ContainerVolume, error)) *ContainerVolumeRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// Prune provides a mock function for the type ContainerVolumeRepo -func (_mock *ContainerVolumeRepo) Prune(sock string) error { - ret := _mock.Called(sock) - - if len(ret) == 0 { - panic("no return value specified for Prune") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(sock) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerVolumeRepo_Prune_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Prune' -type ContainerVolumeRepo_Prune_Call struct { - *mock.Call -} - -// Prune is a helper method to define mock.On call -// - sock string -func (_e *ContainerVolumeRepo_Expecter) Prune(sock any) *ContainerVolumeRepo_Prune_Call { - return &ContainerVolumeRepo_Prune_Call{Call: _e.mock.On("Prune", sock)} -} - -func (_c *ContainerVolumeRepo_Prune_Call) Run(run func(sock string)) *ContainerVolumeRepo_Prune_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ContainerVolumeRepo_Prune_Call) Return(err error) *ContainerVolumeRepo_Prune_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerVolumeRepo_Prune_Call) RunAndReturn(run func(sock string) error) *ContainerVolumeRepo_Prune_Call { - _c.Call.Return(run) - return _c -} - -// Remove provides a mock function for the type ContainerVolumeRepo -func (_mock *ContainerVolumeRepo) Remove(sock string, id string) error { - ret := _mock.Called(sock, id) - - if len(ret) == 0 { - panic("no return value specified for Remove") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(sock, id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ContainerVolumeRepo_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove' -type ContainerVolumeRepo_Remove_Call struct { - *mock.Call -} - -// Remove is a helper method to define mock.On call -// - sock string -// - id string -func (_e *ContainerVolumeRepo_Expecter) Remove(sock any, id any) *ContainerVolumeRepo_Remove_Call { - return &ContainerVolumeRepo_Remove_Call{Call: _e.mock.On("Remove", sock, id)} -} - -func (_c *ContainerVolumeRepo_Remove_Call) Run(run func(sock string, id string)) *ContainerVolumeRepo_Remove_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ContainerVolumeRepo_Remove_Call) Return(err error) *ContainerVolumeRepo_Remove_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ContainerVolumeRepo_Remove_Call) RunAndReturn(run func(sock string, id string) error) *ContainerVolumeRepo_Remove_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/CronRepo.go b/mocks/biz/CronRepo.go deleted file mode 100644 index 4934fd169..000000000 --- a/mocks/biz/CronRepo.go +++ /dev/null @@ -1,779 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewCronRepo creates a new instance of CronRepo. 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 NewCronRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *CronRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &CronRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// CronRepo is an autogenerated mock type for the CronRepo type -type CronRepo struct { - mock.Mock -} - -type CronRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *CronRepo) EXPECT() *CronRepo_Expecter { - return &CronRepo_Expecter{mock: &_m.Mock} -} - -// AddToSystem provides a mock function for the type CronRepo -func (_mock *CronRepo) AddToSystem(cron *biz.Cron) error { - ret := _mock.Called(cron) - - if len(ret) == 0 { - panic("no return value specified for AddToSystem") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Cron) error); ok { - r0 = returnFunc(cron) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CronRepo_AddToSystem_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddToSystem' -type CronRepo_AddToSystem_Call struct { - *mock.Call -} - -// AddToSystem is a helper method to define mock.On call -// - cron *biz.Cron -func (_e *CronRepo_Expecter) AddToSystem(cron any) *CronRepo_AddToSystem_Call { - return &CronRepo_AddToSystem_Call{Call: _e.mock.On("AddToSystem", cron)} -} - -func (_c *CronRepo_AddToSystem_Call) Run(run func(cron *biz.Cron)) *CronRepo_AddToSystem_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Cron - if args[0] != nil { - arg0 = args[0].(*biz.Cron) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CronRepo_AddToSystem_Call) Return(err error) *CronRepo_AddToSystem_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CronRepo_AddToSystem_Call) RunAndReturn(run func(cron *biz.Cron) error) *CronRepo_AddToSystem_Call { - _c.Call.Return(run) - return _c -} - -// Count provides a mock function for the type CronRepo -func (_mock *CronRepo) Count() (int64, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for Count") - } - - var r0 int64 - var r1 error - if returnFunc, ok := ret.Get(0).(func() (int64, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() int64); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(int64) - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CronRepo_Count_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Count' -type CronRepo_Count_Call struct { - *mock.Call -} - -// Count is a helper method to define mock.On call -func (_e *CronRepo_Expecter) Count() *CronRepo_Count_Call { - return &CronRepo_Count_Call{Call: _e.mock.On("Count")} -} - -func (_c *CronRepo_Count_Call) Run(run func()) *CronRepo_Count_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *CronRepo_Count_Call) Return(n int64, err error) *CronRepo_Count_Call { - _c.Call.Return(n, err) - return _c -} - -func (_c *CronRepo_Count_Call) RunAndReturn(run func() (int64, error)) *CronRepo_Count_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function for the type CronRepo -func (_mock *CronRepo) Create(cron *biz.Cron) error { - ret := _mock.Called(cron) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Cron) error); ok { - r0 = returnFunc(cron) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CronRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type CronRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - cron *biz.Cron -func (_e *CronRepo_Expecter) Create(cron any) *CronRepo_Create_Call { - return &CronRepo_Create_Call{Call: _e.mock.On("Create", cron)} -} - -func (_c *CronRepo_Create_Call) Run(run func(cron *biz.Cron)) *CronRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Cron - if args[0] != nil { - arg0 = args[0].(*biz.Cron) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CronRepo_Create_Call) Return(err error) *CronRepo_Create_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CronRepo_Create_Call) RunAndReturn(run func(cron *biz.Cron) error) *CronRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type CronRepo -func (_mock *CronRepo) Delete(cron *biz.Cron) error { - ret := _mock.Called(cron) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Cron) error); ok { - r0 = returnFunc(cron) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CronRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type CronRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - cron *biz.Cron -func (_e *CronRepo_Expecter) Delete(cron any) *CronRepo_Delete_Call { - return &CronRepo_Delete_Call{Call: _e.mock.On("Delete", cron)} -} - -func (_c *CronRepo_Delete_Call) Run(run func(cron *biz.Cron)) *CronRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Cron - if args[0] != nil { - arg0 = args[0].(*biz.Cron) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CronRepo_Delete_Call) Return(err error) *CronRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CronRepo_Delete_Call) RunAndReturn(run func(cron *biz.Cron) error) *CronRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// DeleteFromSystem provides a mock function for the type CronRepo -func (_mock *CronRepo) DeleteFromSystem(cron *biz.Cron) error { - ret := _mock.Called(cron) - - if len(ret) == 0 { - panic("no return value specified for DeleteFromSystem") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Cron) error); ok { - r0 = returnFunc(cron) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CronRepo_DeleteFromSystem_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteFromSystem' -type CronRepo_DeleteFromSystem_Call struct { - *mock.Call -} - -// DeleteFromSystem is a helper method to define mock.On call -// - cron *biz.Cron -func (_e *CronRepo_Expecter) DeleteFromSystem(cron any) *CronRepo_DeleteFromSystem_Call { - return &CronRepo_DeleteFromSystem_Call{Call: _e.mock.On("DeleteFromSystem", cron)} -} - -func (_c *CronRepo_DeleteFromSystem_Call) Run(run func(cron *biz.Cron)) *CronRepo_DeleteFromSystem_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Cron - if args[0] != nil { - arg0 = args[0].(*biz.Cron) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CronRepo_DeleteFromSystem_Call) Return(err error) *CronRepo_DeleteFromSystem_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CronRepo_DeleteFromSystem_Call) RunAndReturn(run func(cron *biz.Cron) error) *CronRepo_DeleteFromSystem_Call { - _c.Call.Return(run) - return _c -} - -// Dos2Unix provides a mock function for the type CronRepo -func (_mock *CronRepo) Dos2Unix(path string) error { - ret := _mock.Called(path) - - if len(ret) == 0 { - panic("no return value specified for Dos2Unix") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(path) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CronRepo_Dos2Unix_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Dos2Unix' -type CronRepo_Dos2Unix_Call struct { - *mock.Call -} - -// Dos2Unix is a helper method to define mock.On call -// - path string -func (_e *CronRepo_Expecter) Dos2Unix(path any) *CronRepo_Dos2Unix_Call { - return &CronRepo_Dos2Unix_Call{Call: _e.mock.On("Dos2Unix", path)} -} - -func (_c *CronRepo_Dos2Unix_Call) Run(run func(path string)) *CronRepo_Dos2Unix_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CronRepo_Dos2Unix_Call) Return(err error) *CronRepo_Dos2Unix_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CronRepo_Dos2Unix_Call) RunAndReturn(run func(path string) error) *CronRepo_Dos2Unix_Call { - _c.Call.Return(run) - return _c -} - -// GenerateScript provides a mock function for the type CronRepo -func (_mock *CronRepo) GenerateScript(typ string, config types.CronConfig, rawScript string) string { - ret := _mock.Called(typ, config, rawScript) - - if len(ret) == 0 { - panic("no return value specified for GenerateScript") - } - - var r0 string - if returnFunc, ok := ret.Get(0).(func(string, types.CronConfig, string) string); ok { - r0 = returnFunc(typ, config, rawScript) - } else { - r0 = ret.Get(0).(string) - } - return r0 -} - -// CronRepo_GenerateScript_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GenerateScript' -type CronRepo_GenerateScript_Call struct { - *mock.Call -} - -// GenerateScript is a helper method to define mock.On call -// - typ string -// - config types.CronConfig -// - rawScript string -func (_e *CronRepo_Expecter) GenerateScript(typ any, config any, rawScript any) *CronRepo_GenerateScript_Call { - return &CronRepo_GenerateScript_Call{Call: _e.mock.On("GenerateScript", typ, config, rawScript)} -} - -func (_c *CronRepo_GenerateScript_Call) Run(run func(typ string, config types.CronConfig, rawScript string)) *CronRepo_GenerateScript_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 types.CronConfig - if args[1] != nil { - arg1 = args[1].(types.CronConfig) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *CronRepo_GenerateScript_Call) Return(s string) *CronRepo_GenerateScript_Call { - _c.Call.Return(s) - return _c -} - -func (_c *CronRepo_GenerateScript_Call) RunAndReturn(run func(typ string, config types.CronConfig, rawScript string) string) *CronRepo_GenerateScript_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type CronRepo -func (_mock *CronRepo) Get(id uint) (*biz.Cron, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.Cron - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.Cron, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.Cron); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.Cron) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// CronRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type CronRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *CronRepo_Expecter) Get(id any) *CronRepo_Get_Call { - return &CronRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *CronRepo_Get_Call) Run(run func(id uint)) *CronRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CronRepo_Get_Call) Return(cron *biz.Cron, err error) *CronRepo_Get_Call { - _c.Call.Return(cron, err) - return _c -} - -func (_c *CronRepo_Get_Call) RunAndReturn(run func(id uint) (*biz.Cron, error)) *CronRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type CronRepo -func (_mock *CronRepo) List(page uint, limit uint) ([]*biz.Cron, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.Cron - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.Cron, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.Cron); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.Cron) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// CronRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type CronRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *CronRepo_Expecter) List(page any, limit any) *CronRepo_List_Call { - return &CronRepo_List_Call{Call: _e.mock.On("List", page, limit)} -} - -func (_c *CronRepo_List_Call) Run(run func(page uint, limit uint)) *CronRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *CronRepo_List_Call) Return(crons []*biz.Cron, n int64, err error) *CronRepo_List_Call { - _c.Call.Return(crons, n, err) - return _c -} - -func (_c *CronRepo_List_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.Cron, int64, error)) *CronRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// RemoveScriptFiles provides a mock function for the type CronRepo -func (_mock *CronRepo) RemoveScriptFiles(shellPath string) error { - ret := _mock.Called(shellPath) - - if len(ret) == 0 { - panic("no return value specified for RemoveScriptFiles") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(shellPath) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CronRepo_RemoveScriptFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveScriptFiles' -type CronRepo_RemoveScriptFiles_Call struct { - *mock.Call -} - -// RemoveScriptFiles is a helper method to define mock.On call -// - shellPath string -func (_e *CronRepo_Expecter) RemoveScriptFiles(shellPath any) *CronRepo_RemoveScriptFiles_Call { - return &CronRepo_RemoveScriptFiles_Call{Call: _e.mock.On("RemoveScriptFiles", shellPath)} -} - -func (_c *CronRepo_RemoveScriptFiles_Call) Run(run func(shellPath string)) *CronRepo_RemoveScriptFiles_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CronRepo_RemoveScriptFiles_Call) Return(err error) *CronRepo_RemoveScriptFiles_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CronRepo_RemoveScriptFiles_Call) RunAndReturn(run func(shellPath string) error) *CronRepo_RemoveScriptFiles_Call { - _c.Call.Return(run) - return _c -} - -// Save provides a mock function for the type CronRepo -func (_mock *CronRepo) Save(cron *biz.Cron) error { - ret := _mock.Called(cron) - - if len(ret) == 0 { - panic("no return value specified for Save") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Cron) error); ok { - r0 = returnFunc(cron) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CronRepo_Save_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Save' -type CronRepo_Save_Call struct { - *mock.Call -} - -// Save is a helper method to define mock.On call -// - cron *biz.Cron -func (_e *CronRepo_Expecter) Save(cron any) *CronRepo_Save_Call { - return &CronRepo_Save_Call{Call: _e.mock.On("Save", cron)} -} - -func (_c *CronRepo_Save_Call) Run(run func(cron *biz.Cron)) *CronRepo_Save_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Cron - if args[0] != nil { - arg0 = args[0].(*biz.Cron) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CronRepo_Save_Call) Return(err error) *CronRepo_Save_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CronRepo_Save_Call) RunAndReturn(run func(cron *biz.Cron) error) *CronRepo_Save_Call { - _c.Call.Return(run) - return _c -} - -// WriteNewScript provides a mock function for the type CronRepo -func (_mock *CronRepo) WriteNewScript(script string) (string, string, error) { - ret := _mock.Called(script) - - if len(ret) == 0 { - panic("no return value specified for WriteNewScript") - } - - var r0 string - var r1 string - var r2 error - if returnFunc, ok := ret.Get(0).(func(string) (string, string, error)); ok { - return returnFunc(script) - } - if returnFunc, ok := ret.Get(0).(func(string) string); ok { - r0 = returnFunc(script) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(string) string); ok { - r1 = returnFunc(script) - } else { - r1 = ret.Get(1).(string) - } - if returnFunc, ok := ret.Get(2).(func(string) error); ok { - r2 = returnFunc(script) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// CronRepo_WriteNewScript_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteNewScript' -type CronRepo_WriteNewScript_Call struct { - *mock.Call -} - -// WriteNewScript is a helper method to define mock.On call -// - script string -func (_e *CronRepo_Expecter) WriteNewScript(script any) *CronRepo_WriteNewScript_Call { - return &CronRepo_WriteNewScript_Call{Call: _e.mock.On("WriteNewScript", script)} -} - -func (_c *CronRepo_WriteNewScript_Call) Run(run func(script string)) *CronRepo_WriteNewScript_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *CronRepo_WriteNewScript_Call) Return(s string, s1 string, err error) *CronRepo_WriteNewScript_Call { - _c.Call.Return(s, s1, err) - return _c -} - -func (_c *CronRepo_WriteNewScript_Call) RunAndReturn(run func(script string) (string, string, error)) *CronRepo_WriteNewScript_Call { - _c.Call.Return(run) - return _c -} - -// WriteScript provides a mock function for the type CronRepo -func (_mock *CronRepo) WriteScript(path string, script string) error { - ret := _mock.Called(path, script) - - if len(ret) == 0 { - panic("no return value specified for WriteScript") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(path, script) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// CronRepo_WriteScript_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteScript' -type CronRepo_WriteScript_Call struct { - *mock.Call -} - -// WriteScript is a helper method to define mock.On call -// - path string -// - script string -func (_e *CronRepo_Expecter) WriteScript(path any, script any) *CronRepo_WriteScript_Call { - return &CronRepo_WriteScript_Call{Call: _e.mock.On("WriteScript", path, script)} -} - -func (_c *CronRepo_WriteScript_Call) Run(run func(path string, script string)) *CronRepo_WriteScript_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *CronRepo_WriteScript_Call) Return(err error) *CronRepo_WriteScript_Call { - _c.Call.Return(err) - return _c -} - -func (_c *CronRepo_WriteScript_Call) RunAndReturn(run func(path string, script string) error) *CronRepo_WriteScript_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/DatabaseElasticsearchRepo.go b/mocks/biz/DatabaseElasticsearchRepo.go deleted file mode 100644 index 449130641..000000000 --- a/mocks/biz/DatabaseElasticsearchRepo.go +++ /dev/null @@ -1,487 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "context" - - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/db" - mock "github.com/stretchr/testify/mock" -) - -// NewDatabaseElasticsearchRepo creates a new instance of DatabaseElasticsearchRepo. 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 NewDatabaseElasticsearchRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *DatabaseElasticsearchRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &DatabaseElasticsearchRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// DatabaseElasticsearchRepo is an autogenerated mock type for the DatabaseElasticsearchRepo type -type DatabaseElasticsearchRepo struct { - mock.Mock -} - -type DatabaseElasticsearchRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *DatabaseElasticsearchRepo) EXPECT() *DatabaseElasticsearchRepo_Expecter { - return &DatabaseElasticsearchRepo_Expecter{mock: &_m.Mock} -} - -// Data provides a mock function for the type DatabaseElasticsearchRepo -func (_mock *DatabaseElasticsearchRepo) Data(ctx context.Context, req *request.DatabaseESData) ([]db.ESDocument, int64, error) { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for Data") - } - - var r0 []db.ESDocument - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseESData) ([]db.ESDocument, int64, error)); ok { - return returnFunc(ctx, req) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseESData) []db.ESDocument); ok { - r0 = returnFunc(ctx, req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.ESDocument) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *request.DatabaseESData) int64); ok { - r1 = returnFunc(ctx, req) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(context.Context, *request.DatabaseESData) error); ok { - r2 = returnFunc(ctx, req) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// DatabaseElasticsearchRepo_Data_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Data' -type DatabaseElasticsearchRepo_Data_Call struct { - *mock.Call -} - -// Data is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseESData -func (_e *DatabaseElasticsearchRepo_Expecter) Data(ctx any, req any) *DatabaseElasticsearchRepo_Data_Call { - return &DatabaseElasticsearchRepo_Data_Call{Call: _e.mock.On("Data", ctx, req)} -} - -func (_c *DatabaseElasticsearchRepo_Data_Call) Run(run func(ctx context.Context, req *request.DatabaseESData)) *DatabaseElasticsearchRepo_Data_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseESData - if args[1] != nil { - arg1 = args[1].(*request.DatabaseESData) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseElasticsearchRepo_Data_Call) Return(eSDocuments []db.ESDocument, n int64, err error) *DatabaseElasticsearchRepo_Data_Call { - _c.Call.Return(eSDocuments, n, err) - return _c -} - -func (_c *DatabaseElasticsearchRepo_Data_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseESData) ([]db.ESDocument, int64, error)) *DatabaseElasticsearchRepo_Data_Call { - _c.Call.Return(run) - return _c -} - -// DocumentDelete provides a mock function for the type DatabaseElasticsearchRepo -func (_mock *DatabaseElasticsearchRepo) DocumentDelete(ctx context.Context, req *request.DatabaseESDocumentDelete) error { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for DocumentDelete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseESDocumentDelete) error); ok { - r0 = returnFunc(ctx, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseElasticsearchRepo_DocumentDelete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DocumentDelete' -type DatabaseElasticsearchRepo_DocumentDelete_Call struct { - *mock.Call -} - -// DocumentDelete is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseESDocumentDelete -func (_e *DatabaseElasticsearchRepo_Expecter) DocumentDelete(ctx any, req any) *DatabaseElasticsearchRepo_DocumentDelete_Call { - return &DatabaseElasticsearchRepo_DocumentDelete_Call{Call: _e.mock.On("DocumentDelete", ctx, req)} -} - -func (_c *DatabaseElasticsearchRepo_DocumentDelete_Call) Run(run func(ctx context.Context, req *request.DatabaseESDocumentDelete)) *DatabaseElasticsearchRepo_DocumentDelete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseESDocumentDelete - if args[1] != nil { - arg1 = args[1].(*request.DatabaseESDocumentDelete) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseElasticsearchRepo_DocumentDelete_Call) Return(err error) *DatabaseElasticsearchRepo_DocumentDelete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseElasticsearchRepo_DocumentDelete_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseESDocumentDelete) error) *DatabaseElasticsearchRepo_DocumentDelete_Call { - _c.Call.Return(run) - return _c -} - -// DocumentGet provides a mock function for the type DatabaseElasticsearchRepo -func (_mock *DatabaseElasticsearchRepo) DocumentGet(ctx context.Context, req *request.DatabaseESDocumentGet) (*db.ESDocument, error) { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for DocumentGet") - } - - var r0 *db.ESDocument - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseESDocumentGet) (*db.ESDocument, error)); ok { - return returnFunc(ctx, req) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseESDocumentGet) *db.ESDocument); ok { - r0 = returnFunc(ctx, req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*db.ESDocument) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *request.DatabaseESDocumentGet) error); ok { - r1 = returnFunc(ctx, req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseElasticsearchRepo_DocumentGet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DocumentGet' -type DatabaseElasticsearchRepo_DocumentGet_Call struct { - *mock.Call -} - -// DocumentGet is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseESDocumentGet -func (_e *DatabaseElasticsearchRepo_Expecter) DocumentGet(ctx any, req any) *DatabaseElasticsearchRepo_DocumentGet_Call { - return &DatabaseElasticsearchRepo_DocumentGet_Call{Call: _e.mock.On("DocumentGet", ctx, req)} -} - -func (_c *DatabaseElasticsearchRepo_DocumentGet_Call) Run(run func(ctx context.Context, req *request.DatabaseESDocumentGet)) *DatabaseElasticsearchRepo_DocumentGet_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseESDocumentGet - if args[1] != nil { - arg1 = args[1].(*request.DatabaseESDocumentGet) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseElasticsearchRepo_DocumentGet_Call) Return(eSDocument *db.ESDocument, err error) *DatabaseElasticsearchRepo_DocumentGet_Call { - _c.Call.Return(eSDocument, err) - return _c -} - -func (_c *DatabaseElasticsearchRepo_DocumentGet_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseESDocumentGet) (*db.ESDocument, error)) *DatabaseElasticsearchRepo_DocumentGet_Call { - _c.Call.Return(run) - return _c -} - -// DocumentSet provides a mock function for the type DatabaseElasticsearchRepo -func (_mock *DatabaseElasticsearchRepo) DocumentSet(ctx context.Context, req *request.DatabaseESDocumentSet) error { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for DocumentSet") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseESDocumentSet) error); ok { - r0 = returnFunc(ctx, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseElasticsearchRepo_DocumentSet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DocumentSet' -type DatabaseElasticsearchRepo_DocumentSet_Call struct { - *mock.Call -} - -// DocumentSet is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseESDocumentSet -func (_e *DatabaseElasticsearchRepo_Expecter) DocumentSet(ctx any, req any) *DatabaseElasticsearchRepo_DocumentSet_Call { - return &DatabaseElasticsearchRepo_DocumentSet_Call{Call: _e.mock.On("DocumentSet", ctx, req)} -} - -func (_c *DatabaseElasticsearchRepo_DocumentSet_Call) Run(run func(ctx context.Context, req *request.DatabaseESDocumentSet)) *DatabaseElasticsearchRepo_DocumentSet_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseESDocumentSet - if args[1] != nil { - arg1 = args[1].(*request.DatabaseESDocumentSet) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseElasticsearchRepo_DocumentSet_Call) Return(err error) *DatabaseElasticsearchRepo_DocumentSet_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseElasticsearchRepo_DocumentSet_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseESDocumentSet) error) *DatabaseElasticsearchRepo_DocumentSet_Call { - _c.Call.Return(run) - return _c -} - -// IndexCreate provides a mock function for the type DatabaseElasticsearchRepo -func (_mock *DatabaseElasticsearchRepo) IndexCreate(ctx context.Context, req *request.DatabaseESIndexCreate) error { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for IndexCreate") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseESIndexCreate) error); ok { - r0 = returnFunc(ctx, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseElasticsearchRepo_IndexCreate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IndexCreate' -type DatabaseElasticsearchRepo_IndexCreate_Call struct { - *mock.Call -} - -// IndexCreate is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseESIndexCreate -func (_e *DatabaseElasticsearchRepo_Expecter) IndexCreate(ctx any, req any) *DatabaseElasticsearchRepo_IndexCreate_Call { - return &DatabaseElasticsearchRepo_IndexCreate_Call{Call: _e.mock.On("IndexCreate", ctx, req)} -} - -func (_c *DatabaseElasticsearchRepo_IndexCreate_Call) Run(run func(ctx context.Context, req *request.DatabaseESIndexCreate)) *DatabaseElasticsearchRepo_IndexCreate_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseESIndexCreate - if args[1] != nil { - arg1 = args[1].(*request.DatabaseESIndexCreate) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseElasticsearchRepo_IndexCreate_Call) Return(err error) *DatabaseElasticsearchRepo_IndexCreate_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseElasticsearchRepo_IndexCreate_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseESIndexCreate) error) *DatabaseElasticsearchRepo_IndexCreate_Call { - _c.Call.Return(run) - return _c -} - -// IndexDelete provides a mock function for the type DatabaseElasticsearchRepo -func (_mock *DatabaseElasticsearchRepo) IndexDelete(ctx context.Context, req *request.DatabaseESIndexDelete) error { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for IndexDelete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseESIndexDelete) error); ok { - r0 = returnFunc(ctx, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseElasticsearchRepo_IndexDelete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IndexDelete' -type DatabaseElasticsearchRepo_IndexDelete_Call struct { - *mock.Call -} - -// IndexDelete is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseESIndexDelete -func (_e *DatabaseElasticsearchRepo_Expecter) IndexDelete(ctx any, req any) *DatabaseElasticsearchRepo_IndexDelete_Call { - return &DatabaseElasticsearchRepo_IndexDelete_Call{Call: _e.mock.On("IndexDelete", ctx, req)} -} - -func (_c *DatabaseElasticsearchRepo_IndexDelete_Call) Run(run func(ctx context.Context, req *request.DatabaseESIndexDelete)) *DatabaseElasticsearchRepo_IndexDelete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseESIndexDelete - if args[1] != nil { - arg1 = args[1].(*request.DatabaseESIndexDelete) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseElasticsearchRepo_IndexDelete_Call) Return(err error) *DatabaseElasticsearchRepo_IndexDelete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseElasticsearchRepo_IndexDelete_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseESIndexDelete) error) *DatabaseElasticsearchRepo_IndexDelete_Call { - _c.Call.Return(run) - return _c -} - -// Indices provides a mock function for the type DatabaseElasticsearchRepo -func (_mock *DatabaseElasticsearchRepo) Indices(ctx context.Context, req *request.DatabaseESIndices) ([]db.ESIndex, error) { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for Indices") - } - - var r0 []db.ESIndex - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseESIndices) ([]db.ESIndex, error)); ok { - return returnFunc(ctx, req) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseESIndices) []db.ESIndex); ok { - r0 = returnFunc(ctx, req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.ESIndex) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *request.DatabaseESIndices) error); ok { - r1 = returnFunc(ctx, req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseElasticsearchRepo_Indices_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Indices' -type DatabaseElasticsearchRepo_Indices_Call struct { - *mock.Call -} - -// Indices is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseESIndices -func (_e *DatabaseElasticsearchRepo_Expecter) Indices(ctx any, req any) *DatabaseElasticsearchRepo_Indices_Call { - return &DatabaseElasticsearchRepo_Indices_Call{Call: _e.mock.On("Indices", ctx, req)} -} - -func (_c *DatabaseElasticsearchRepo_Indices_Call) Run(run func(ctx context.Context, req *request.DatabaseESIndices)) *DatabaseElasticsearchRepo_Indices_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseESIndices - if args[1] != nil { - arg1 = args[1].(*request.DatabaseESIndices) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseElasticsearchRepo_Indices_Call) Return(eSIndexs []db.ESIndex, err error) *DatabaseElasticsearchRepo_Indices_Call { - _c.Call.Return(eSIndexs, err) - return _c -} - -func (_c *DatabaseElasticsearchRepo_Indices_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseESIndices) ([]db.ESIndex, error)) *DatabaseElasticsearchRepo_Indices_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/DatabaseRedisRepo.go b/mocks/biz/DatabaseRedisRepo.go deleted file mode 100644 index 50fa7bad6..000000000 --- a/mocks/biz/DatabaseRedisRepo.go +++ /dev/null @@ -1,542 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "context" - - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/db" - mock "github.com/stretchr/testify/mock" -) - -// NewDatabaseRedisRepo creates a new instance of DatabaseRedisRepo. 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 NewDatabaseRedisRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *DatabaseRedisRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &DatabaseRedisRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// DatabaseRedisRepo is an autogenerated mock type for the DatabaseRedisRepo type -type DatabaseRedisRepo struct { - mock.Mock -} - -type DatabaseRedisRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *DatabaseRedisRepo) EXPECT() *DatabaseRedisRepo_Expecter { - return &DatabaseRedisRepo_Expecter{mock: &_m.Mock} -} - -// Clear provides a mock function for the type DatabaseRedisRepo -func (_mock *DatabaseRedisRepo) Clear(ctx context.Context, req *request.DatabaseRedisClear) error { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for Clear") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseRedisClear) error); ok { - r0 = returnFunc(ctx, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseRedisRepo_Clear_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Clear' -type DatabaseRedisRepo_Clear_Call struct { - *mock.Call -} - -// Clear is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseRedisClear -func (_e *DatabaseRedisRepo_Expecter) Clear(ctx any, req any) *DatabaseRedisRepo_Clear_Call { - return &DatabaseRedisRepo_Clear_Call{Call: _e.mock.On("Clear", ctx, req)} -} - -func (_c *DatabaseRedisRepo_Clear_Call) Run(run func(ctx context.Context, req *request.DatabaseRedisClear)) *DatabaseRedisRepo_Clear_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseRedisClear - if args[1] != nil { - arg1 = args[1].(*request.DatabaseRedisClear) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseRedisRepo_Clear_Call) Return(err error) *DatabaseRedisRepo_Clear_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseRedisRepo_Clear_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseRedisClear) error) *DatabaseRedisRepo_Clear_Call { - _c.Call.Return(run) - return _c -} - -// Data provides a mock function for the type DatabaseRedisRepo -func (_mock *DatabaseRedisRepo) Data(ctx context.Context, req *request.DatabaseRedisData) ([]db.RedisKV, int, error) { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for Data") - } - - var r0 []db.RedisKV - var r1 int - var r2 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseRedisData) ([]db.RedisKV, int, error)); ok { - return returnFunc(ctx, req) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseRedisData) []db.RedisKV); ok { - r0 = returnFunc(ctx, req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.RedisKV) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *request.DatabaseRedisData) int); ok { - r1 = returnFunc(ctx, req) - } else { - r1 = ret.Get(1).(int) - } - if returnFunc, ok := ret.Get(2).(func(context.Context, *request.DatabaseRedisData) error); ok { - r2 = returnFunc(ctx, req) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// DatabaseRedisRepo_Data_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Data' -type DatabaseRedisRepo_Data_Call struct { - *mock.Call -} - -// Data is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseRedisData -func (_e *DatabaseRedisRepo_Expecter) Data(ctx any, req any) *DatabaseRedisRepo_Data_Call { - return &DatabaseRedisRepo_Data_Call{Call: _e.mock.On("Data", ctx, req)} -} - -func (_c *DatabaseRedisRepo_Data_Call) Run(run func(ctx context.Context, req *request.DatabaseRedisData)) *DatabaseRedisRepo_Data_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseRedisData - if args[1] != nil { - arg1 = args[1].(*request.DatabaseRedisData) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseRedisRepo_Data_Call) Return(redisKVs []db.RedisKV, n int, err error) *DatabaseRedisRepo_Data_Call { - _c.Call.Return(redisKVs, n, err) - return _c -} - -func (_c *DatabaseRedisRepo_Data_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseRedisData) ([]db.RedisKV, int, error)) *DatabaseRedisRepo_Data_Call { - _c.Call.Return(run) - return _c -} - -// Databases provides a mock function for the type DatabaseRedisRepo -func (_mock *DatabaseRedisRepo) Databases(ctx context.Context, req *request.DatabaseRedisDatabases) (int, error) { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for Databases") - } - - var r0 int - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseRedisDatabases) (int, error)); ok { - return returnFunc(ctx, req) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseRedisDatabases) int); ok { - r0 = returnFunc(ctx, req) - } else { - r0 = ret.Get(0).(int) - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *request.DatabaseRedisDatabases) error); ok { - r1 = returnFunc(ctx, req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseRedisRepo_Databases_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Databases' -type DatabaseRedisRepo_Databases_Call struct { - *mock.Call -} - -// Databases is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseRedisDatabases -func (_e *DatabaseRedisRepo_Expecter) Databases(ctx any, req any) *DatabaseRedisRepo_Databases_Call { - return &DatabaseRedisRepo_Databases_Call{Call: _e.mock.On("Databases", ctx, req)} -} - -func (_c *DatabaseRedisRepo_Databases_Call) Run(run func(ctx context.Context, req *request.DatabaseRedisDatabases)) *DatabaseRedisRepo_Databases_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseRedisDatabases - if args[1] != nil { - arg1 = args[1].(*request.DatabaseRedisDatabases) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseRedisRepo_Databases_Call) Return(n int, err error) *DatabaseRedisRepo_Databases_Call { - _c.Call.Return(n, err) - return _c -} - -func (_c *DatabaseRedisRepo_Databases_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseRedisDatabases) (int, error)) *DatabaseRedisRepo_Databases_Call { - _c.Call.Return(run) - return _c -} - -// KeyDelete provides a mock function for the type DatabaseRedisRepo -func (_mock *DatabaseRedisRepo) KeyDelete(ctx context.Context, req *request.DatabaseRedisKeyDelete) error { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for KeyDelete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseRedisKeyDelete) error); ok { - r0 = returnFunc(ctx, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseRedisRepo_KeyDelete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'KeyDelete' -type DatabaseRedisRepo_KeyDelete_Call struct { - *mock.Call -} - -// KeyDelete is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseRedisKeyDelete -func (_e *DatabaseRedisRepo_Expecter) KeyDelete(ctx any, req any) *DatabaseRedisRepo_KeyDelete_Call { - return &DatabaseRedisRepo_KeyDelete_Call{Call: _e.mock.On("KeyDelete", ctx, req)} -} - -func (_c *DatabaseRedisRepo_KeyDelete_Call) Run(run func(ctx context.Context, req *request.DatabaseRedisKeyDelete)) *DatabaseRedisRepo_KeyDelete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseRedisKeyDelete - if args[1] != nil { - arg1 = args[1].(*request.DatabaseRedisKeyDelete) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseRedisRepo_KeyDelete_Call) Return(err error) *DatabaseRedisRepo_KeyDelete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseRedisRepo_KeyDelete_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseRedisKeyDelete) error) *DatabaseRedisRepo_KeyDelete_Call { - _c.Call.Return(run) - return _c -} - -// KeyGet provides a mock function for the type DatabaseRedisRepo -func (_mock *DatabaseRedisRepo) KeyGet(ctx context.Context, req *request.DatabaseRedisKeyGet) (*db.RedisKV, error) { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for KeyGet") - } - - var r0 *db.RedisKV - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseRedisKeyGet) (*db.RedisKV, error)); ok { - return returnFunc(ctx, req) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseRedisKeyGet) *db.RedisKV); ok { - r0 = returnFunc(ctx, req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*db.RedisKV) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *request.DatabaseRedisKeyGet) error); ok { - r1 = returnFunc(ctx, req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseRedisRepo_KeyGet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'KeyGet' -type DatabaseRedisRepo_KeyGet_Call struct { - *mock.Call -} - -// KeyGet is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseRedisKeyGet -func (_e *DatabaseRedisRepo_Expecter) KeyGet(ctx any, req any) *DatabaseRedisRepo_KeyGet_Call { - return &DatabaseRedisRepo_KeyGet_Call{Call: _e.mock.On("KeyGet", ctx, req)} -} - -func (_c *DatabaseRedisRepo_KeyGet_Call) Run(run func(ctx context.Context, req *request.DatabaseRedisKeyGet)) *DatabaseRedisRepo_KeyGet_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseRedisKeyGet - if args[1] != nil { - arg1 = args[1].(*request.DatabaseRedisKeyGet) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseRedisRepo_KeyGet_Call) Return(redisKV *db.RedisKV, err error) *DatabaseRedisRepo_KeyGet_Call { - _c.Call.Return(redisKV, err) - return _c -} - -func (_c *DatabaseRedisRepo_KeyGet_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseRedisKeyGet) (*db.RedisKV, error)) *DatabaseRedisRepo_KeyGet_Call { - _c.Call.Return(run) - return _c -} - -// KeyRename provides a mock function for the type DatabaseRedisRepo -func (_mock *DatabaseRedisRepo) KeyRename(ctx context.Context, req *request.DatabaseRedisKeyRename) error { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for KeyRename") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseRedisKeyRename) error); ok { - r0 = returnFunc(ctx, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseRedisRepo_KeyRename_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'KeyRename' -type DatabaseRedisRepo_KeyRename_Call struct { - *mock.Call -} - -// KeyRename is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseRedisKeyRename -func (_e *DatabaseRedisRepo_Expecter) KeyRename(ctx any, req any) *DatabaseRedisRepo_KeyRename_Call { - return &DatabaseRedisRepo_KeyRename_Call{Call: _e.mock.On("KeyRename", ctx, req)} -} - -func (_c *DatabaseRedisRepo_KeyRename_Call) Run(run func(ctx context.Context, req *request.DatabaseRedisKeyRename)) *DatabaseRedisRepo_KeyRename_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseRedisKeyRename - if args[1] != nil { - arg1 = args[1].(*request.DatabaseRedisKeyRename) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseRedisRepo_KeyRename_Call) Return(err error) *DatabaseRedisRepo_KeyRename_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseRedisRepo_KeyRename_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseRedisKeyRename) error) *DatabaseRedisRepo_KeyRename_Call { - _c.Call.Return(run) - return _c -} - -// KeySet provides a mock function for the type DatabaseRedisRepo -func (_mock *DatabaseRedisRepo) KeySet(ctx context.Context, req *request.DatabaseRedisKeySet) error { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for KeySet") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseRedisKeySet) error); ok { - r0 = returnFunc(ctx, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseRedisRepo_KeySet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'KeySet' -type DatabaseRedisRepo_KeySet_Call struct { - *mock.Call -} - -// KeySet is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseRedisKeySet -func (_e *DatabaseRedisRepo_Expecter) KeySet(ctx any, req any) *DatabaseRedisRepo_KeySet_Call { - return &DatabaseRedisRepo_KeySet_Call{Call: _e.mock.On("KeySet", ctx, req)} -} - -func (_c *DatabaseRedisRepo_KeySet_Call) Run(run func(ctx context.Context, req *request.DatabaseRedisKeySet)) *DatabaseRedisRepo_KeySet_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseRedisKeySet - if args[1] != nil { - arg1 = args[1].(*request.DatabaseRedisKeySet) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseRedisRepo_KeySet_Call) Return(err error) *DatabaseRedisRepo_KeySet_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseRedisRepo_KeySet_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseRedisKeySet) error) *DatabaseRedisRepo_KeySet_Call { - _c.Call.Return(run) - return _c -} - -// KeyTTL provides a mock function for the type DatabaseRedisRepo -func (_mock *DatabaseRedisRepo) KeyTTL(ctx context.Context, req *request.DatabaseRedisKeyTTL) error { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for KeyTTL") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseRedisKeyTTL) error); ok { - r0 = returnFunc(ctx, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseRedisRepo_KeyTTL_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'KeyTTL' -type DatabaseRedisRepo_KeyTTL_Call struct { - *mock.Call -} - -// KeyTTL is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseRedisKeyTTL -func (_e *DatabaseRedisRepo_Expecter) KeyTTL(ctx any, req any) *DatabaseRedisRepo_KeyTTL_Call { - return &DatabaseRedisRepo_KeyTTL_Call{Call: _e.mock.On("KeyTTL", ctx, req)} -} - -func (_c *DatabaseRedisRepo_KeyTTL_Call) Run(run func(ctx context.Context, req *request.DatabaseRedisKeyTTL)) *DatabaseRedisRepo_KeyTTL_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseRedisKeyTTL - if args[1] != nil { - arg1 = args[1].(*request.DatabaseRedisKeyTTL) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseRedisRepo_KeyTTL_Call) Return(err error) *DatabaseRedisRepo_KeyTTL_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseRedisRepo_KeyTTL_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseRedisKeyTTL) error) *DatabaseRedisRepo_KeyTTL_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/DatabaseRepo.go b/mocks/biz/DatabaseRepo.go deleted file mode 100644 index 5cd9b685e..000000000 --- a/mocks/biz/DatabaseRepo.go +++ /dev/null @@ -1,315 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "context" - - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/pkg/db" - mock "github.com/stretchr/testify/mock" -) - -// NewDatabaseRepo creates a new instance of DatabaseRepo. 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 NewDatabaseRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *DatabaseRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &DatabaseRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// DatabaseRepo is an autogenerated mock type for the DatabaseRepo type -type DatabaseRepo struct { - mock.Mock -} - -type DatabaseRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *DatabaseRepo) EXPECT() *DatabaseRepo_Expecter { - return &DatabaseRepo_Expecter{mock: &_m.Mock} -} - -// DatabasesOf provides a mock function for the type DatabaseRepo -func (_mock *DatabaseRepo) DatabasesOf(ctx context.Context, server *biz.DatabaseServer) ([]*biz.Database, error) { - ret := _mock.Called(ctx, server) - - if len(ret) == 0 { - panic("no return value specified for DatabasesOf") - } - - var r0 []*biz.Database - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *biz.DatabaseServer) ([]*biz.Database, error)); ok { - return returnFunc(ctx, server) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *biz.DatabaseServer) []*biz.Database); ok { - r0 = returnFunc(ctx, server) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.Database) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *biz.DatabaseServer) error); ok { - r1 = returnFunc(ctx, server) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseRepo_DatabasesOf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DatabasesOf' -type DatabaseRepo_DatabasesOf_Call struct { - *mock.Call -} - -// DatabasesOf is a helper method to define mock.On call -// - ctx context.Context -// - server *biz.DatabaseServer -func (_e *DatabaseRepo_Expecter) DatabasesOf(ctx any, server any) *DatabaseRepo_DatabasesOf_Call { - return &DatabaseRepo_DatabasesOf_Call{Call: _e.mock.On("DatabasesOf", ctx, server)} -} - -func (_c *DatabaseRepo_DatabasesOf_Call) Run(run func(ctx context.Context, server *biz.DatabaseServer)) *DatabaseRepo_DatabasesOf_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *biz.DatabaseServer - if args[1] != nil { - arg1 = args[1].(*biz.DatabaseServer) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseRepo_DatabasesOf_Call) Return(databases []*biz.Database, err error) *DatabaseRepo_DatabasesOf_Call { - _c.Call.Return(databases, err) - return _c -} - -func (_c *DatabaseRepo_DatabasesOf_Call) RunAndReturn(run func(ctx context.Context, server *biz.DatabaseServer) ([]*biz.Database, error)) *DatabaseRepo_DatabasesOf_Call { - _c.Call.Return(run) - return _c -} - -// ListServers provides a mock function for the type DatabaseRepo -func (_mock *DatabaseRepo) ListServers(typ string) ([]*biz.DatabaseServer, error) { - ret := _mock.Called(typ) - - if len(ret) == 0 { - panic("no return value specified for ListServers") - } - - var r0 []*biz.DatabaseServer - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) ([]*biz.DatabaseServer, error)); ok { - return returnFunc(typ) - } - if returnFunc, ok := ret.Get(0).(func(string) []*biz.DatabaseServer); ok { - r0 = returnFunc(typ) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.DatabaseServer) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(typ) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseRepo_ListServers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListServers' -type DatabaseRepo_ListServers_Call struct { - *mock.Call -} - -// ListServers is a helper method to define mock.On call -// - typ string -func (_e *DatabaseRepo_Expecter) ListServers(typ any) *DatabaseRepo_ListServers_Call { - return &DatabaseRepo_ListServers_Call{Call: _e.mock.On("ListServers", typ)} -} - -func (_c *DatabaseRepo_ListServers_Call) Run(run func(typ string)) *DatabaseRepo_ListServers_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *DatabaseRepo_ListServers_Call) Return(databaseServers []*biz.DatabaseServer, err error) *DatabaseRepo_ListServers_Call { - _c.Call.Return(databaseServers, err) - return _c -} - -func (_c *DatabaseRepo_ListServers_Call) RunAndReturn(run func(typ string) ([]*biz.DatabaseServer, error)) *DatabaseRepo_ListServers_Call { - _c.Call.Return(run) - return _c -} - -// Mongo provides a mock function for the type DatabaseRepo -func (_mock *DatabaseRepo) Mongo(ctx context.Context, server *biz.DatabaseServer) (*db.MongoDB, error) { - ret := _mock.Called(ctx, server) - - if len(ret) == 0 { - panic("no return value specified for Mongo") - } - - var r0 *db.MongoDB - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *biz.DatabaseServer) (*db.MongoDB, error)); ok { - return returnFunc(ctx, server) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *biz.DatabaseServer) *db.MongoDB); ok { - r0 = returnFunc(ctx, server) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*db.MongoDB) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *biz.DatabaseServer) error); ok { - r1 = returnFunc(ctx, server) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseRepo_Mongo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Mongo' -type DatabaseRepo_Mongo_Call struct { - *mock.Call -} - -// Mongo is a helper method to define mock.On call -// - ctx context.Context -// - server *biz.DatabaseServer -func (_e *DatabaseRepo_Expecter) Mongo(ctx any, server any) *DatabaseRepo_Mongo_Call { - return &DatabaseRepo_Mongo_Call{Call: _e.mock.On("Mongo", ctx, server)} -} - -func (_c *DatabaseRepo_Mongo_Call) Run(run func(ctx context.Context, server *biz.DatabaseServer)) *DatabaseRepo_Mongo_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *biz.DatabaseServer - if args[1] != nil { - arg1 = args[1].(*biz.DatabaseServer) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseRepo_Mongo_Call) Return(mongoDB *db.MongoDB, err error) *DatabaseRepo_Mongo_Call { - _c.Call.Return(mongoDB, err) - return _c -} - -func (_c *DatabaseRepo_Mongo_Call) RunAndReturn(run func(ctx context.Context, server *biz.DatabaseServer) (*db.MongoDB, error)) *DatabaseRepo_Mongo_Call { - _c.Call.Return(run) - return _c -} - -// Operator provides a mock function for the type DatabaseRepo -func (_mock *DatabaseRepo) Operator(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) { - ret := _mock.Called(ctx, server) - - if len(ret) == 0 { - panic("no return value specified for Operator") - } - - var r0 db.Operator - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *biz.DatabaseServer) (db.Operator, error)); ok { - return returnFunc(ctx, server) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *biz.DatabaseServer) db.Operator); ok { - r0 = returnFunc(ctx, server) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(db.Operator) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *biz.DatabaseServer) error); ok { - r1 = returnFunc(ctx, server) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseRepo_Operator_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Operator' -type DatabaseRepo_Operator_Call struct { - *mock.Call -} - -// Operator is a helper method to define mock.On call -// - ctx context.Context -// - server *biz.DatabaseServer -func (_e *DatabaseRepo_Expecter) Operator(ctx any, server any) *DatabaseRepo_Operator_Call { - return &DatabaseRepo_Operator_Call{Call: _e.mock.On("Operator", ctx, server)} -} - -func (_c *DatabaseRepo_Operator_Call) Run(run func(ctx context.Context, server *biz.DatabaseServer)) *DatabaseRepo_Operator_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *biz.DatabaseServer - if args[1] != nil { - arg1 = args[1].(*biz.DatabaseServer) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseRepo_Operator_Call) Return(operator db.Operator, err error) *DatabaseRepo_Operator_Call { - _c.Call.Return(operator, err) - return _c -} - -func (_c *DatabaseRepo_Operator_Call) RunAndReturn(run func(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error)) *DatabaseRepo_Operator_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/DatabaseServerRepo.go b/mocks/biz/DatabaseServerRepo.go deleted file mode 100644 index df5db1501..000000000 --- a/mocks/biz/DatabaseServerRepo.go +++ /dev/null @@ -1,932 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "context" - - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/db" - mock "github.com/stretchr/testify/mock" -) - -// NewDatabaseServerRepo creates a new instance of DatabaseServerRepo. 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 NewDatabaseServerRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *DatabaseServerRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &DatabaseServerRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// DatabaseServerRepo is an autogenerated mock type for the DatabaseServerRepo type -type DatabaseServerRepo struct { - mock.Mock -} - -type DatabaseServerRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *DatabaseServerRepo) EXPECT() *DatabaseServerRepo_Expecter { - return &DatabaseServerRepo_Expecter{mock: &_m.Mock} -} - -// CheckServer provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) CheckServer(ctx context.Context, server *biz.DatabaseServer) bool { - ret := _mock.Called(ctx, server) - - if len(ret) == 0 { - panic("no return value specified for CheckServer") - } - - var r0 bool - if returnFunc, ok := ret.Get(0).(func(context.Context, *biz.DatabaseServer) bool); ok { - r0 = returnFunc(ctx, server) - } else { - r0 = ret.Get(0).(bool) - } - return r0 -} - -// DatabaseServerRepo_CheckServer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckServer' -type DatabaseServerRepo_CheckServer_Call struct { - *mock.Call -} - -// CheckServer is a helper method to define mock.On call -// - ctx context.Context -// - server *biz.DatabaseServer -func (_e *DatabaseServerRepo_Expecter) CheckServer(ctx any, server any) *DatabaseServerRepo_CheckServer_Call { - return &DatabaseServerRepo_CheckServer_Call{Call: _e.mock.On("CheckServer", ctx, server)} -} - -func (_c *DatabaseServerRepo_CheckServer_Call) Run(run func(ctx context.Context, server *biz.DatabaseServer)) *DatabaseServerRepo_CheckServer_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *biz.DatabaseServer - if args[1] != nil { - arg1 = args[1].(*biz.DatabaseServer) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_CheckServer_Call) Return(b bool) *DatabaseServerRepo_CheckServer_Call { - _c.Call.Return(b) - return _c -} - -func (_c *DatabaseServerRepo_CheckServer_Call) RunAndReturn(run func(ctx context.Context, server *biz.DatabaseServer) bool) *DatabaseServerRepo_CheckServer_Call { - _c.Call.Return(run) - return _c -} - -// ClearUsers provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) ClearUsers(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for ClearUsers") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseServerRepo_ClearUsers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearUsers' -type DatabaseServerRepo_ClearUsers_Call struct { - *mock.Call -} - -// ClearUsers is a helper method to define mock.On call -// - id uint -func (_e *DatabaseServerRepo_Expecter) ClearUsers(id any) *DatabaseServerRepo_ClearUsers_Call { - return &DatabaseServerRepo_ClearUsers_Call{Call: _e.mock.On("ClearUsers", id)} -} - -func (_c *DatabaseServerRepo_ClearUsers_Call) Run(run func(id uint)) *DatabaseServerRepo_ClearUsers_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_ClearUsers_Call) Return(err error) *DatabaseServerRepo_ClearUsers_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseServerRepo_ClearUsers_Call) RunAndReturn(run func(id uint) error) *DatabaseServerRepo_ClearUsers_Call { - _c.Call.Return(run) - return _c -} - -// Count provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) Count() (int64, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for Count") - } - - var r0 int64 - var r1 error - if returnFunc, ok := ret.Get(0).(func() (int64, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() int64); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(int64) - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseServerRepo_Count_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Count' -type DatabaseServerRepo_Count_Call struct { - *mock.Call -} - -// Count is a helper method to define mock.On call -func (_e *DatabaseServerRepo_Expecter) Count() *DatabaseServerRepo_Count_Call { - return &DatabaseServerRepo_Count_Call{Call: _e.mock.On("Count")} -} - -func (_c *DatabaseServerRepo_Count_Call) Run(run func()) *DatabaseServerRepo_Count_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *DatabaseServerRepo_Count_Call) Return(n int64, err error) *DatabaseServerRepo_Count_Call { - _c.Call.Return(n, err) - return _c -} - -func (_c *DatabaseServerRepo_Count_Call) RunAndReturn(run func() (int64, error)) *DatabaseServerRepo_Count_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) Create(server *biz.DatabaseServer) error { - ret := _mock.Called(server) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.DatabaseServer) error); ok { - r0 = returnFunc(server) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseServerRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type DatabaseServerRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - server *biz.DatabaseServer -func (_e *DatabaseServerRepo_Expecter) Create(server any) *DatabaseServerRepo_Create_Call { - return &DatabaseServerRepo_Create_Call{Call: _e.mock.On("Create", server)} -} - -func (_c *DatabaseServerRepo_Create_Call) Run(run func(server *biz.DatabaseServer)) *DatabaseServerRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.DatabaseServer - if args[0] != nil { - arg0 = args[0].(*biz.DatabaseServer) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_Create_Call) Return(err error) *DatabaseServerRepo_Create_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseServerRepo_Create_Call) RunAndReturn(run func(server *biz.DatabaseServer) error) *DatabaseServerRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// CreateUser provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) CreateUser(user *biz.DatabaseUser) error { - ret := _mock.Called(user) - - if len(ret) == 0 { - panic("no return value specified for CreateUser") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.DatabaseUser) error); ok { - r0 = returnFunc(user) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseServerRepo_CreateUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateUser' -type DatabaseServerRepo_CreateUser_Call struct { - *mock.Call -} - -// CreateUser is a helper method to define mock.On call -// - user *biz.DatabaseUser -func (_e *DatabaseServerRepo_Expecter) CreateUser(user any) *DatabaseServerRepo_CreateUser_Call { - return &DatabaseServerRepo_CreateUser_Call{Call: _e.mock.On("CreateUser", user)} -} - -func (_c *DatabaseServerRepo_CreateUser_Call) Run(run func(user *biz.DatabaseUser)) *DatabaseServerRepo_CreateUser_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.DatabaseUser - if args[0] != nil { - arg0 = args[0].(*biz.DatabaseUser) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_CreateUser_Call) Return(err error) *DatabaseServerRepo_CreateUser_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseServerRepo_CreateUser_Call) RunAndReturn(run func(user *biz.DatabaseUser) error) *DatabaseServerRepo_CreateUser_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) Delete(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseServerRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type DatabaseServerRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *DatabaseServerRepo_Expecter) Delete(id any) *DatabaseServerRepo_Delete_Call { - return &DatabaseServerRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *DatabaseServerRepo_Delete_Call) Run(run func(id uint)) *DatabaseServerRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_Delete_Call) Return(err error) *DatabaseServerRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseServerRepo_Delete_Call) RunAndReturn(run func(id uint) error) *DatabaseServerRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) Get(ctx context.Context, id uint) (*biz.DatabaseServer, error) { - ret := _mock.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.DatabaseServer - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, uint) (*biz.DatabaseServer, error)); ok { - return returnFunc(ctx, id) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, uint) *biz.DatabaseServer); ok { - r0 = returnFunc(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.DatabaseServer) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, uint) error); ok { - r1 = returnFunc(ctx, id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseServerRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type DatabaseServerRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - ctx context.Context -// - id uint -func (_e *DatabaseServerRepo_Expecter) Get(ctx any, id any) *DatabaseServerRepo_Get_Call { - return &DatabaseServerRepo_Get_Call{Call: _e.mock.On("Get", ctx, id)} -} - -func (_c *DatabaseServerRepo_Get_Call) Run(run func(ctx context.Context, id uint)) *DatabaseServerRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_Get_Call) Return(databaseServer *biz.DatabaseServer, err error) *DatabaseServerRepo_Get_Call { - _c.Call.Return(databaseServer, err) - return _c -} - -func (_c *DatabaseServerRepo_Get_Call) RunAndReturn(run func(ctx context.Context, id uint) (*biz.DatabaseServer, error)) *DatabaseServerRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// GetByName provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) GetByName(ctx context.Context, name string) (*biz.DatabaseServer, error) { - ret := _mock.Called(ctx, name) - - if len(ret) == 0 { - panic("no return value specified for GetByName") - } - - var r0 *biz.DatabaseServer - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, string) (*biz.DatabaseServer, error)); ok { - return returnFunc(ctx, name) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, string) *biz.DatabaseServer); ok { - r0 = returnFunc(ctx, name) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.DatabaseServer) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = returnFunc(ctx, name) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseServerRepo_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' -type DatabaseServerRepo_GetByName_Call struct { - *mock.Call -} - -// GetByName is a helper method to define mock.On call -// - ctx context.Context -// - name string -func (_e *DatabaseServerRepo_Expecter) GetByName(ctx any, name any) *DatabaseServerRepo_GetByName_Call { - return &DatabaseServerRepo_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} -} - -func (_c *DatabaseServerRepo_GetByName_Call) Run(run func(ctx context.Context, name string)) *DatabaseServerRepo_GetByName_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_GetByName_Call) Return(databaseServer *biz.DatabaseServer, err error) *DatabaseServerRepo_GetByName_Call { - _c.Call.Return(databaseServer, err) - return _c -} - -func (_c *DatabaseServerRepo_GetByName_Call) RunAndReturn(run func(ctx context.Context, name string) (*biz.DatabaseServer, error)) *DatabaseServerRepo_GetByName_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) List(ctx context.Context, page uint, limit uint, typ string) ([]*biz.DatabaseServer, int64, error) { - ret := _mock.Called(ctx, page, limit, typ) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.DatabaseServer - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(context.Context, uint, uint, string) ([]*biz.DatabaseServer, int64, error)); ok { - return returnFunc(ctx, page, limit, typ) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, uint, uint, string) []*biz.DatabaseServer); ok { - r0 = returnFunc(ctx, page, limit, typ) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.DatabaseServer) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, uint, uint, string) int64); ok { - r1 = returnFunc(ctx, page, limit, typ) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(context.Context, uint, uint, string) error); ok { - r2 = returnFunc(ctx, page, limit, typ) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// DatabaseServerRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type DatabaseServerRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - ctx context.Context -// - page uint -// - limit uint -// - typ string -func (_e *DatabaseServerRepo_Expecter) List(ctx any, page any, limit any, typ any) *DatabaseServerRepo_List_Call { - return &DatabaseServerRepo_List_Call{Call: _e.mock.On("List", ctx, page, limit, typ)} -} - -func (_c *DatabaseServerRepo_List_Call) Run(run func(ctx context.Context, page uint, limit uint, typ string)) *DatabaseServerRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - var arg2 uint - if args[2] != nil { - arg2 = args[2].(uint) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_List_Call) Return(databaseServers []*biz.DatabaseServer, n int64, err error) *DatabaseServerRepo_List_Call { - _c.Call.Return(databaseServers, n, err) - return _c -} - -func (_c *DatabaseServerRepo_List_Call) RunAndReturn(run func(ctx context.Context, page uint, limit uint, typ string) ([]*biz.DatabaseServer, int64, error)) *DatabaseServerRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// ListUsers provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) ListUsers(serverID uint) ([]*biz.DatabaseUser, error) { - ret := _mock.Called(serverID) - - if len(ret) == 0 { - panic("no return value specified for ListUsers") - } - - var r0 []*biz.DatabaseUser - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) ([]*biz.DatabaseUser, error)); ok { - return returnFunc(serverID) - } - if returnFunc, ok := ret.Get(0).(func(uint) []*biz.DatabaseUser); ok { - r0 = returnFunc(serverID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.DatabaseUser) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(serverID) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseServerRepo_ListUsers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListUsers' -type DatabaseServerRepo_ListUsers_Call struct { - *mock.Call -} - -// ListUsers is a helper method to define mock.On call -// - serverID uint -func (_e *DatabaseServerRepo_Expecter) ListUsers(serverID any) *DatabaseServerRepo_ListUsers_Call { - return &DatabaseServerRepo_ListUsers_Call{Call: _e.mock.On("ListUsers", serverID)} -} - -func (_c *DatabaseServerRepo_ListUsers_Call) Run(run func(serverID uint)) *DatabaseServerRepo_ListUsers_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_ListUsers_Call) Return(databaseUsers []*biz.DatabaseUser, err error) *DatabaseServerRepo_ListUsers_Call { - _c.Call.Return(databaseUsers, err) - return _c -} - -func (_c *DatabaseServerRepo_ListUsers_Call) RunAndReturn(run func(serverID uint) ([]*biz.DatabaseUser, error)) *DatabaseServerRepo_ListUsers_Call { - _c.Call.Return(run) - return _c -} - -// Operator provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) Operator(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) { - ret := _mock.Called(ctx, server) - - if len(ret) == 0 { - panic("no return value specified for Operator") - } - - var r0 db.Operator - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *biz.DatabaseServer) (db.Operator, error)); ok { - return returnFunc(ctx, server) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *biz.DatabaseServer) db.Operator); ok { - r0 = returnFunc(ctx, server) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(db.Operator) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *biz.DatabaseServer) error); ok { - r1 = returnFunc(ctx, server) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseServerRepo_Operator_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Operator' -type DatabaseServerRepo_Operator_Call struct { - *mock.Call -} - -// Operator is a helper method to define mock.On call -// - ctx context.Context -// - server *biz.DatabaseServer -func (_e *DatabaseServerRepo_Expecter) Operator(ctx any, server any) *DatabaseServerRepo_Operator_Call { - return &DatabaseServerRepo_Operator_Call{Call: _e.mock.On("Operator", ctx, server)} -} - -func (_c *DatabaseServerRepo_Operator_Call) Run(run func(ctx context.Context, server *biz.DatabaseServer)) *DatabaseServerRepo_Operator_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *biz.DatabaseServer - if args[1] != nil { - arg1 = args[1].(*biz.DatabaseServer) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_Operator_Call) Return(operator db.Operator, err error) *DatabaseServerRepo_Operator_Call { - _c.Call.Return(operator, err) - return _c -} - -func (_c *DatabaseServerRepo_Operator_Call) RunAndReturn(run func(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error)) *DatabaseServerRepo_Operator_Call { - _c.Call.Return(run) - return _c -} - -// Save provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) Save(server *biz.DatabaseServer) error { - ret := _mock.Called(server) - - if len(ret) == 0 { - panic("no return value specified for Save") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.DatabaseServer) error); ok { - r0 = returnFunc(server) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseServerRepo_Save_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Save' -type DatabaseServerRepo_Save_Call struct { - *mock.Call -} - -// Save is a helper method to define mock.On call -// - server *biz.DatabaseServer -func (_e *DatabaseServerRepo_Expecter) Save(server any) *DatabaseServerRepo_Save_Call { - return &DatabaseServerRepo_Save_Call{Call: _e.mock.On("Save", server)} -} - -func (_c *DatabaseServerRepo_Save_Call) Run(run func(server *biz.DatabaseServer)) *DatabaseServerRepo_Save_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.DatabaseServer - if args[0] != nil { - arg0 = args[0].(*biz.DatabaseServer) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_Save_Call) Return(err error) *DatabaseServerRepo_Save_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseServerRepo_Save_Call) RunAndReturn(run func(server *biz.DatabaseServer) error) *DatabaseServerRepo_Save_Call { - _c.Call.Return(run) - return _c -} - -// UpdatePassword provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) UpdatePassword(name string, password string) error { - ret := _mock.Called(name, password) - - if len(ret) == 0 { - panic("no return value specified for UpdatePassword") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(name, password) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseServerRepo_UpdatePassword_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdatePassword' -type DatabaseServerRepo_UpdatePassword_Call struct { - *mock.Call -} - -// UpdatePassword is a helper method to define mock.On call -// - name string -// - password string -func (_e *DatabaseServerRepo_Expecter) UpdatePassword(name any, password any) *DatabaseServerRepo_UpdatePassword_Call { - return &DatabaseServerRepo_UpdatePassword_Call{Call: _e.mock.On("UpdatePassword", name, password)} -} - -func (_c *DatabaseServerRepo_UpdatePassword_Call) Run(run func(name string, password string)) *DatabaseServerRepo_UpdatePassword_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_UpdatePassword_Call) Return(err error) *DatabaseServerRepo_UpdatePassword_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseServerRepo_UpdatePassword_Call) RunAndReturn(run func(name string, password string) error) *DatabaseServerRepo_UpdatePassword_Call { - _c.Call.Return(run) - return _c -} - -// UpdatePort provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) UpdatePort(name string, port uint) error { - ret := _mock.Called(name, port) - - if len(ret) == 0 { - panic("no return value specified for UpdatePort") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, uint) error); ok { - r0 = returnFunc(name, port) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseServerRepo_UpdatePort_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdatePort' -type DatabaseServerRepo_UpdatePort_Call struct { - *mock.Call -} - -// UpdatePort is a helper method to define mock.On call -// - name string -// - port uint -func (_e *DatabaseServerRepo_Expecter) UpdatePort(name any, port any) *DatabaseServerRepo_UpdatePort_Call { - return &DatabaseServerRepo_UpdatePort_Call{Call: _e.mock.On("UpdatePort", name, port)} -} - -func (_c *DatabaseServerRepo_UpdatePort_Call) Run(run func(name string, port uint)) *DatabaseServerRepo_UpdatePort_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_UpdatePort_Call) Return(err error) *DatabaseServerRepo_UpdatePort_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseServerRepo_UpdatePort_Call) RunAndReturn(run func(name string, port uint) error) *DatabaseServerRepo_UpdatePort_Call { - _c.Call.Return(run) - return _c -} - -// UpdateRemark provides a mock function for the type DatabaseServerRepo -func (_mock *DatabaseServerRepo) UpdateRemark(req *request.DatabaseServerUpdateRemark) error { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for UpdateRemark") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*request.DatabaseServerUpdateRemark) error); ok { - r0 = returnFunc(req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseServerRepo_UpdateRemark_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRemark' -type DatabaseServerRepo_UpdateRemark_Call struct { - *mock.Call -} - -// UpdateRemark is a helper method to define mock.On call -// - req *request.DatabaseServerUpdateRemark -func (_e *DatabaseServerRepo_Expecter) UpdateRemark(req any) *DatabaseServerRepo_UpdateRemark_Call { - return &DatabaseServerRepo_UpdateRemark_Call{Call: _e.mock.On("UpdateRemark", req)} -} - -func (_c *DatabaseServerRepo_UpdateRemark_Call) Run(run func(req *request.DatabaseServerUpdateRemark)) *DatabaseServerRepo_UpdateRemark_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.DatabaseServerUpdateRemark - if args[0] != nil { - arg0 = args[0].(*request.DatabaseServerUpdateRemark) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *DatabaseServerRepo_UpdateRemark_Call) Return(err error) *DatabaseServerRepo_UpdateRemark_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseServerRepo_UpdateRemark_Call) RunAndReturn(run func(req *request.DatabaseServerUpdateRemark) error) *DatabaseServerRepo_UpdateRemark_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/DatabaseUserRepo.go b/mocks/biz/DatabaseUserRepo.go deleted file mode 100644 index ca9f64fdd..000000000 --- a/mocks/biz/DatabaseUserRepo.go +++ /dev/null @@ -1,660 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "context" - - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/db" - mock "github.com/stretchr/testify/mock" -) - -// NewDatabaseUserRepo creates a new instance of DatabaseUserRepo. 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 NewDatabaseUserRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *DatabaseUserRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &DatabaseUserRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// DatabaseUserRepo is an autogenerated mock type for the DatabaseUserRepo type -type DatabaseUserRepo struct { - mock.Mock -} - -type DatabaseUserRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *DatabaseUserRepo) EXPECT() *DatabaseUserRepo_Expecter { - return &DatabaseUserRepo_Expecter{mock: &_m.Mock} -} - -// Count provides a mock function for the type DatabaseUserRepo -func (_mock *DatabaseUserRepo) Count() (int64, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for Count") - } - - var r0 int64 - var r1 error - if returnFunc, ok := ret.Get(0).(func() (int64, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() int64); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(int64) - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseUserRepo_Count_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Count' -type DatabaseUserRepo_Count_Call struct { - *mock.Call -} - -// Count is a helper method to define mock.On call -func (_e *DatabaseUserRepo_Expecter) Count() *DatabaseUserRepo_Count_Call { - return &DatabaseUserRepo_Count_Call{Call: _e.mock.On("Count")} -} - -func (_c *DatabaseUserRepo_Count_Call) Run(run func()) *DatabaseUserRepo_Count_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *DatabaseUserRepo_Count_Call) Return(n int64, err error) *DatabaseUserRepo_Count_Call { - _c.Call.Return(n, err) - return _c -} - -func (_c *DatabaseUserRepo_Count_Call) RunAndReturn(run func() (int64, error)) *DatabaseUserRepo_Count_Call { - _c.Call.Return(run) - return _c -} - -// DeleteByID provides a mock function for the type DatabaseUserRepo -func (_mock *DatabaseUserRepo) DeleteByID(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for DeleteByID") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseUserRepo_DeleteByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteByID' -type DatabaseUserRepo_DeleteByID_Call struct { - *mock.Call -} - -// DeleteByID is a helper method to define mock.On call -// - id uint -func (_e *DatabaseUserRepo_Expecter) DeleteByID(id any) *DatabaseUserRepo_DeleteByID_Call { - return &DatabaseUserRepo_DeleteByID_Call{Call: _e.mock.On("DeleteByID", id)} -} - -func (_c *DatabaseUserRepo_DeleteByID_Call) Run(run func(id uint)) *DatabaseUserRepo_DeleteByID_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *DatabaseUserRepo_DeleteByID_Call) Return(err error) *DatabaseUserRepo_DeleteByID_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseUserRepo_DeleteByID_Call) RunAndReturn(run func(id uint) error) *DatabaseUserRepo_DeleteByID_Call { - _c.Call.Return(run) - return _c -} - -// DeleteByServerNames provides a mock function for the type DatabaseUserRepo -func (_mock *DatabaseUserRepo) DeleteByServerNames(serverID uint, names []string) error { - ret := _mock.Called(serverID, names) - - if len(ret) == 0 { - panic("no return value specified for DeleteByServerNames") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, []string) error); ok { - r0 = returnFunc(serverID, names) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseUserRepo_DeleteByServerNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteByServerNames' -type DatabaseUserRepo_DeleteByServerNames_Call struct { - *mock.Call -} - -// DeleteByServerNames is a helper method to define mock.On call -// - serverID uint -// - names []string -func (_e *DatabaseUserRepo_Expecter) DeleteByServerNames(serverID any, names any) *DatabaseUserRepo_DeleteByServerNames_Call { - return &DatabaseUserRepo_DeleteByServerNames_Call{Call: _e.mock.On("DeleteByServerNames", serverID, names)} -} - -func (_c *DatabaseUserRepo_DeleteByServerNames_Call) Run(run func(serverID uint, names []string)) *DatabaseUserRepo_DeleteByServerNames_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 []string - if args[1] != nil { - arg1 = args[1].([]string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseUserRepo_DeleteByServerNames_Call) Return(err error) *DatabaseUserRepo_DeleteByServerNames_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseUserRepo_DeleteByServerNames_Call) RunAndReturn(run func(serverID uint, names []string) error) *DatabaseUserRepo_DeleteByServerNames_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type DatabaseUserRepo -func (_mock *DatabaseUserRepo) Get(ctx context.Context, id uint) (*biz.DatabaseUser, error) { - ret := _mock.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.DatabaseUser - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, uint) (*biz.DatabaseUser, error)); ok { - return returnFunc(ctx, id) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, uint) *biz.DatabaseUser); ok { - r0 = returnFunc(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.DatabaseUser) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, uint) error); ok { - r1 = returnFunc(ctx, id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseUserRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type DatabaseUserRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - ctx context.Context -// - id uint -func (_e *DatabaseUserRepo_Expecter) Get(ctx any, id any) *DatabaseUserRepo_Get_Call { - return &DatabaseUserRepo_Get_Call{Call: _e.mock.On("Get", ctx, id)} -} - -func (_c *DatabaseUserRepo_Get_Call) Run(run func(ctx context.Context, id uint)) *DatabaseUserRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseUserRepo_Get_Call) Return(databaseUser *biz.DatabaseUser, err error) *DatabaseUserRepo_Get_Call { - _c.Call.Return(databaseUser, err) - return _c -} - -func (_c *DatabaseUserRepo_Get_Call) RunAndReturn(run func(ctx context.Context, id uint) (*biz.DatabaseUser, error)) *DatabaseUserRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type DatabaseUserRepo -func (_mock *DatabaseUserRepo) List(ctx context.Context, page uint, limit uint, typ string) ([]*biz.DatabaseUser, int64, error) { - ret := _mock.Called(ctx, page, limit, typ) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.DatabaseUser - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(context.Context, uint, uint, string) ([]*biz.DatabaseUser, int64, error)); ok { - return returnFunc(ctx, page, limit, typ) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, uint, uint, string) []*biz.DatabaseUser); ok { - r0 = returnFunc(ctx, page, limit, typ) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.DatabaseUser) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, uint, uint, string) int64); ok { - r1 = returnFunc(ctx, page, limit, typ) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(context.Context, uint, uint, string) error); ok { - r2 = returnFunc(ctx, page, limit, typ) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// DatabaseUserRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type DatabaseUserRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - ctx context.Context -// - page uint -// - limit uint -// - typ string -func (_e *DatabaseUserRepo_Expecter) List(ctx any, page any, limit any, typ any) *DatabaseUserRepo_List_Call { - return &DatabaseUserRepo_List_Call{Call: _e.mock.On("List", ctx, page, limit, typ)} -} - -func (_c *DatabaseUserRepo_List_Call) Run(run func(ctx context.Context, page uint, limit uint, typ string)) *DatabaseUserRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - var arg2 uint - if args[2] != nil { - arg2 = args[2].(uint) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *DatabaseUserRepo_List_Call) Return(databaseUsers []*biz.DatabaseUser, n int64, err error) *DatabaseUserRepo_List_Call { - _c.Call.Return(databaseUsers, n, err) - return _c -} - -func (_c *DatabaseUserRepo_List_Call) RunAndReturn(run func(ctx context.Context, page uint, limit uint, typ string) ([]*biz.DatabaseUser, int64, error)) *DatabaseUserRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// ListByNames provides a mock function for the type DatabaseUserRepo -func (_mock *DatabaseUserRepo) ListByNames(serverID uint, names []string) ([]*biz.DatabaseUser, error) { - ret := _mock.Called(serverID, names) - - if len(ret) == 0 { - panic("no return value specified for ListByNames") - } - - var r0 []*biz.DatabaseUser - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint, []string) ([]*biz.DatabaseUser, error)); ok { - return returnFunc(serverID, names) - } - if returnFunc, ok := ret.Get(0).(func(uint, []string) []*biz.DatabaseUser); ok { - r0 = returnFunc(serverID, names) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.DatabaseUser) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, []string) error); ok { - r1 = returnFunc(serverID, names) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseUserRepo_ListByNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListByNames' -type DatabaseUserRepo_ListByNames_Call struct { - *mock.Call -} - -// ListByNames is a helper method to define mock.On call -// - serverID uint -// - names []string -func (_e *DatabaseUserRepo_Expecter) ListByNames(serverID any, names any) *DatabaseUserRepo_ListByNames_Call { - return &DatabaseUserRepo_ListByNames_Call{Call: _e.mock.On("ListByNames", serverID, names)} -} - -func (_c *DatabaseUserRepo_ListByNames_Call) Run(run func(serverID uint, names []string)) *DatabaseUserRepo_ListByNames_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 []string - if args[1] != nil { - arg1 = args[1].([]string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseUserRepo_ListByNames_Call) Return(databaseUsers []*biz.DatabaseUser, err error) *DatabaseUserRepo_ListByNames_Call { - _c.Call.Return(databaseUsers, err) - return _c -} - -func (_c *DatabaseUserRepo_ListByNames_Call) RunAndReturn(run func(serverID uint, names []string) ([]*biz.DatabaseUser, error)) *DatabaseUserRepo_ListByNames_Call { - _c.Call.Return(run) - return _c -} - -// Operator provides a mock function for the type DatabaseUserRepo -func (_mock *DatabaseUserRepo) Operator(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error) { - ret := _mock.Called(ctx, server) - - if len(ret) == 0 { - panic("no return value specified for Operator") - } - - var r0 db.Operator - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *biz.DatabaseServer) (db.Operator, error)); ok { - return returnFunc(ctx, server) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *biz.DatabaseServer) db.Operator); ok { - r0 = returnFunc(ctx, server) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(db.Operator) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *biz.DatabaseServer) error); ok { - r1 = returnFunc(ctx, server) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// DatabaseUserRepo_Operator_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Operator' -type DatabaseUserRepo_Operator_Call struct { - *mock.Call -} - -// Operator is a helper method to define mock.On call -// - ctx context.Context -// - server *biz.DatabaseServer -func (_e *DatabaseUserRepo_Expecter) Operator(ctx any, server any) *DatabaseUserRepo_Operator_Call { - return &DatabaseUserRepo_Operator_Call{Call: _e.mock.On("Operator", ctx, server)} -} - -func (_c *DatabaseUserRepo_Operator_Call) Run(run func(ctx context.Context, server *biz.DatabaseServer)) *DatabaseUserRepo_Operator_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *biz.DatabaseServer - if args[1] != nil { - arg1 = args[1].(*biz.DatabaseServer) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseUserRepo_Operator_Call) Return(operator db.Operator, err error) *DatabaseUserRepo_Operator_Call { - _c.Call.Return(operator, err) - return _c -} - -func (_c *DatabaseUserRepo_Operator_Call) RunAndReturn(run func(ctx context.Context, server *biz.DatabaseServer) (db.Operator, error)) *DatabaseUserRepo_Operator_Call { - _c.Call.Return(run) - return _c -} - -// Save provides a mock function for the type DatabaseUserRepo -func (_mock *DatabaseUserRepo) Save(user *biz.DatabaseUser) error { - ret := _mock.Called(user) - - if len(ret) == 0 { - panic("no return value specified for Save") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.DatabaseUser) error); ok { - r0 = returnFunc(user) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseUserRepo_Save_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Save' -type DatabaseUserRepo_Save_Call struct { - *mock.Call -} - -// Save is a helper method to define mock.On call -// - user *biz.DatabaseUser -func (_e *DatabaseUserRepo_Expecter) Save(user any) *DatabaseUserRepo_Save_Call { - return &DatabaseUserRepo_Save_Call{Call: _e.mock.On("Save", user)} -} - -func (_c *DatabaseUserRepo_Save_Call) Run(run func(user *biz.DatabaseUser)) *DatabaseUserRepo_Save_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.DatabaseUser - if args[0] != nil { - arg0 = args[0].(*biz.DatabaseUser) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *DatabaseUserRepo_Save_Call) Return(err error) *DatabaseUserRepo_Save_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseUserRepo_Save_Call) RunAndReturn(run func(user *biz.DatabaseUser) error) *DatabaseUserRepo_Save_Call { - _c.Call.Return(run) - return _c -} - -// UpdateRemark provides a mock function for the type DatabaseUserRepo -func (_mock *DatabaseUserRepo) UpdateRemark(ctx context.Context, req *request.DatabaseUserUpdateRemark) error { - ret := _mock.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for UpdateRemark") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.DatabaseUserUpdateRemark) error); ok { - r0 = returnFunc(ctx, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseUserRepo_UpdateRemark_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRemark' -type DatabaseUserRepo_UpdateRemark_Call struct { - *mock.Call -} - -// UpdateRemark is a helper method to define mock.On call -// - ctx context.Context -// - req *request.DatabaseUserUpdateRemark -func (_e *DatabaseUserRepo_Expecter) UpdateRemark(ctx any, req any) *DatabaseUserRepo_UpdateRemark_Call { - return &DatabaseUserRepo_UpdateRemark_Call{Call: _e.mock.On("UpdateRemark", ctx, req)} -} - -func (_c *DatabaseUserRepo_UpdateRemark_Call) Run(run func(ctx context.Context, req *request.DatabaseUserUpdateRemark)) *DatabaseUserRepo_UpdateRemark_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.DatabaseUserUpdateRemark - if args[1] != nil { - arg1 = args[1].(*request.DatabaseUserUpdateRemark) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *DatabaseUserRepo_UpdateRemark_Call) Return(err error) *DatabaseUserRepo_UpdateRemark_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseUserRepo_UpdateRemark_Call) RunAndReturn(run func(ctx context.Context, req *request.DatabaseUserUpdateRemark) error) *DatabaseUserRepo_UpdateRemark_Call { - _c.Call.Return(run) - return _c -} - -// Upsert provides a mock function for the type DatabaseUserRepo -func (_mock *DatabaseUserRepo) Upsert(user *biz.DatabaseUser) error { - ret := _mock.Called(user) - - if len(ret) == 0 { - panic("no return value specified for Upsert") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.DatabaseUser) error); ok { - r0 = returnFunc(user) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// DatabaseUserRepo_Upsert_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Upsert' -type DatabaseUserRepo_Upsert_Call struct { - *mock.Call -} - -// Upsert is a helper method to define mock.On call -// - user *biz.DatabaseUser -func (_e *DatabaseUserRepo_Expecter) Upsert(user any) *DatabaseUserRepo_Upsert_Call { - return &DatabaseUserRepo_Upsert_Call{Call: _e.mock.On("Upsert", user)} -} - -func (_c *DatabaseUserRepo_Upsert_Call) Run(run func(user *biz.DatabaseUser)) *DatabaseUserRepo_Upsert_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.DatabaseUser - if args[0] != nil { - arg0 = args[0].(*biz.DatabaseUser) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *DatabaseUserRepo_Upsert_Call) Return(err error) *DatabaseUserRepo_Upsert_Call { - _c.Call.Return(err) - return _c -} - -func (_c *DatabaseUserRepo_Upsert_Call) RunAndReturn(run func(user *biz.DatabaseUser) error) *DatabaseUserRepo_Upsert_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/EnvironmentRepo.go b/mocks/biz/EnvironmentRepo.go deleted file mode 100644 index 535355556..000000000 --- a/mocks/biz/EnvironmentRepo.go +++ /dev/null @@ -1,279 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - mock "github.com/stretchr/testify/mock" -) - -// NewEnvironmentRepo creates a new instance of EnvironmentRepo. 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 NewEnvironmentRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *EnvironmentRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &EnvironmentRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// EnvironmentRepo is an autogenerated mock type for the EnvironmentRepo type -type EnvironmentRepo struct { - mock.Mock -} - -type EnvironmentRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *EnvironmentRepo) EXPECT() *EnvironmentRepo_Expecter { - return &EnvironmentRepo_Expecter{mock: &_m.Mock} -} - -// ExecScript provides a mock function for the type EnvironmentRepo -func (_mock *EnvironmentRepo) ExecScript(cmd string) error { - ret := _mock.Called(cmd) - - if len(ret) == 0 { - panic("no return value specified for ExecScript") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(cmd) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// EnvironmentRepo_ExecScript_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExecScript' -type EnvironmentRepo_ExecScript_Call struct { - *mock.Call -} - -// ExecScript is a helper method to define mock.On call -// - cmd string -func (_e *EnvironmentRepo_Expecter) ExecScript(cmd any) *EnvironmentRepo_ExecScript_Call { - return &EnvironmentRepo_ExecScript_Call{Call: _e.mock.On("ExecScript", cmd)} -} - -func (_c *EnvironmentRepo_ExecScript_Call) Run(run func(cmd string)) *EnvironmentRepo_ExecScript_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *EnvironmentRepo_ExecScript_Call) Return(err error) *EnvironmentRepo_ExecScript_Call { - _c.Call.Return(err) - return _c -} - -func (_c *EnvironmentRepo_ExecScript_Call) RunAndReturn(run func(cmd string) error) *EnvironmentRepo_ExecScript_Call { - _c.Call.Return(run) - return _c -} - -// InstalledVersion provides a mock function for the type EnvironmentRepo -func (_mock *EnvironmentRepo) InstalledVersion(typ string, slug string) string { - ret := _mock.Called(typ, slug) - - if len(ret) == 0 { - panic("no return value specified for InstalledVersion") - } - - var r0 string - if returnFunc, ok := ret.Get(0).(func(string, string) string); ok { - r0 = returnFunc(typ, slug) - } else { - r0 = ret.Get(0).(string) - } - return r0 -} - -// EnvironmentRepo_InstalledVersion_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'InstalledVersion' -type EnvironmentRepo_InstalledVersion_Call struct { - *mock.Call -} - -// InstalledVersion is a helper method to define mock.On call -// - typ string -// - slug string -func (_e *EnvironmentRepo_Expecter) InstalledVersion(typ any, slug any) *EnvironmentRepo_InstalledVersion_Call { - return &EnvironmentRepo_InstalledVersion_Call{Call: _e.mock.On("InstalledVersion", typ, slug)} -} - -func (_c *EnvironmentRepo_InstalledVersion_Call) Run(run func(typ string, slug string)) *EnvironmentRepo_InstalledVersion_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *EnvironmentRepo_InstalledVersion_Call) Return(s string) *EnvironmentRepo_InstalledVersion_Call { - _c.Call.Return(s) - return _c -} - -func (_c *EnvironmentRepo_InstalledVersion_Call) RunAndReturn(run func(typ string, slug string) string) *EnvironmentRepo_InstalledVersion_Call { - _c.Call.Return(run) - return _c -} - -// IsInstalled provides a mock function for the type EnvironmentRepo -func (_mock *EnvironmentRepo) IsInstalled(typ string, slug string) bool { - ret := _mock.Called(typ, slug) - - if len(ret) == 0 { - panic("no return value specified for IsInstalled") - } - - var r0 bool - if returnFunc, ok := ret.Get(0).(func(string, string) bool); ok { - r0 = returnFunc(typ, slug) - } else { - r0 = ret.Get(0).(bool) - } - return r0 -} - -// EnvironmentRepo_IsInstalled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsInstalled' -type EnvironmentRepo_IsInstalled_Call struct { - *mock.Call -} - -// IsInstalled is a helper method to define mock.On call -// - typ string -// - slug string -func (_e *EnvironmentRepo_Expecter) IsInstalled(typ any, slug any) *EnvironmentRepo_IsInstalled_Call { - return &EnvironmentRepo_IsInstalled_Call{Call: _e.mock.On("IsInstalled", typ, slug)} -} - -func (_c *EnvironmentRepo_IsInstalled_Call) Run(run func(typ string, slug string)) *EnvironmentRepo_IsInstalled_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *EnvironmentRepo_IsInstalled_Call) Return(b bool) *EnvironmentRepo_IsInstalled_Call { - _c.Call.Return(b) - return _c -} - -func (_c *EnvironmentRepo_IsInstalled_Call) RunAndReturn(run func(typ string, slug string) bool) *EnvironmentRepo_IsInstalled_Call { - _c.Call.Return(run) - return _c -} - -// ScriptCommand provides a mock function for the type EnvironmentRepo -func (_mock *EnvironmentRepo) ScriptCommand(typ string, action string, slug string, version string) string { - ret := _mock.Called(typ, action, slug, version) - - if len(ret) == 0 { - panic("no return value specified for ScriptCommand") - } - - var r0 string - if returnFunc, ok := ret.Get(0).(func(string, string, string, string) string); ok { - r0 = returnFunc(typ, action, slug, version) - } else { - r0 = ret.Get(0).(string) - } - return r0 -} - -// EnvironmentRepo_ScriptCommand_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ScriptCommand' -type EnvironmentRepo_ScriptCommand_Call struct { - *mock.Call -} - -// ScriptCommand is a helper method to define mock.On call -// - typ string -// - action string -// - slug string -// - version string -func (_e *EnvironmentRepo_Expecter) ScriptCommand(typ any, action any, slug any, version any) *EnvironmentRepo_ScriptCommand_Call { - return &EnvironmentRepo_ScriptCommand_Call{Call: _e.mock.On("ScriptCommand", typ, action, slug, version)} -} - -func (_c *EnvironmentRepo_ScriptCommand_Call) Run(run func(typ string, action string, slug string, version string)) *EnvironmentRepo_ScriptCommand_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *EnvironmentRepo_ScriptCommand_Call) Return(s string) *EnvironmentRepo_ScriptCommand_Call { - _c.Call.Return(s) - return _c -} - -func (_c *EnvironmentRepo_ScriptCommand_Call) RunAndReturn(run func(typ string, action string, slug string, version string) string) *EnvironmentRepo_ScriptCommand_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/FileShareRepo.go b/mocks/biz/FileShareRepo.go deleted file mode 100644 index 3808abd59..000000000 --- a/mocks/biz/FileShareRepo.go +++ /dev/null @@ -1,411 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "time" - - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewFileShareRepo creates a new instance of FileShareRepo. 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 NewFileShareRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *FileShareRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &FileShareRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// FileShareRepo is an autogenerated mock type for the FileShareRepo type -type FileShareRepo struct { - mock.Mock -} - -type FileShareRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *FileShareRepo) EXPECT() *FileShareRepo_Expecter { - return &FileShareRepo_Expecter{mock: &_m.Mock} -} - -// ClearExpired provides a mock function for the type FileShareRepo -func (_mock *FileShareRepo) ClearExpired() (int64, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for ClearExpired") - } - - var r0 int64 - var r1 error - if returnFunc, ok := ret.Get(0).(func() (int64, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() int64); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(int64) - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// FileShareRepo_ClearExpired_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearExpired' -type FileShareRepo_ClearExpired_Call struct { - *mock.Call -} - -// ClearExpired is a helper method to define mock.On call -func (_e *FileShareRepo_Expecter) ClearExpired() *FileShareRepo_ClearExpired_Call { - return &FileShareRepo_ClearExpired_Call{Call: _e.mock.On("ClearExpired")} -} - -func (_c *FileShareRepo_ClearExpired_Call) Run(run func()) *FileShareRepo_ClearExpired_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *FileShareRepo_ClearExpired_Call) Return(n int64, err error) *FileShareRepo_ClearExpired_Call { - _c.Call.Return(n, err) - return _c -} - -func (_c *FileShareRepo_ClearExpired_Call) RunAndReturn(run func() (int64, error)) *FileShareRepo_ClearExpired_Call { - _c.Call.Return(run) - return _c -} - -// Consume provides a mock function for the type FileShareRepo -func (_mock *FileShareRepo) Consume(token string, count bool) (*biz.FileShare, error) { - ret := _mock.Called(token, count) - - if len(ret) == 0 { - panic("no return value specified for Consume") - } - - var r0 *biz.FileShare - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, bool) (*biz.FileShare, error)); ok { - return returnFunc(token, count) - } - if returnFunc, ok := ret.Get(0).(func(string, bool) *biz.FileShare); ok { - r0 = returnFunc(token, count) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.FileShare) - } - } - if returnFunc, ok := ret.Get(1).(func(string, bool) error); ok { - r1 = returnFunc(token, count) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// FileShareRepo_Consume_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Consume' -type FileShareRepo_Consume_Call struct { - *mock.Call -} - -// Consume is a helper method to define mock.On call -// - token string -// - count bool -func (_e *FileShareRepo_Expecter) Consume(token any, count any) *FileShareRepo_Consume_Call { - return &FileShareRepo_Consume_Call{Call: _e.mock.On("Consume", token, count)} -} - -func (_c *FileShareRepo_Consume_Call) Run(run func(token string, count bool)) *FileShareRepo_Consume_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 bool - if args[1] != nil { - arg1 = args[1].(bool) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *FileShareRepo_Consume_Call) Return(fileShare *biz.FileShare, err error) *FileShareRepo_Consume_Call { - _c.Call.Return(fileShare, err) - return _c -} - -func (_c *FileShareRepo_Consume_Call) RunAndReturn(run func(token string, count bool) (*biz.FileShare, error)) *FileShareRepo_Consume_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function for the type FileShareRepo -func (_mock *FileShareRepo) Create(path string, maxDownloads uint, expiredAt time.Time) (*biz.FileShare, error) { - ret := _mock.Called(path, maxDownloads, expiredAt) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *biz.FileShare - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, uint, time.Time) (*biz.FileShare, error)); ok { - return returnFunc(path, maxDownloads, expiredAt) - } - if returnFunc, ok := ret.Get(0).(func(string, uint, time.Time) *biz.FileShare); ok { - r0 = returnFunc(path, maxDownloads, expiredAt) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.FileShare) - } - } - if returnFunc, ok := ret.Get(1).(func(string, uint, time.Time) error); ok { - r1 = returnFunc(path, maxDownloads, expiredAt) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// FileShareRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type FileShareRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - path string -// - maxDownloads uint -// - expiredAt time.Time -func (_e *FileShareRepo_Expecter) Create(path any, maxDownloads any, expiredAt any) *FileShareRepo_Create_Call { - return &FileShareRepo_Create_Call{Call: _e.mock.On("Create", path, maxDownloads, expiredAt)} -} - -func (_c *FileShareRepo_Create_Call) Run(run func(path string, maxDownloads uint, expiredAt time.Time)) *FileShareRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - var arg2 time.Time - if args[2] != nil { - arg2 = args[2].(time.Time) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *FileShareRepo_Create_Call) Return(fileShare *biz.FileShare, err error) *FileShareRepo_Create_Call { - _c.Call.Return(fileShare, err) - return _c -} - -func (_c *FileShareRepo_Create_Call) RunAndReturn(run func(path string, maxDownloads uint, expiredAt time.Time) (*biz.FileShare, error)) *FileShareRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type FileShareRepo -func (_mock *FileShareRepo) Delete(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// FileShareRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type FileShareRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *FileShareRepo_Expecter) Delete(id any) *FileShareRepo_Delete_Call { - return &FileShareRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *FileShareRepo_Delete_Call) Run(run func(id uint)) *FileShareRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *FileShareRepo_Delete_Call) Return(err error) *FileShareRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *FileShareRepo_Delete_Call) RunAndReturn(run func(id uint) error) *FileShareRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type FileShareRepo -func (_mock *FileShareRepo) Get(id uint) (*biz.FileShare, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.FileShare - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.FileShare, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.FileShare); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.FileShare) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// FileShareRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type FileShareRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *FileShareRepo_Expecter) Get(id any) *FileShareRepo_Get_Call { - return &FileShareRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *FileShareRepo_Get_Call) Run(run func(id uint)) *FileShareRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *FileShareRepo_Get_Call) Return(fileShare *biz.FileShare, err error) *FileShareRepo_Get_Call { - _c.Call.Return(fileShare, err) - return _c -} - -func (_c *FileShareRepo_Get_Call) RunAndReturn(run func(id uint) (*biz.FileShare, error)) *FileShareRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type FileShareRepo -func (_mock *FileShareRepo) List() ([]*biz.FileShare, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.FileShare - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]*biz.FileShare, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []*biz.FileShare); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.FileShare) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// FileShareRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type FileShareRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -func (_e *FileShareRepo_Expecter) List() *FileShareRepo_List_Call { - return &FileShareRepo_List_Call{Call: _e.mock.On("List")} -} - -func (_c *FileShareRepo_List_Call) Run(run func()) *FileShareRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *FileShareRepo_List_Call) Return(fileShares []*biz.FileShare, err error) *FileShareRepo_List_Call { - _c.Call.Return(fileShares, err) - return _c -} - -func (_c *FileShareRepo_List_Call) RunAndReturn(run func() ([]*biz.FileShare, error)) *FileShareRepo_List_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/LogRepo.go b/mocks/biz/LogRepo.go deleted file mode 100644 index e0cac23b7..000000000 --- a/mocks/biz/LogRepo.go +++ /dev/null @@ -1,182 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewLogRepo creates a new instance of LogRepo. 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 NewLogRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *LogRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &LogRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// LogRepo is an autogenerated mock type for the LogRepo type -type LogRepo struct { - mock.Mock -} - -type LogRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *LogRepo) EXPECT() *LogRepo_Expecter { - return &LogRepo_Expecter{mock: &_m.Mock} -} - -// List provides a mock function for the type LogRepo -func (_mock *LogRepo) List(logType string, limit int, date string) ([]biz.LogEntry, error) { - ret := _mock.Called(logType, limit, date) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []biz.LogEntry - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, int, string) ([]biz.LogEntry, error)); ok { - return returnFunc(logType, limit, date) - } - if returnFunc, ok := ret.Get(0).(func(string, int, string) []biz.LogEntry); ok { - r0 = returnFunc(logType, limit, date) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]biz.LogEntry) - } - } - if returnFunc, ok := ret.Get(1).(func(string, int, string) error); ok { - r1 = returnFunc(logType, limit, date) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// LogRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type LogRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - logType string -// - limit int -// - date string -func (_e *LogRepo_Expecter) List(logType any, limit any, date any) *LogRepo_List_Call { - return &LogRepo_List_Call{Call: _e.mock.On("List", logType, limit, date)} -} - -func (_c *LogRepo_List_Call) Run(run func(logType string, limit int, date string)) *LogRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 int - if args[1] != nil { - arg1 = args[1].(int) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *LogRepo_List_Call) Return(logEntrys []biz.LogEntry, err error) *LogRepo_List_Call { - _c.Call.Return(logEntrys, err) - return _c -} - -func (_c *LogRepo_List_Call) RunAndReturn(run func(logType string, limit int, date string) ([]biz.LogEntry, error)) *LogRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// ListDates provides a mock function for the type LogRepo -func (_mock *LogRepo) ListDates(logType string) ([]string, error) { - ret := _mock.Called(logType) - - if len(ret) == 0 { - panic("no return value specified for ListDates") - } - - var r0 []string - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) ([]string, error)); ok { - return returnFunc(logType) - } - if returnFunc, ok := ret.Get(0).(func(string) []string); ok { - r0 = returnFunc(logType) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]string) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(logType) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// LogRepo_ListDates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListDates' -type LogRepo_ListDates_Call struct { - *mock.Call -} - -// ListDates is a helper method to define mock.On call -// - logType string -func (_e *LogRepo_Expecter) ListDates(logType any) *LogRepo_ListDates_Call { - return &LogRepo_ListDates_Call{Call: _e.mock.On("ListDates", logType)} -} - -func (_c *LogRepo_ListDates_Call) Run(run func(logType string)) *LogRepo_ListDates_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *LogRepo_ListDates_Call) Return(strings []string, err error) *LogRepo_ListDates_Call { - _c.Call.Return(strings, err) - return _c -} - -func (_c *LogRepo_ListDates_Call) RunAndReturn(run func(logType string) ([]string, error)) *LogRepo_ListDates_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/MigrationArchiveRepo.go b/mocks/biz/MigrationArchiveRepo.go deleted file mode 100644 index d459f496c..000000000 --- a/mocks/biz/MigrationArchiveRepo.go +++ /dev/null @@ -1,349 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "context" - - mock "github.com/stretchr/testify/mock" -) - -// NewMigrationArchiveRepo creates a new instance of MigrationArchiveRepo. 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 NewMigrationArchiveRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *MigrationArchiveRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &MigrationArchiveRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// MigrationArchiveRepo is an autogenerated mock type for the MigrationArchiveRepo type -type MigrationArchiveRepo struct { - mock.Mock -} - -type MigrationArchiveRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *MigrationArchiveRepo) EXPECT() *MigrationArchiveRepo_Expecter { - return &MigrationArchiveRepo_Expecter{mock: &_m.Mock} -} - -// Compress provides a mock function for the type MigrationArchiveRepo -func (_mock *MigrationArchiveRepo) Compress(ctx context.Context, source string, archive string) error { - ret := _mock.Called(ctx, source, archive) - - if len(ret) == 0 { - panic("no return value specified for Compress") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) error); ok { - r0 = returnFunc(ctx, source, archive) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// MigrationArchiveRepo_Compress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Compress' -type MigrationArchiveRepo_Compress_Call struct { - *mock.Call -} - -// Compress is a helper method to define mock.On call -// - ctx context.Context -// - source string -// - archive string -func (_e *MigrationArchiveRepo_Expecter) Compress(ctx any, source any, archive any) *MigrationArchiveRepo_Compress_Call { - return &MigrationArchiveRepo_Compress_Call{Call: _e.mock.On("Compress", ctx, source, archive)} -} - -func (_c *MigrationArchiveRepo_Compress_Call) Run(run func(ctx context.Context, source string, archive string)) *MigrationArchiveRepo_Compress_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *MigrationArchiveRepo_Compress_Call) Return(err error) *MigrationArchiveRepo_Compress_Call { - _c.Call.Return(err) - return _c -} - -func (_c *MigrationArchiveRepo_Compress_Call) RunAndReturn(run func(ctx context.Context, source string, archive string) error) *MigrationArchiveRepo_Compress_Call { - _c.Call.Return(run) - return _c -} - -// CopyTree provides a mock function for the type MigrationArchiveRepo -func (_mock *MigrationArchiveRepo) CopyTree(ctx context.Context, source string, target string) error { - ret := _mock.Called(ctx, source, target) - - if len(ret) == 0 { - panic("no return value specified for CopyTree") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) error); ok { - r0 = returnFunc(ctx, source, target) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// MigrationArchiveRepo_CopyTree_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CopyTree' -type MigrationArchiveRepo_CopyTree_Call struct { - *mock.Call -} - -// CopyTree is a helper method to define mock.On call -// - ctx context.Context -// - source string -// - target string -func (_e *MigrationArchiveRepo_Expecter) CopyTree(ctx any, source any, target any) *MigrationArchiveRepo_CopyTree_Call { - return &MigrationArchiveRepo_CopyTree_Call{Call: _e.mock.On("CopyTree", ctx, source, target)} -} - -func (_c *MigrationArchiveRepo_CopyTree_Call) Run(run func(ctx context.Context, source string, target string)) *MigrationArchiveRepo_CopyTree_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *MigrationArchiveRepo_CopyTree_Call) Return(err error) *MigrationArchiveRepo_CopyTree_Call { - _c.Call.Return(err) - return _c -} - -func (_c *MigrationArchiveRepo_CopyTree_Call) RunAndReturn(run func(ctx context.Context, source string, target string) error) *MigrationArchiveRepo_CopyTree_Call { - _c.Call.Return(run) - return _c -} - -// Extract provides a mock function for the type MigrationArchiveRepo -func (_mock *MigrationArchiveRepo) Extract(ctx context.Context, archive string, target string) (string, error) { - ret := _mock.Called(ctx, archive, target) - - if len(ret) == 0 { - panic("no return value specified for Extract") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) (string, error)); ok { - return returnFunc(ctx, archive, target) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) string); ok { - r0 = returnFunc(ctx, archive, target) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = returnFunc(ctx, archive, target) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// MigrationArchiveRepo_Extract_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Extract' -type MigrationArchiveRepo_Extract_Call struct { - *mock.Call -} - -// Extract is a helper method to define mock.On call -// - ctx context.Context -// - archive string -// - target string -func (_e *MigrationArchiveRepo_Expecter) Extract(ctx any, archive any, target any) *MigrationArchiveRepo_Extract_Call { - return &MigrationArchiveRepo_Extract_Call{Call: _e.mock.On("Extract", ctx, archive, target)} -} - -func (_c *MigrationArchiveRepo_Extract_Call) Run(run func(ctx context.Context, archive string, target string)) *MigrationArchiveRepo_Extract_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *MigrationArchiveRepo_Extract_Call) Return(s string, err error) *MigrationArchiveRepo_Extract_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *MigrationArchiveRepo_Extract_Call) RunAndReturn(run func(ctx context.Context, archive string, target string) (string, error)) *MigrationArchiveRepo_Extract_Call { - _c.Call.Return(run) - return _c -} - -// IsEmpty provides a mock function for the type MigrationArchiveRepo -func (_mock *MigrationArchiveRepo) IsEmpty(path string) bool { - ret := _mock.Called(path) - - if len(ret) == 0 { - panic("no return value specified for IsEmpty") - } - - var r0 bool - if returnFunc, ok := ret.Get(0).(func(string) bool); ok { - r0 = returnFunc(path) - } else { - r0 = ret.Get(0).(bool) - } - return r0 -} - -// MigrationArchiveRepo_IsEmpty_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsEmpty' -type MigrationArchiveRepo_IsEmpty_Call struct { - *mock.Call -} - -// IsEmpty is a helper method to define mock.On call -// - path string -func (_e *MigrationArchiveRepo_Expecter) IsEmpty(path any) *MigrationArchiveRepo_IsEmpty_Call { - return &MigrationArchiveRepo_IsEmpty_Call{Call: _e.mock.On("IsEmpty", path)} -} - -func (_c *MigrationArchiveRepo_IsEmpty_Call) Run(run func(path string)) *MigrationArchiveRepo_IsEmpty_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *MigrationArchiveRepo_IsEmpty_Call) Return(b bool) *MigrationArchiveRepo_IsEmpty_Call { - _c.Call.Return(b) - return _c -} - -func (_c *MigrationArchiveRepo_IsEmpty_Call) RunAndReturn(run func(path string) bool) *MigrationArchiveRepo_IsEmpty_Call { - _c.Call.Return(run) - return _c -} - -// TempDir provides a mock function for the type MigrationArchiveRepo -func (_mock *MigrationArchiveRepo) TempDir() (string, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for TempDir") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func() (string, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() string); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// MigrationArchiveRepo_TempDir_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TempDir' -type MigrationArchiveRepo_TempDir_Call struct { - *mock.Call -} - -// TempDir is a helper method to define mock.On call -func (_e *MigrationArchiveRepo_Expecter) TempDir() *MigrationArchiveRepo_TempDir_Call { - return &MigrationArchiveRepo_TempDir_Call{Call: _e.mock.On("TempDir")} -} - -func (_c *MigrationArchiveRepo_TempDir_Call) Run(run func()) *MigrationArchiveRepo_TempDir_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MigrationArchiveRepo_TempDir_Call) Return(s string, err error) *MigrationArchiveRepo_TempDir_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *MigrationArchiveRepo_TempDir_Call) RunAndReturn(run func() (string, error)) *MigrationArchiveRepo_TempDir_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/MigrationRemoteRepo.go b/mocks/biz/MigrationRemoteRepo.go deleted file mode 100644 index 9d9a9c0ef..000000000 --- a/mocks/biz/MigrationRemoteRepo.go +++ /dev/null @@ -1,273 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "context" - - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewMigrationRemoteRepo creates a new instance of MigrationRemoteRepo. 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 NewMigrationRemoteRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *MigrationRemoteRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &MigrationRemoteRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// MigrationRemoteRepo is an autogenerated mock type for the MigrationRemoteRepo type -type MigrationRemoteRepo struct { - mock.Mock -} - -type MigrationRemoteRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *MigrationRemoteRepo) EXPECT() *MigrationRemoteRepo_Expecter { - return &MigrationRemoteRepo_Expecter{mock: &_m.Mock} -} - -// Exec provides a mock function for the type MigrationRemoteRepo -func (_mock *MigrationRemoteRepo) Exec(ctx context.Context, conn *request.ToolboxMigrationConnection, command string) error { - ret := _mock.Called(ctx, conn, command) - - if len(ret) == 0 { - panic("no return value specified for Exec") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection, string) error); ok { - r0 = returnFunc(ctx, conn, command) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// MigrationRemoteRepo_Exec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exec' -type MigrationRemoteRepo_Exec_Call struct { - *mock.Call -} - -// Exec is a helper method to define mock.On call -// - ctx context.Context -// - conn *request.ToolboxMigrationConnection -// - command string -func (_e *MigrationRemoteRepo_Expecter) Exec(ctx any, conn any, command any) *MigrationRemoteRepo_Exec_Call { - return &MigrationRemoteRepo_Exec_Call{Call: _e.mock.On("Exec", ctx, conn, command)} -} - -func (_c *MigrationRemoteRepo_Exec_Call) Run(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, command string)) *MigrationRemoteRepo_Exec_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.ToolboxMigrationConnection - if args[1] != nil { - arg1 = args[1].(*request.ToolboxMigrationConnection) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *MigrationRemoteRepo_Exec_Call) Return(err error) *MigrationRemoteRepo_Exec_Call { - _c.Call.Return(err) - return _c -} - -func (_c *MigrationRemoteRepo_Exec_Call) RunAndReturn(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, command string) error) *MigrationRemoteRepo_Exec_Call { - _c.Call.Return(run) - return _c -} - -// Request provides a mock function for the type MigrationRemoteRepo -func (_mock *MigrationRemoteRepo) Request(ctx context.Context, conn *request.ToolboxMigrationConnection, method string, path string, body any) ([]byte, error) { - ret := _mock.Called(ctx, conn, method, path, body) - - if len(ret) == 0 { - panic("no return value specified for Request") - } - - var r0 []byte - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection, string, string, any) ([]byte, error)); ok { - return returnFunc(ctx, conn, method, path, body) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection, string, string, any) []byte); ok { - r0 = returnFunc(ctx, conn, method, path, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *request.ToolboxMigrationConnection, string, string, any) error); ok { - r1 = returnFunc(ctx, conn, method, path, body) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// MigrationRemoteRepo_Request_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Request' -type MigrationRemoteRepo_Request_Call struct { - *mock.Call -} - -// Request is a helper method to define mock.On call -// - ctx context.Context -// - conn *request.ToolboxMigrationConnection -// - method string -// - path string -// - body any -func (_e *MigrationRemoteRepo_Expecter) Request(ctx any, conn any, method any, path any, body any) *MigrationRemoteRepo_Request_Call { - return &MigrationRemoteRepo_Request_Call{Call: _e.mock.On("Request", ctx, conn, method, path, body)} -} - -func (_c *MigrationRemoteRepo_Request_Call) Run(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, method string, path string, body any)) *MigrationRemoteRepo_Request_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.ToolboxMigrationConnection - if args[1] != nil { - arg1 = args[1].(*request.ToolboxMigrationConnection) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - var arg4 any - if args[4] != nil { - arg4 = args[4].(any) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - ) - }) - return _c -} - -func (_c *MigrationRemoteRepo_Request_Call) Return(bytes []byte, err error) *MigrationRemoteRepo_Request_Call { - _c.Call.Return(bytes, err) - return _c -} - -func (_c *MigrationRemoteRepo_Request_Call) RunAndReturn(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, method string, path string, body any) ([]byte, error)) *MigrationRemoteRepo_Request_Call { - _c.Call.Return(run) - return _c -} - -// Upload provides a mock function for the type MigrationRemoteRepo -func (_mock *MigrationRemoteRepo) Upload(ctx context.Context, conn *request.ToolboxMigrationConnection, local string, remote string, progress types.MigrationProgress) error { - ret := _mock.Called(ctx, conn, local, remote, progress) - - if len(ret) == 0 { - panic("no return value specified for Upload") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection, string, string, types.MigrationProgress) error); ok { - r0 = returnFunc(ctx, conn, local, remote, progress) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// MigrationRemoteRepo_Upload_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Upload' -type MigrationRemoteRepo_Upload_Call struct { - *mock.Call -} - -// Upload is a helper method to define mock.On call -// - ctx context.Context -// - conn *request.ToolboxMigrationConnection -// - local string -// - remote string -// - progress types.MigrationProgress -func (_e *MigrationRemoteRepo_Expecter) Upload(ctx any, conn any, local any, remote any, progress any) *MigrationRemoteRepo_Upload_Call { - return &MigrationRemoteRepo_Upload_Call{Call: _e.mock.On("Upload", ctx, conn, local, remote, progress)} -} - -func (_c *MigrationRemoteRepo_Upload_Call) Run(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, local string, remote string, progress types.MigrationProgress)) *MigrationRemoteRepo_Upload_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.ToolboxMigrationConnection - if args[1] != nil { - arg1 = args[1].(*request.ToolboxMigrationConnection) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - var arg4 types.MigrationProgress - if args[4] != nil { - arg4 = args[4].(types.MigrationProgress) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - ) - }) - return _c -} - -func (_c *MigrationRemoteRepo_Upload_Call) Return(err error) *MigrationRemoteRepo_Upload_Call { - _c.Call.Return(err) - return _c -} - -func (_c *MigrationRemoteRepo_Upload_Call) RunAndReturn(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, local string, remote string, progress types.MigrationProgress) error) *MigrationRemoteRepo_Upload_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/MigrationSourceRepo.go b/mocks/biz/MigrationSourceRepo.go deleted file mode 100644 index c6f47f8f0..000000000 --- a/mocks/biz/MigrationSourceRepo.go +++ /dev/null @@ -1,475 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "context" - - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewMigrationSourceRepo creates a new instance of MigrationSourceRepo. 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 NewMigrationSourceRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *MigrationSourceRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &MigrationSourceRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// MigrationSourceRepo is an autogenerated mock type for the MigrationSourceRepo type -type MigrationSourceRepo struct { - mock.Mock -} - -type MigrationSourceRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *MigrationSourceRepo) EXPECT() *MigrationSourceRepo_Expecter { - return &MigrationSourceRepo_Expecter{mock: &_m.Mock} -} - -// Backup provides a mock function for the type MigrationSourceRepo -func (_mock *MigrationSourceRepo) Backup(ctx context.Context, conn *request.ToolboxMigrationConnection, detail *types.MigrationDetail) (string, error) { - ret := _mock.Called(ctx, conn, detail) - - if len(ret) == 0 { - panic("no return value specified for Backup") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection, *types.MigrationDetail) (string, error)); ok { - return returnFunc(ctx, conn, detail) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection, *types.MigrationDetail) string); ok { - r0 = returnFunc(ctx, conn, detail) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *request.ToolboxMigrationConnection, *types.MigrationDetail) error); ok { - r1 = returnFunc(ctx, conn, detail) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// MigrationSourceRepo_Backup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Backup' -type MigrationSourceRepo_Backup_Call struct { - *mock.Call -} - -// Backup is a helper method to define mock.On call -// - ctx context.Context -// - conn *request.ToolboxMigrationConnection -// - detail *types.MigrationDetail -func (_e *MigrationSourceRepo_Expecter) Backup(ctx any, conn any, detail any) *MigrationSourceRepo_Backup_Call { - return &MigrationSourceRepo_Backup_Call{Call: _e.mock.On("Backup", ctx, conn, detail)} -} - -func (_c *MigrationSourceRepo_Backup_Call) Run(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, detail *types.MigrationDetail)) *MigrationSourceRepo_Backup_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.ToolboxMigrationConnection - if args[1] != nil { - arg1 = args[1].(*request.ToolboxMigrationConnection) - } - var arg2 *types.MigrationDetail - if args[2] != nil { - arg2 = args[2].(*types.MigrationDetail) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *MigrationSourceRepo_Backup_Call) Return(s string, err error) *MigrationSourceRepo_Backup_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *MigrationSourceRepo_Backup_Call) RunAndReturn(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, detail *types.MigrationDetail) (string, error)) *MigrationSourceRepo_Backup_Call { - _c.Call.Return(run) - return _c -} - -// Detail provides a mock function for the type MigrationSourceRepo -func (_mock *MigrationSourceRepo) Detail(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem) (*types.MigrationDetail, error) { - ret := _mock.Called(ctx, conn, item) - - if len(ret) == 0 { - panic("no return value specified for Detail") - } - - var r0 *types.MigrationDetail - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection, types.MigrationItem) (*types.MigrationDetail, error)); ok { - return returnFunc(ctx, conn, item) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection, types.MigrationItem) *types.MigrationDetail); ok { - r0 = returnFunc(ctx, conn, item) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*types.MigrationDetail) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *request.ToolboxMigrationConnection, types.MigrationItem) error); ok { - r1 = returnFunc(ctx, conn, item) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// MigrationSourceRepo_Detail_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Detail' -type MigrationSourceRepo_Detail_Call struct { - *mock.Call -} - -// Detail is a helper method to define mock.On call -// - ctx context.Context -// - conn *request.ToolboxMigrationConnection -// - item types.MigrationItem -func (_e *MigrationSourceRepo_Expecter) Detail(ctx any, conn any, item any) *MigrationSourceRepo_Detail_Call { - return &MigrationSourceRepo_Detail_Call{Call: _e.mock.On("Detail", ctx, conn, item)} -} - -func (_c *MigrationSourceRepo_Detail_Call) Run(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem)) *MigrationSourceRepo_Detail_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.ToolboxMigrationConnection - if args[1] != nil { - arg1 = args[1].(*request.ToolboxMigrationConnection) - } - var arg2 types.MigrationItem - if args[2] != nil { - arg2 = args[2].(types.MigrationItem) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *MigrationSourceRepo_Detail_Call) Return(migrationDetail *types.MigrationDetail, err error) *MigrationSourceRepo_Detail_Call { - _c.Call.Return(migrationDetail, err) - return _c -} - -func (_c *MigrationSourceRepo_Detail_Call) RunAndReturn(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem) (*types.MigrationDetail, error)) *MigrationSourceRepo_Detail_Call { - _c.Call.Return(run) - return _c -} - -// Download provides a mock function for the type MigrationSourceRepo -func (_mock *MigrationSourceRepo) Download(ctx context.Context, conn *request.ToolboxMigrationConnection, remote string, local string, progress types.MigrationProgress) error { - ret := _mock.Called(ctx, conn, remote, local, progress) - - if len(ret) == 0 { - panic("no return value specified for Download") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection, string, string, types.MigrationProgress) error); ok { - r0 = returnFunc(ctx, conn, remote, local, progress) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// MigrationSourceRepo_Download_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Download' -type MigrationSourceRepo_Download_Call struct { - *mock.Call -} - -// Download is a helper method to define mock.On call -// - ctx context.Context -// - conn *request.ToolboxMigrationConnection -// - remote string -// - local string -// - progress types.MigrationProgress -func (_e *MigrationSourceRepo_Expecter) Download(ctx any, conn any, remote any, local any, progress any) *MigrationSourceRepo_Download_Call { - return &MigrationSourceRepo_Download_Call{Call: _e.mock.On("Download", ctx, conn, remote, local, progress)} -} - -func (_c *MigrationSourceRepo_Download_Call) Run(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, remote string, local string, progress types.MigrationProgress)) *MigrationSourceRepo_Download_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.ToolboxMigrationConnection - if args[1] != nil { - arg1 = args[1].(*request.ToolboxMigrationConnection) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - var arg4 types.MigrationProgress - if args[4] != nil { - arg4 = args[4].(types.MigrationProgress) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - ) - }) - return _c -} - -func (_c *MigrationSourceRepo_Download_Call) Return(err error) *MigrationSourceRepo_Download_Call { - _c.Call.Return(err) - return _c -} - -func (_c *MigrationSourceRepo_Download_Call) RunAndReturn(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, remote string, local string, progress types.MigrationProgress) error) *MigrationSourceRepo_Download_Call { - _c.Call.Return(run) - return _c -} - -// Items provides a mock function for the type MigrationSourceRepo -func (_mock *MigrationSourceRepo) Items(ctx context.Context, conn *request.ToolboxMigrationConnection) ([]types.MigrationItem, error) { - ret := _mock.Called(ctx, conn) - - if len(ret) == 0 { - panic("no return value specified for Items") - } - - var r0 []types.MigrationItem - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection) ([]types.MigrationItem, error)); ok { - return returnFunc(ctx, conn) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection) []types.MigrationItem); ok { - r0 = returnFunc(ctx, conn) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.MigrationItem) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *request.ToolboxMigrationConnection) error); ok { - r1 = returnFunc(ctx, conn) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// MigrationSourceRepo_Items_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Items' -type MigrationSourceRepo_Items_Call struct { - *mock.Call -} - -// Items is a helper method to define mock.On call -// - ctx context.Context -// - conn *request.ToolboxMigrationConnection -func (_e *MigrationSourceRepo_Expecter) Items(ctx any, conn any) *MigrationSourceRepo_Items_Call { - return &MigrationSourceRepo_Items_Call{Call: _e.mock.On("Items", ctx, conn)} -} - -func (_c *MigrationSourceRepo_Items_Call) Run(run func(ctx context.Context, conn *request.ToolboxMigrationConnection)) *MigrationSourceRepo_Items_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.ToolboxMigrationConnection - if args[1] != nil { - arg1 = args[1].(*request.ToolboxMigrationConnection) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *MigrationSourceRepo_Items_Call) Return(migrationItems []types.MigrationItem, err error) *MigrationSourceRepo_Items_Call { - _c.Call.Return(migrationItems, err) - return _c -} - -func (_c *MigrationSourceRepo_Items_Call) RunAndReturn(run func(ctx context.Context, conn *request.ToolboxMigrationConnection) ([]types.MigrationItem, error)) *MigrationSourceRepo_Items_Call { - _c.Call.Return(run) - return _c -} - -// Probe provides a mock function for the type MigrationSourceRepo -func (_mock *MigrationSourceRepo) Probe(ctx context.Context, conn *request.ToolboxMigrationConnection) (*types.MigrationSource, error) { - ret := _mock.Called(ctx, conn) - - if len(ret) == 0 { - panic("no return value specified for Probe") - } - - var r0 *types.MigrationSource - var r1 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection) (*types.MigrationSource, error)); ok { - return returnFunc(ctx, conn) - } - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection) *types.MigrationSource); ok { - r0 = returnFunc(ctx, conn) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*types.MigrationSource) - } - } - if returnFunc, ok := ret.Get(1).(func(context.Context, *request.ToolboxMigrationConnection) error); ok { - r1 = returnFunc(ctx, conn) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// MigrationSourceRepo_Probe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Probe' -type MigrationSourceRepo_Probe_Call struct { - *mock.Call -} - -// Probe is a helper method to define mock.On call -// - ctx context.Context -// - conn *request.ToolboxMigrationConnection -func (_e *MigrationSourceRepo_Expecter) Probe(ctx any, conn any) *MigrationSourceRepo_Probe_Call { - return &MigrationSourceRepo_Probe_Call{Call: _e.mock.On("Probe", ctx, conn)} -} - -func (_c *MigrationSourceRepo_Probe_Call) Run(run func(ctx context.Context, conn *request.ToolboxMigrationConnection)) *MigrationSourceRepo_Probe_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.ToolboxMigrationConnection - if args[1] != nil { - arg1 = args[1].(*request.ToolboxMigrationConnection) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *MigrationSourceRepo_Probe_Call) Return(migrationSource *types.MigrationSource, err error) *MigrationSourceRepo_Probe_Call { - _c.Call.Return(migrationSource, err) - return _c -} - -func (_c *MigrationSourceRepo_Probe_Call) RunAndReturn(run func(ctx context.Context, conn *request.ToolboxMigrationConnection) (*types.MigrationSource, error)) *MigrationSourceRepo_Probe_Call { - _c.Call.Return(run) - return _c -} - -// SetRunning provides a mock function for the type MigrationSourceRepo -func (_mock *MigrationSourceRepo) SetRunning(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem, running bool) error { - ret := _mock.Called(ctx, conn, item, running) - - if len(ret) == 0 { - panic("no return value specified for SetRunning") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, *request.ToolboxMigrationConnection, types.MigrationItem, bool) error); ok { - r0 = returnFunc(ctx, conn, item, running) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// MigrationSourceRepo_SetRunning_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetRunning' -type MigrationSourceRepo_SetRunning_Call struct { - *mock.Call -} - -// SetRunning is a helper method to define mock.On call -// - ctx context.Context -// - conn *request.ToolboxMigrationConnection -// - item types.MigrationItem -// - running bool -func (_e *MigrationSourceRepo_Expecter) SetRunning(ctx any, conn any, item any, running any) *MigrationSourceRepo_SetRunning_Call { - return &MigrationSourceRepo_SetRunning_Call{Call: _e.mock.On("SetRunning", ctx, conn, item, running)} -} - -func (_c *MigrationSourceRepo_SetRunning_Call) Run(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem, running bool)) *MigrationSourceRepo_SetRunning_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 *request.ToolboxMigrationConnection - if args[1] != nil { - arg1 = args[1].(*request.ToolboxMigrationConnection) - } - var arg2 types.MigrationItem - if args[2] != nil { - arg2 = args[2].(types.MigrationItem) - } - var arg3 bool - if args[3] != nil { - arg3 = args[3].(bool) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *MigrationSourceRepo_SetRunning_Call) Return(err error) *MigrationSourceRepo_SetRunning_Call { - _c.Call.Return(err) - return _c -} - -func (_c *MigrationSourceRepo_SetRunning_Call) RunAndReturn(run func(ctx context.Context, conn *request.ToolboxMigrationConnection, item types.MigrationItem, running bool) error) *MigrationSourceRepo_SetRunning_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/MonitorRepo.go b/mocks/biz/MonitorRepo.go deleted file mode 100644 index 16f0b5d6c..000000000 --- a/mocks/biz/MonitorRepo.go +++ /dev/null @@ -1,306 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "time" - - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewMonitorRepo creates a new instance of MonitorRepo. 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 NewMonitorRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *MonitorRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &MonitorRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// MonitorRepo is an autogenerated mock type for the MonitorRepo type -type MonitorRepo struct { - mock.Mock -} - -type MonitorRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *MonitorRepo) EXPECT() *MonitorRepo_Expecter { - return &MonitorRepo_Expecter{mock: &_m.Mock} -} - -// Clear provides a mock function for the type MonitorRepo -func (_mock *MonitorRepo) Clear() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for Clear") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// MonitorRepo_Clear_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Clear' -type MonitorRepo_Clear_Call struct { - *mock.Call -} - -// Clear is a helper method to define mock.On call -func (_e *MonitorRepo_Expecter) Clear() *MonitorRepo_Clear_Call { - return &MonitorRepo_Clear_Call{Call: _e.mock.On("Clear")} -} - -func (_c *MonitorRepo_Clear_Call) Run(run func()) *MonitorRepo_Clear_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MonitorRepo_Clear_Call) Return(err error) *MonitorRepo_Clear_Call { - _c.Call.Return(err) - return _c -} - -func (_c *MonitorRepo_Clear_Call) RunAndReturn(run func() error) *MonitorRepo_Clear_Call { - _c.Call.Return(run) - return _c -} - -// ClearBefore provides a mock function for the type MonitorRepo -func (_mock *MonitorRepo) ClearBefore(t time.Time) error { - ret := _mock.Called(t) - - if len(ret) == 0 { - panic("no return value specified for ClearBefore") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(time.Time) error); ok { - r0 = returnFunc(t) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// MonitorRepo_ClearBefore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearBefore' -type MonitorRepo_ClearBefore_Call struct { - *mock.Call -} - -// ClearBefore is a helper method to define mock.On call -// - t time.Time -func (_e *MonitorRepo_Expecter) ClearBefore(t any) *MonitorRepo_ClearBefore_Call { - return &MonitorRepo_ClearBefore_Call{Call: _e.mock.On("ClearBefore", t)} -} - -func (_c *MonitorRepo_ClearBefore_Call) Run(run func(t time.Time)) *MonitorRepo_ClearBefore_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 time.Time - if args[0] != nil { - arg0 = args[0].(time.Time) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *MonitorRepo_ClearBefore_Call) Return(err error) *MonitorRepo_ClearBefore_Call { - _c.Call.Return(err) - return _c -} - -func (_c *MonitorRepo_ClearBefore_Call) RunAndReturn(run func(t time.Time) error) *MonitorRepo_ClearBefore_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function for the type MonitorRepo -func (_mock *MonitorRepo) Create(monitor *biz.Monitor) error { - ret := _mock.Called(monitor) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Monitor) error); ok { - r0 = returnFunc(monitor) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// MonitorRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MonitorRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - monitor *biz.Monitor -func (_e *MonitorRepo_Expecter) Create(monitor any) *MonitorRepo_Create_Call { - return &MonitorRepo_Create_Call{Call: _e.mock.On("Create", monitor)} -} - -func (_c *MonitorRepo_Create_Call) Run(run func(monitor *biz.Monitor)) *MonitorRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Monitor - if args[0] != nil { - arg0 = args[0].(*biz.Monitor) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *MonitorRepo_Create_Call) Return(err error) *MonitorRepo_Create_Call { - _c.Call.Return(err) - return _c -} - -func (_c *MonitorRepo_Create_Call) RunAndReturn(run func(monitor *biz.Monitor) error) *MonitorRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type MonitorRepo -func (_mock *MonitorRepo) List(start time.Time, end time.Time) ([]*biz.Monitor, error) { - ret := _mock.Called(start, end) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.Monitor - var r1 error - if returnFunc, ok := ret.Get(0).(func(time.Time, time.Time) ([]*biz.Monitor, error)); ok { - return returnFunc(start, end) - } - if returnFunc, ok := ret.Get(0).(func(time.Time, time.Time) []*biz.Monitor); ok { - r0 = returnFunc(start, end) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.Monitor) - } - } - if returnFunc, ok := ret.Get(1).(func(time.Time, time.Time) error); ok { - r1 = returnFunc(start, end) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// MonitorRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type MonitorRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - start time.Time -// - end time.Time -func (_e *MonitorRepo_Expecter) List(start any, end any) *MonitorRepo_List_Call { - return &MonitorRepo_List_Call{Call: _e.mock.On("List", start, end)} -} - -func (_c *MonitorRepo_List_Call) Run(run func(start time.Time, end time.Time)) *MonitorRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 time.Time - if args[0] != nil { - arg0 = args[0].(time.Time) - } - var arg1 time.Time - if args[1] != nil { - arg1 = args[1].(time.Time) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *MonitorRepo_List_Call) Return(monitors []*biz.Monitor, err error) *MonitorRepo_List_Call { - _c.Call.Return(monitors, err) - return _c -} - -func (_c *MonitorRepo_List_Call) RunAndReturn(run func(start time.Time, end time.Time) ([]*biz.Monitor, error)) *MonitorRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// VacuumDB provides a mock function for the type MonitorRepo -func (_mock *MonitorRepo) VacuumDB() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for VacuumDB") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// MonitorRepo_VacuumDB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VacuumDB' -type MonitorRepo_VacuumDB_Call struct { - *mock.Call -} - -// VacuumDB is a helper method to define mock.On call -func (_e *MonitorRepo_Expecter) VacuumDB() *MonitorRepo_VacuumDB_Call { - return &MonitorRepo_VacuumDB_Call{Call: _e.mock.On("VacuumDB")} -} - -func (_c *MonitorRepo_VacuumDB_Call) Run(run func()) *MonitorRepo_VacuumDB_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MonitorRepo_VacuumDB_Call) Return(err error) *MonitorRepo_VacuumDB_Call { - _c.Call.Return(err) - return _c -} - -func (_c *MonitorRepo_VacuumDB_Call) RunAndReturn(run func() error) *MonitorRepo_VacuumDB_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/NotifyChannelRepo.go b/mocks/biz/NotifyChannelRepo.go deleted file mode 100644 index 12c443935..000000000 --- a/mocks/biz/NotifyChannelRepo.go +++ /dev/null @@ -1,452 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewNotifyChannelRepo creates a new instance of NotifyChannelRepo. 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 NewNotifyChannelRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *NotifyChannelRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &NotifyChannelRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// NotifyChannelRepo is an autogenerated mock type for the NotifyChannelRepo type -type NotifyChannelRepo struct { - mock.Mock -} - -type NotifyChannelRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *NotifyChannelRepo) EXPECT() *NotifyChannelRepo_Expecter { - return &NotifyChannelRepo_Expecter{mock: &_m.Mock} -} - -// All provides a mock function for the type NotifyChannelRepo -func (_mock *NotifyChannelRepo) All() ([]*biz.NotifyChannel, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for All") - } - - var r0 []*biz.NotifyChannel - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]*biz.NotifyChannel, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []*biz.NotifyChannel); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.NotifyChannel) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// NotifyChannelRepo_All_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'All' -type NotifyChannelRepo_All_Call struct { - *mock.Call -} - -// All is a helper method to define mock.On call -func (_e *NotifyChannelRepo_Expecter) All() *NotifyChannelRepo_All_Call { - return &NotifyChannelRepo_All_Call{Call: _e.mock.On("All")} -} - -func (_c *NotifyChannelRepo_All_Call) Run(run func()) *NotifyChannelRepo_All_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *NotifyChannelRepo_All_Call) Return(notifyChannels []*biz.NotifyChannel, err error) *NotifyChannelRepo_All_Call { - _c.Call.Return(notifyChannels, err) - return _c -} - -func (_c *NotifyChannelRepo_All_Call) RunAndReturn(run func() ([]*biz.NotifyChannel, error)) *NotifyChannelRepo_All_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function for the type NotifyChannelRepo -func (_mock *NotifyChannelRepo) Create(channel *biz.NotifyChannel) error { - ret := _mock.Called(channel) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.NotifyChannel) error); ok { - r0 = returnFunc(channel) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// NotifyChannelRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type NotifyChannelRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - channel *biz.NotifyChannel -func (_e *NotifyChannelRepo_Expecter) Create(channel any) *NotifyChannelRepo_Create_Call { - return &NotifyChannelRepo_Create_Call{Call: _e.mock.On("Create", channel)} -} - -func (_c *NotifyChannelRepo_Create_Call) Run(run func(channel *biz.NotifyChannel)) *NotifyChannelRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.NotifyChannel - if args[0] != nil { - arg0 = args[0].(*biz.NotifyChannel) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *NotifyChannelRepo_Create_Call) Return(err error) *NotifyChannelRepo_Create_Call { - _c.Call.Return(err) - return _c -} - -func (_c *NotifyChannelRepo_Create_Call) RunAndReturn(run func(channel *biz.NotifyChannel) error) *NotifyChannelRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type NotifyChannelRepo -func (_mock *NotifyChannelRepo) Delete(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// NotifyChannelRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type NotifyChannelRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *NotifyChannelRepo_Expecter) Delete(id any) *NotifyChannelRepo_Delete_Call { - return &NotifyChannelRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *NotifyChannelRepo_Delete_Call) Run(run func(id uint)) *NotifyChannelRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *NotifyChannelRepo_Delete_Call) Return(err error) *NotifyChannelRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *NotifyChannelRepo_Delete_Call) RunAndReturn(run func(id uint) error) *NotifyChannelRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type NotifyChannelRepo -func (_mock *NotifyChannelRepo) Get(id uint) (*biz.NotifyChannel, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.NotifyChannel - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.NotifyChannel, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.NotifyChannel); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.NotifyChannel) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// NotifyChannelRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type NotifyChannelRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *NotifyChannelRepo_Expecter) Get(id any) *NotifyChannelRepo_Get_Call { - return &NotifyChannelRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *NotifyChannelRepo_Get_Call) Run(run func(id uint)) *NotifyChannelRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *NotifyChannelRepo_Get_Call) Return(notifyChannel *biz.NotifyChannel, err error) *NotifyChannelRepo_Get_Call { - _c.Call.Return(notifyChannel, err) - return _c -} - -func (_c *NotifyChannelRepo_Get_Call) RunAndReturn(run func(id uint) (*biz.NotifyChannel, error)) *NotifyChannelRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// GetByIDs provides a mock function for the type NotifyChannelRepo -func (_mock *NotifyChannelRepo) GetByIDs(ids []uint) ([]*biz.NotifyChannel, error) { - ret := _mock.Called(ids) - - if len(ret) == 0 { - panic("no return value specified for GetByIDs") - } - - var r0 []*biz.NotifyChannel - var r1 error - if returnFunc, ok := ret.Get(0).(func([]uint) ([]*biz.NotifyChannel, error)); ok { - return returnFunc(ids) - } - if returnFunc, ok := ret.Get(0).(func([]uint) []*biz.NotifyChannel); ok { - r0 = returnFunc(ids) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.NotifyChannel) - } - } - if returnFunc, ok := ret.Get(1).(func([]uint) error); ok { - r1 = returnFunc(ids) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// NotifyChannelRepo_GetByIDs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByIDs' -type NotifyChannelRepo_GetByIDs_Call struct { - *mock.Call -} - -// GetByIDs is a helper method to define mock.On call -// - ids []uint -func (_e *NotifyChannelRepo_Expecter) GetByIDs(ids any) *NotifyChannelRepo_GetByIDs_Call { - return &NotifyChannelRepo_GetByIDs_Call{Call: _e.mock.On("GetByIDs", ids)} -} - -func (_c *NotifyChannelRepo_GetByIDs_Call) Run(run func(ids []uint)) *NotifyChannelRepo_GetByIDs_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []uint - if args[0] != nil { - arg0 = args[0].([]uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *NotifyChannelRepo_GetByIDs_Call) Return(notifyChannels []*biz.NotifyChannel, err error) *NotifyChannelRepo_GetByIDs_Call { - _c.Call.Return(notifyChannels, err) - return _c -} - -func (_c *NotifyChannelRepo_GetByIDs_Call) RunAndReturn(run func(ids []uint) ([]*biz.NotifyChannel, error)) *NotifyChannelRepo_GetByIDs_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type NotifyChannelRepo -func (_mock *NotifyChannelRepo) List(page uint, limit uint) ([]*biz.NotifyChannel, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.NotifyChannel - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.NotifyChannel, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.NotifyChannel); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.NotifyChannel) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// NotifyChannelRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type NotifyChannelRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *NotifyChannelRepo_Expecter) List(page any, limit any) *NotifyChannelRepo_List_Call { - return &NotifyChannelRepo_List_Call{Call: _e.mock.On("List", page, limit)} -} - -func (_c *NotifyChannelRepo_List_Call) Run(run func(page uint, limit uint)) *NotifyChannelRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *NotifyChannelRepo_List_Call) Return(notifyChannels []*biz.NotifyChannel, n int64, err error) *NotifyChannelRepo_List_Call { - _c.Call.Return(notifyChannels, n, err) - return _c -} - -func (_c *NotifyChannelRepo_List_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.NotifyChannel, int64, error)) *NotifyChannelRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function for the type NotifyChannelRepo -func (_mock *NotifyChannelRepo) Update(channel *biz.NotifyChannel) error { - ret := _mock.Called(channel) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.NotifyChannel) error); ok { - r0 = returnFunc(channel) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// NotifyChannelRepo_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type NotifyChannelRepo_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - channel *biz.NotifyChannel -func (_e *NotifyChannelRepo_Expecter) Update(channel any) *NotifyChannelRepo_Update_Call { - return &NotifyChannelRepo_Update_Call{Call: _e.mock.On("Update", channel)} -} - -func (_c *NotifyChannelRepo_Update_Call) Run(run func(channel *biz.NotifyChannel)) *NotifyChannelRepo_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.NotifyChannel - if args[0] != nil { - arg0 = args[0].(*biz.NotifyChannel) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *NotifyChannelRepo_Update_Call) Return(err error) *NotifyChannelRepo_Update_Call { - _c.Call.Return(err) - return _c -} - -func (_c *NotifyChannelRepo_Update_Call) RunAndReturn(run func(channel *biz.NotifyChannel) error) *NotifyChannelRepo_Update_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/ProjectRepo.go b/mocks/biz/ProjectRepo.go deleted file mode 100644 index c3c96c022..000000000 --- a/mocks/biz/ProjectRepo.go +++ /dev/null @@ -1,689 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewProjectRepo creates a new instance of ProjectRepo. 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 NewProjectRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *ProjectRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &ProjectRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// ProjectRepo is an autogenerated mock type for the ProjectRepo type -type ProjectRepo struct { - mock.Mock -} - -type ProjectRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *ProjectRepo) EXPECT() *ProjectRepo_Expecter { - return &ProjectRepo_Expecter{mock: &_m.Mock} -} - -// Count provides a mock function for the type ProjectRepo -func (_mock *ProjectRepo) Count() (int64, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for Count") - } - - var r0 int64 - var r1 error - if returnFunc, ok := ret.Get(0).(func() (int64, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() int64); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(int64) - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ProjectRepo_Count_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Count' -type ProjectRepo_Count_Call struct { - *mock.Call -} - -// Count is a helper method to define mock.On call -func (_e *ProjectRepo_Expecter) Count() *ProjectRepo_Count_Call { - return &ProjectRepo_Count_Call{Call: _e.mock.On("Count")} -} - -func (_c *ProjectRepo_Count_Call) Run(run func()) *ProjectRepo_Count_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *ProjectRepo_Count_Call) Return(n int64, err error) *ProjectRepo_Count_Call { - _c.Call.Return(n, err) - return _c -} - -func (_c *ProjectRepo_Count_Call) RunAndReturn(run func() (int64, error)) *ProjectRepo_Count_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function for the type ProjectRepo -func (_mock *ProjectRepo) Create(project *biz.Project, req *request.ProjectCreate) error { - ret := _mock.Called(project, req) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Project, *request.ProjectCreate) error); ok { - r0 = returnFunc(project, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ProjectRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type ProjectRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - project *biz.Project -// - req *request.ProjectCreate -func (_e *ProjectRepo_Expecter) Create(project any, req any) *ProjectRepo_Create_Call { - return &ProjectRepo_Create_Call{Call: _e.mock.On("Create", project, req)} -} - -func (_c *ProjectRepo_Create_Call) Run(run func(project *biz.Project, req *request.ProjectCreate)) *ProjectRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Project - if args[0] != nil { - arg0 = args[0].(*biz.Project) - } - var arg1 *request.ProjectCreate - if args[1] != nil { - arg1 = args[1].(*request.ProjectCreate) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ProjectRepo_Create_Call) Return(err error) *ProjectRepo_Create_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ProjectRepo_Create_Call) RunAndReturn(run func(project *biz.Project, req *request.ProjectCreate) error) *ProjectRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type ProjectRepo -func (_mock *ProjectRepo) Delete(project *biz.Project) error { - ret := _mock.Called(project) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Project) error); ok { - r0 = returnFunc(project) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ProjectRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type ProjectRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - project *biz.Project -func (_e *ProjectRepo_Expecter) Delete(project any) *ProjectRepo_Delete_Call { - return &ProjectRepo_Delete_Call{Call: _e.mock.On("Delete", project)} -} - -func (_c *ProjectRepo_Delete_Call) Run(run func(project *biz.Project)) *ProjectRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Project - if args[0] != nil { - arg0 = args[0].(*biz.Project) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ProjectRepo_Delete_Call) Return(err error) *ProjectRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ProjectRepo_Delete_Call) RunAndReturn(run func(project *biz.Project) error) *ProjectRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// GetEntity provides a mock function for the type ProjectRepo -func (_mock *ProjectRepo) GetEntity(id uint) (*biz.Project, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for GetEntity") - } - - var r0 *biz.Project - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.Project, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.Project); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.Project) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ProjectRepo_GetEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetEntity' -type ProjectRepo_GetEntity_Call struct { - *mock.Call -} - -// GetEntity is a helper method to define mock.On call -// - id uint -func (_e *ProjectRepo_Expecter) GetEntity(id any) *ProjectRepo_GetEntity_Call { - return &ProjectRepo_GetEntity_Call{Call: _e.mock.On("GetEntity", id)} -} - -func (_c *ProjectRepo_GetEntity_Call) Run(run func(id uint)) *ProjectRepo_GetEntity_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ProjectRepo_GetEntity_Call) Return(project *biz.Project, err error) *ProjectRepo_GetEntity_Call { - _c.Call.Return(project, err) - return _c -} - -func (_c *ProjectRepo_GetEntity_Call) RunAndReturn(run func(id uint) (*biz.Project, error)) *ProjectRepo_GetEntity_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type ProjectRepo -func (_mock *ProjectRepo) List(typ types.ProjectType, page uint, limit uint) ([]*biz.Project, int64, error) { - ret := _mock.Called(typ, page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.Project - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(types.ProjectType, uint, uint) ([]*biz.Project, int64, error)); ok { - return returnFunc(typ, page, limit) - } - if returnFunc, ok := ret.Get(0).(func(types.ProjectType, uint, uint) []*biz.Project); ok { - r0 = returnFunc(typ, page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.Project) - } - } - if returnFunc, ok := ret.Get(1).(func(types.ProjectType, uint, uint) int64); ok { - r1 = returnFunc(typ, page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(types.ProjectType, uint, uint) error); ok { - r2 = returnFunc(typ, page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// ProjectRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type ProjectRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - typ types.ProjectType -// - page uint -// - limit uint -func (_e *ProjectRepo_Expecter) List(typ any, page any, limit any) *ProjectRepo_List_Call { - return &ProjectRepo_List_Call{Call: _e.mock.On("List", typ, page, limit)} -} - -func (_c *ProjectRepo_List_Call) Run(run func(typ types.ProjectType, page uint, limit uint)) *ProjectRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 types.ProjectType - if args[0] != nil { - arg0 = args[0].(types.ProjectType) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - var arg2 uint - if args[2] != nil { - arg2 = args[2].(uint) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *ProjectRepo_List_Call) Return(projects []*biz.Project, n int64, err error) *ProjectRepo_List_Call { - _c.Call.Return(projects, n, err) - return _c -} - -func (_c *ProjectRepo_List_Call) RunAndReturn(run func(typ types.ProjectType, page uint, limit uint) ([]*biz.Project, int64, error)) *ProjectRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// NameExists provides a mock function for the type ProjectRepo -func (_mock *ProjectRepo) NameExists(name string) (bool, error) { - ret := _mock.Called(name) - - if len(ret) == 0 { - panic("no return value specified for NameExists") - } - - var r0 bool - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) (bool, error)); ok { - return returnFunc(name) - } - if returnFunc, ok := ret.Get(0).(func(string) bool); ok { - r0 = returnFunc(name) - } else { - r0 = ret.Get(0).(bool) - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(name) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ProjectRepo_NameExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NameExists' -type ProjectRepo_NameExists_Call struct { - *mock.Call -} - -// NameExists is a helper method to define mock.On call -// - name string -func (_e *ProjectRepo_Expecter) NameExists(name any) *ProjectRepo_NameExists_Call { - return &ProjectRepo_NameExists_Call{Call: _e.mock.On("NameExists", name)} -} - -func (_c *ProjectRepo_NameExists_Call) Run(run func(name string)) *ProjectRepo_NameExists_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ProjectRepo_NameExists_Call) Return(b bool, err error) *ProjectRepo_NameExists_Call { - _c.Call.Return(b, err) - return _c -} - -func (_c *ProjectRepo_NameExists_Call) RunAndReturn(run func(name string) (bool, error)) *ProjectRepo_NameExists_Call { - _c.Call.Return(run) - return _c -} - -// ParseDetail provides a mock function for the type ProjectRepo -func (_mock *ProjectRepo) ParseDetail(project *biz.Project) (*types.ProjectDetail, error) { - ret := _mock.Called(project) - - if len(ret) == 0 { - panic("no return value specified for ParseDetail") - } - - var r0 *types.ProjectDetail - var r1 error - if returnFunc, ok := ret.Get(0).(func(*biz.Project) (*types.ProjectDetail, error)); ok { - return returnFunc(project) - } - if returnFunc, ok := ret.Get(0).(func(*biz.Project) *types.ProjectDetail); ok { - r0 = returnFunc(project) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*types.ProjectDetail) - } - } - if returnFunc, ok := ret.Get(1).(func(*biz.Project) error); ok { - r1 = returnFunc(project) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ProjectRepo_ParseDetail_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ParseDetail' -type ProjectRepo_ParseDetail_Call struct { - *mock.Call -} - -// ParseDetail is a helper method to define mock.On call -// - project *biz.Project -func (_e *ProjectRepo_Expecter) ParseDetail(project any) *ProjectRepo_ParseDetail_Call { - return &ProjectRepo_ParseDetail_Call{Call: _e.mock.On("ParseDetail", project)} -} - -func (_c *ProjectRepo_ParseDetail_Call) Run(run func(project *biz.Project)) *ProjectRepo_ParseDetail_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Project - if args[0] != nil { - arg0 = args[0].(*biz.Project) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ProjectRepo_ParseDetail_Call) Return(projectDetail *types.ProjectDetail, err error) *ProjectRepo_ParseDetail_Call { - _c.Call.Return(projectDetail, err) - return _c -} - -func (_c *ProjectRepo_ParseDetail_Call) RunAndReturn(run func(project *biz.Project) (*types.ProjectDetail, error)) *ProjectRepo_ParseDetail_Call { - _c.Call.Return(run) - return _c -} - -// RemoveUnitFile provides a mock function for the type ProjectRepo -func (_mock *ProjectRepo) RemoveUnitFile(name string) error { - ret := _mock.Called(name) - - if len(ret) == 0 { - panic("no return value specified for RemoveUnitFile") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(name) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ProjectRepo_RemoveUnitFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUnitFile' -type ProjectRepo_RemoveUnitFile_Call struct { - *mock.Call -} - -// RemoveUnitFile is a helper method to define mock.On call -// - name string -func (_e *ProjectRepo_Expecter) RemoveUnitFile(name any) *ProjectRepo_RemoveUnitFile_Call { - return &ProjectRepo_RemoveUnitFile_Call{Call: _e.mock.On("RemoveUnitFile", name)} -} - -func (_c *ProjectRepo_RemoveUnitFile_Call) Run(run func(name string)) *ProjectRepo_RemoveUnitFile_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ProjectRepo_RemoveUnitFile_Call) Return(err error) *ProjectRepo_RemoveUnitFile_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ProjectRepo_RemoveUnitFile_Call) RunAndReturn(run func(name string) error) *ProjectRepo_RemoveUnitFile_Call { - _c.Call.Return(run) - return _c -} - -// RenameUnitFile provides a mock function for the type ProjectRepo -func (_mock *ProjectRepo) RenameUnitFile(old string, new string) error { - ret := _mock.Called(old, new) - - if len(ret) == 0 { - panic("no return value specified for RenameUnitFile") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, string) error); ok { - r0 = returnFunc(old, new) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ProjectRepo_RenameUnitFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RenameUnitFile' -type ProjectRepo_RenameUnitFile_Call struct { - *mock.Call -} - -// RenameUnitFile is a helper method to define mock.On call -// - old string -// - new string -func (_e *ProjectRepo_Expecter) RenameUnitFile(old any, new any) *ProjectRepo_RenameUnitFile_Call { - return &ProjectRepo_RenameUnitFile_Call{Call: _e.mock.On("RenameUnitFile", old, new)} -} - -func (_c *ProjectRepo_RenameUnitFile_Call) Run(run func(old string, new string)) *ProjectRepo_RenameUnitFile_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ProjectRepo_RenameUnitFile_Call) Return(err error) *ProjectRepo_RenameUnitFile_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ProjectRepo_RenameUnitFile_Call) RunAndReturn(run func(old string, new string) error) *ProjectRepo_RenameUnitFile_Call { - _c.Call.Return(run) - return _c -} - -// Save provides a mock function for the type ProjectRepo -func (_mock *ProjectRepo) Save(project *biz.Project) error { - ret := _mock.Called(project) - - if len(ret) == 0 { - panic("no return value specified for Save") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Project) error); ok { - r0 = returnFunc(project) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ProjectRepo_Save_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Save' -type ProjectRepo_Save_Call struct { - *mock.Call -} - -// Save is a helper method to define mock.On call -// - project *biz.Project -func (_e *ProjectRepo_Expecter) Save(project any) *ProjectRepo_Save_Call { - return &ProjectRepo_Save_Call{Call: _e.mock.On("Save", project)} -} - -func (_c *ProjectRepo_Save_Call) Run(run func(project *biz.Project)) *ProjectRepo_Save_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Project - if args[0] != nil { - arg0 = args[0].(*biz.Project) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ProjectRepo_Save_Call) Return(err error) *ProjectRepo_Save_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ProjectRepo_Save_Call) RunAndReturn(run func(project *biz.Project) error) *ProjectRepo_Save_Call { - _c.Call.Return(run) - return _c -} - -// UpdateUnitFile provides a mock function for the type ProjectRepo -func (_mock *ProjectRepo) UpdateUnitFile(name string, req *request.ProjectUpdate) error { - ret := _mock.Called(name, req) - - if len(ret) == 0 { - panic("no return value specified for UpdateUnitFile") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, *request.ProjectUpdate) error); ok { - r0 = returnFunc(name, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ProjectRepo_UpdateUnitFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUnitFile' -type ProjectRepo_UpdateUnitFile_Call struct { - *mock.Call -} - -// UpdateUnitFile is a helper method to define mock.On call -// - name string -// - req *request.ProjectUpdate -func (_e *ProjectRepo_Expecter) UpdateUnitFile(name any, req any) *ProjectRepo_UpdateUnitFile_Call { - return &ProjectRepo_UpdateUnitFile_Call{Call: _e.mock.On("UpdateUnitFile", name, req)} -} - -func (_c *ProjectRepo_UpdateUnitFile_Call) Run(run func(name string, req *request.ProjectUpdate)) *ProjectRepo_UpdateUnitFile_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 *request.ProjectUpdate - if args[1] != nil { - arg1 = args[1].(*request.ProjectUpdate) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ProjectRepo_UpdateUnitFile_Call) Return(err error) *ProjectRepo_UpdateUnitFile_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ProjectRepo_UpdateUnitFile_Call) RunAndReturn(run func(name string, req *request.ProjectUpdate) error) *ProjectRepo_UpdateUnitFile_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/SSHRepo.go b/mocks/biz/SSHRepo.go deleted file mode 100644 index a87afd812..000000000 --- a/mocks/biz/SSHRepo.go +++ /dev/null @@ -1,544 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "context" - - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/internal/request" - mock "github.com/stretchr/testify/mock" -) - -// NewSSHRepo creates a new instance of SSHRepo. 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 NewSSHRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *SSHRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &SSHRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// SSHRepo is an autogenerated mock type for the SSHRepo type -type SSHRepo struct { - mock.Mock -} - -type SSHRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *SSHRepo) EXPECT() *SSHRepo_Expecter { - return &SSHRepo_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function for the type SSHRepo -func (_mock *SSHRepo) Create(req *request.SSHCreate) error { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*request.SSHCreate) error); ok { - r0 = returnFunc(req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// SSHRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type SSHRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - req *request.SSHCreate -func (_e *SSHRepo_Expecter) Create(req any) *SSHRepo_Create_Call { - return &SSHRepo_Create_Call{Call: _e.mock.On("Create", req)} -} - -func (_c *SSHRepo_Create_Call) Run(run func(req *request.SSHCreate)) *SSHRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.SSHCreate - if args[0] != nil { - arg0 = args[0].(*request.SSHCreate) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *SSHRepo_Create_Call) Return(err error) *SSHRepo_Create_Call { - _c.Call.Return(err) - return _c -} - -func (_c *SSHRepo_Create_Call) RunAndReturn(run func(req *request.SSHCreate) error) *SSHRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type SSHRepo -func (_mock *SSHRepo) Delete(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// SSHRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type SSHRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *SSHRepo_Expecter) Delete(id any) *SSHRepo_Delete_Call { - return &SSHRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *SSHRepo_Delete_Call) Run(run func(id uint)) *SSHRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *SSHRepo_Delete_Call) Return(err error) *SSHRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *SSHRepo_Delete_Call) RunAndReturn(run func(id uint) error) *SSHRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type SSHRepo -func (_mock *SSHRepo) Get(id uint) (*biz.SSH, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.SSH - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.SSH, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.SSH); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.SSH) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// SSHRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type SSHRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *SSHRepo_Expecter) Get(id any) *SSHRepo_Get_Call { - return &SSHRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *SSHRepo_Get_Call) Run(run func(id uint)) *SSHRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *SSHRepo_Get_Call) Return(sSH *biz.SSH, err error) *SSHRepo_Get_Call { - _c.Call.Return(sSH, err) - return _c -} - -func (_c *SSHRepo_Get_Call) RunAndReturn(run func(id uint) (*biz.SSH, error)) *SSHRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type SSHRepo -func (_mock *SSHRepo) List(page uint, limit uint) ([]*biz.SSH, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.SSH - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.SSH, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.SSH); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.SSH) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// SSHRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type SSHRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *SSHRepo_Expecter) List(page any, limit any) *SSHRepo_List_Call { - return &SSHRepo_List_Call{Call: _e.mock.On("List", page, limit)} -} - -func (_c *SSHRepo_List_Call) Run(run func(page uint, limit uint)) *SSHRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *SSHRepo_List_Call) Return(sSHs []*biz.SSH, n int64, err error) *SSHRepo_List_Call { - _c.Call.Return(sSHs, n, err) - return _c -} - -func (_c *SSHRepo_List_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.SSH, int64, error)) *SSHRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// ListFiles provides a mock function for the type SSHRepo -func (_mock *SSHRepo) ListFiles(hostID uint, path string) ([]*biz.SSHFileInfo, error) { - ret := _mock.Called(hostID, path) - - if len(ret) == 0 { - panic("no return value specified for ListFiles") - } - - var r0 []*biz.SSHFileInfo - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint, string) ([]*biz.SSHFileInfo, error)); ok { - return returnFunc(hostID, path) - } - if returnFunc, ok := ret.Get(0).(func(uint, string) []*biz.SSHFileInfo); ok { - r0 = returnFunc(hostID, path) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.SSHFileInfo) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, string) error); ok { - r1 = returnFunc(hostID, path) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// SSHRepo_ListFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListFiles' -type SSHRepo_ListFiles_Call struct { - *mock.Call -} - -// ListFiles is a helper method to define mock.On call -// - hostID uint -// - path string -func (_e *SSHRepo_Expecter) ListFiles(hostID any, path any) *SSHRepo_ListFiles_Call { - return &SSHRepo_ListFiles_Call{Call: _e.mock.On("ListFiles", hostID, path)} -} - -func (_c *SSHRepo_ListFiles_Call) Run(run func(hostID uint, path string)) *SSHRepo_ListFiles_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *SSHRepo_ListFiles_Call) Return(sSHFileInfos []*biz.SSHFileInfo, err error) *SSHRepo_ListFiles_Call { - _c.Call.Return(sSHFileInfos, err) - return _c -} - -func (_c *SSHRepo_ListFiles_Call) RunAndReturn(run func(hostID uint, path string) ([]*biz.SSHFileInfo, error)) *SSHRepo_ListFiles_Call { - _c.Call.Return(run) - return _c -} - -// Mkdir provides a mock function for the type SSHRepo -func (_mock *SSHRepo) Mkdir(hostID uint, path string) error { - ret := _mock.Called(hostID, path) - - if len(ret) == 0 { - panic("no return value specified for Mkdir") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, string) error); ok { - r0 = returnFunc(hostID, path) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// SSHRepo_Mkdir_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Mkdir' -type SSHRepo_Mkdir_Call struct { - *mock.Call -} - -// Mkdir is a helper method to define mock.On call -// - hostID uint -// - path string -func (_e *SSHRepo_Expecter) Mkdir(hostID any, path any) *SSHRepo_Mkdir_Call { - return &SSHRepo_Mkdir_Call{Call: _e.mock.On("Mkdir", hostID, path)} -} - -func (_c *SSHRepo_Mkdir_Call) Run(run func(hostID uint, path string)) *SSHRepo_Mkdir_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *SSHRepo_Mkdir_Call) Return(err error) *SSHRepo_Mkdir_Call { - _c.Call.Return(err) - return _c -} - -func (_c *SSHRepo_Mkdir_Call) RunAndReturn(run func(hostID uint, path string) error) *SSHRepo_Mkdir_Call { - _c.Call.Return(run) - return _c -} - -// TransferFile provides a mock function for the type SSHRepo -func (_mock *SSHRepo) TransferFile(ctx context.Context, srcID uint, srcPath string, dstID uint, dstPath string, progress func(transferred int64, total int64)) error { - ret := _mock.Called(ctx, srcID, srcPath, dstID, dstPath, progress) - - if len(ret) == 0 { - panic("no return value specified for TransferFile") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(context.Context, uint, string, uint, string, func(transferred int64, total int64)) error); ok { - r0 = returnFunc(ctx, srcID, srcPath, dstID, dstPath, progress) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// SSHRepo_TransferFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TransferFile' -type SSHRepo_TransferFile_Call struct { - *mock.Call -} - -// TransferFile is a helper method to define mock.On call -// - ctx context.Context -// - srcID uint -// - srcPath string -// - dstID uint -// - dstPath string -// - progress func(transferred int64, total int64) -func (_e *SSHRepo_Expecter) TransferFile(ctx any, srcID any, srcPath any, dstID any, dstPath any, progress any) *SSHRepo_TransferFile_Call { - return &SSHRepo_TransferFile_Call{Call: _e.mock.On("TransferFile", ctx, srcID, srcPath, dstID, dstPath, progress)} -} - -func (_c *SSHRepo_TransferFile_Call) Run(run func(ctx context.Context, srcID uint, srcPath string, dstID uint, dstPath string, progress func(transferred int64, total int64))) *SSHRepo_TransferFile_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 uint - if args[3] != nil { - arg3 = args[3].(uint) - } - var arg4 string - if args[4] != nil { - arg4 = args[4].(string) - } - var arg5 func(transferred int64, total int64) - if args[5] != nil { - arg5 = args[5].(func(transferred int64, total int64)) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - ) - }) - return _c -} - -func (_c *SSHRepo_TransferFile_Call) Return(err error) *SSHRepo_TransferFile_Call { - _c.Call.Return(err) - return _c -} - -func (_c *SSHRepo_TransferFile_Call) RunAndReturn(run func(ctx context.Context, srcID uint, srcPath string, dstID uint, dstPath string, progress func(transferred int64, total int64)) error) *SSHRepo_TransferFile_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function for the type SSHRepo -func (_mock *SSHRepo) Update(req *request.SSHUpdate) error { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*request.SSHUpdate) error); ok { - r0 = returnFunc(req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// SSHRepo_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type SSHRepo_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - req *request.SSHUpdate -func (_e *SSHRepo_Expecter) Update(req any) *SSHRepo_Update_Call { - return &SSHRepo_Update_Call{Call: _e.mock.On("Update", req)} -} - -func (_c *SSHRepo_Update_Call) Run(run func(req *request.SSHUpdate)) *SSHRepo_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.SSHUpdate - if args[0] != nil { - arg0 = args[0].(*request.SSHUpdate) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *SSHRepo_Update_Call) Return(err error) *SSHRepo_Update_Call { - _c.Call.Return(err) - return _c -} - -func (_c *SSHRepo_Update_Call) RunAndReturn(run func(req *request.SSHUpdate) error) *SSHRepo_Update_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/SafeRepo.go b/mocks/biz/SafeRepo.go deleted file mode 100644 index 96d1cbca7..000000000 --- a/mocks/biz/SafeRepo.go +++ /dev/null @@ -1,202 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - mock "github.com/stretchr/testify/mock" -) - -// NewSafeRepo creates a new instance of SafeRepo. 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 NewSafeRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *SafeRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &SafeRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// SafeRepo is an autogenerated mock type for the SafeRepo type -type SafeRepo struct { - mock.Mock -} - -type SafeRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *SafeRepo) EXPECT() *SafeRepo_Expecter { - return &SafeRepo_Expecter{mock: &_m.Mock} -} - -// FirewallRunning provides a mock function for the type SafeRepo -func (_mock *SafeRepo) FirewallRunning() (bool, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for FirewallRunning") - } - - var r0 bool - var r1 error - if returnFunc, ok := ret.Get(0).(func() (bool, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() bool); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(bool) - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// SafeRepo_FirewallRunning_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FirewallRunning' -type SafeRepo_FirewallRunning_Call struct { - *mock.Call -} - -// FirewallRunning is a helper method to define mock.On call -func (_e *SafeRepo_Expecter) FirewallRunning() *SafeRepo_FirewallRunning_Call { - return &SafeRepo_FirewallRunning_Call{Call: _e.mock.On("FirewallRunning")} -} - -func (_c *SafeRepo_FirewallRunning_Call) Run(run func()) *SafeRepo_FirewallRunning_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *SafeRepo_FirewallRunning_Call) Return(b bool, err error) *SafeRepo_FirewallRunning_Call { - _c.Call.Return(b, err) - return _c -} - -func (_c *SafeRepo_FirewallRunning_Call) RunAndReturn(run func() (bool, error)) *SafeRepo_FirewallRunning_Call { - _c.Call.Return(run) - return _c -} - -// GetPingStatus provides a mock function for the type SafeRepo -func (_mock *SafeRepo) GetPingStatus() (bool, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for GetPingStatus") - } - - var r0 bool - var r1 error - if returnFunc, ok := ret.Get(0).(func() (bool, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() bool); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(bool) - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// SafeRepo_GetPingStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPingStatus' -type SafeRepo_GetPingStatus_Call struct { - *mock.Call -} - -// GetPingStatus is a helper method to define mock.On call -func (_e *SafeRepo_Expecter) GetPingStatus() *SafeRepo_GetPingStatus_Call { - return &SafeRepo_GetPingStatus_Call{Call: _e.mock.On("GetPingStatus")} -} - -func (_c *SafeRepo_GetPingStatus_Call) Run(run func()) *SafeRepo_GetPingStatus_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *SafeRepo_GetPingStatus_Call) Return(b bool, err error) *SafeRepo_GetPingStatus_Call { - _c.Call.Return(b, err) - return _c -} - -func (_c *SafeRepo_GetPingStatus_Call) RunAndReturn(run func() (bool, error)) *SafeRepo_GetPingStatus_Call { - _c.Call.Return(run) - return _c -} - -// SetPingStatus provides a mock function for the type SafeRepo -func (_mock *SafeRepo) SetPingStatus(status bool) error { - ret := _mock.Called(status) - - if len(ret) == 0 { - panic("no return value specified for SetPingStatus") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(bool) error); ok { - r0 = returnFunc(status) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// SafeRepo_SetPingStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPingStatus' -type SafeRepo_SetPingStatus_Call struct { - *mock.Call -} - -// SetPingStatus is a helper method to define mock.On call -// - status bool -func (_e *SafeRepo_Expecter) SetPingStatus(status any) *SafeRepo_SetPingStatus_Call { - return &SafeRepo_SetPingStatus_Call{Call: _e.mock.On("SetPingStatus", status)} -} - -func (_c *SafeRepo_SetPingStatus_Call) Run(run func(status bool)) *SafeRepo_SetPingStatus_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 bool - if args[0] != nil { - arg0 = args[0].(bool) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *SafeRepo_SetPingStatus_Call) Return(err error) *SafeRepo_SetPingStatus_Call { - _c.Call.Return(err) - return _c -} - -func (_c *SafeRepo_SetPingStatus_Call) RunAndReturn(run func(status bool) error) *SafeRepo_SetPingStatus_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/ScanEventRepo.go b/mocks/biz/ScanEventRepo.go deleted file mode 100644 index 956dc1aa3..000000000 --- a/mocks/biz/ScanEventRepo.go +++ /dev/null @@ -1,624 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewScanEventRepo creates a new instance of ScanEventRepo. 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 NewScanEventRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *ScanEventRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &ScanEventRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// ScanEventRepo is an autogenerated mock type for the ScanEventRepo type -type ScanEventRepo struct { - mock.Mock -} - -type ScanEventRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *ScanEventRepo) EXPECT() *ScanEventRepo_Expecter { - return &ScanEventRepo_Expecter{mock: &_m.Mock} -} - -// Clear provides a mock function for the type ScanEventRepo -func (_mock *ScanEventRepo) Clear() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for Clear") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ScanEventRepo_Clear_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Clear' -type ScanEventRepo_Clear_Call struct { - *mock.Call -} - -// Clear is a helper method to define mock.On call -func (_e *ScanEventRepo_Expecter) Clear() *ScanEventRepo_Clear_Call { - return &ScanEventRepo_Clear_Call{Call: _e.mock.On("Clear")} -} - -func (_c *ScanEventRepo_Clear_Call) Run(run func()) *ScanEventRepo_Clear_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *ScanEventRepo_Clear_Call) Return(err error) *ScanEventRepo_Clear_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ScanEventRepo_Clear_Call) RunAndReturn(run func() error) *ScanEventRepo_Clear_Call { - _c.Call.Return(run) - return _c -} - -// ClearBefore provides a mock function for the type ScanEventRepo -func (_mock *ScanEventRepo) ClearBefore(date string) error { - ret := _mock.Called(date) - - if len(ret) == 0 { - panic("no return value specified for ClearBefore") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(date) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ScanEventRepo_ClearBefore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearBefore' -type ScanEventRepo_ClearBefore_Call struct { - *mock.Call -} - -// ClearBefore is a helper method to define mock.On call -// - date string -func (_e *ScanEventRepo_Expecter) ClearBefore(date any) *ScanEventRepo_ClearBefore_Call { - return &ScanEventRepo_ClearBefore_Call{Call: _e.mock.On("ClearBefore", date)} -} - -func (_c *ScanEventRepo_ClearBefore_Call) Run(run func(date string)) *ScanEventRepo_ClearBefore_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ScanEventRepo_ClearBefore_Call) Return(err error) *ScanEventRepo_ClearBefore_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ScanEventRepo_ClearBefore_Call) RunAndReturn(run func(date string) error) *ScanEventRepo_ClearBefore_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type ScanEventRepo -func (_mock *ScanEventRepo) List(start string, end string, sourceIP string, port uint, location string, page uint, limit uint) ([]*biz.ScanEvent, uint, error) { - ret := _mock.Called(start, end, sourceIP, port, location, page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.ScanEvent - var r1 uint - var r2 error - if returnFunc, ok := ret.Get(0).(func(string, string, string, uint, string, uint, uint) ([]*biz.ScanEvent, uint, error)); ok { - return returnFunc(start, end, sourceIP, port, location, page, limit) - } - if returnFunc, ok := ret.Get(0).(func(string, string, string, uint, string, uint, uint) []*biz.ScanEvent); ok { - r0 = returnFunc(start, end, sourceIP, port, location, page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.ScanEvent) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, string, uint, string, uint, uint) uint); ok { - r1 = returnFunc(start, end, sourceIP, port, location, page, limit) - } else { - r1 = ret.Get(1).(uint) - } - if returnFunc, ok := ret.Get(2).(func(string, string, string, uint, string, uint, uint) error); ok { - r2 = returnFunc(start, end, sourceIP, port, location, page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// ScanEventRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type ScanEventRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - start string -// - end string -// - sourceIP string -// - port uint -// - location string -// - page uint -// - limit uint -func (_e *ScanEventRepo_Expecter) List(start any, end any, sourceIP any, port any, location any, page any, limit any) *ScanEventRepo_List_Call { - return &ScanEventRepo_List_Call{Call: _e.mock.On("List", start, end, sourceIP, port, location, page, limit)} -} - -func (_c *ScanEventRepo_List_Call) Run(run func(start string, end string, sourceIP string, port uint, location string, page uint, limit uint)) *ScanEventRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 uint - if args[3] != nil { - arg3 = args[3].(uint) - } - var arg4 string - if args[4] != nil { - arg4 = args[4].(string) - } - var arg5 uint - if args[5] != nil { - arg5 = args[5].(uint) - } - var arg6 uint - if args[6] != nil { - arg6 = args[6].(uint) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - ) - }) - return _c -} - -func (_c *ScanEventRepo_List_Call) Return(scanEvents []*biz.ScanEvent, v uint, err error) *ScanEventRepo_List_Call { - _c.Call.Return(scanEvents, v, err) - return _c -} - -func (_c *ScanEventRepo_List_Call) RunAndReturn(run func(start string, end string, sourceIP string, port uint, location string, page uint, limit uint) ([]*biz.ScanEvent, uint, error)) *ScanEventRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// Summary provides a mock function for the type ScanEventRepo -func (_mock *ScanEventRepo) Summary(start string, end string) (*biz.ScanSummary, error) { - ret := _mock.Called(start, end) - - if len(ret) == 0 { - panic("no return value specified for Summary") - } - - var r0 *biz.ScanSummary - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string) (*biz.ScanSummary, error)); ok { - return returnFunc(start, end) - } - if returnFunc, ok := ret.Get(0).(func(string, string) *biz.ScanSummary); ok { - r0 = returnFunc(start, end) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.ScanSummary) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string) error); ok { - r1 = returnFunc(start, end) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ScanEventRepo_Summary_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Summary' -type ScanEventRepo_Summary_Call struct { - *mock.Call -} - -// Summary is a helper method to define mock.On call -// - start string -// - end string -func (_e *ScanEventRepo_Expecter) Summary(start any, end any) *ScanEventRepo_Summary_Call { - return &ScanEventRepo_Summary_Call{Call: _e.mock.On("Summary", start, end)} -} - -func (_c *ScanEventRepo_Summary_Call) Run(run func(start string, end string)) *ScanEventRepo_Summary_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ScanEventRepo_Summary_Call) Return(scanSummary *biz.ScanSummary, err error) *ScanEventRepo_Summary_Call { - _c.Call.Return(scanSummary, err) - return _c -} - -func (_c *ScanEventRepo_Summary_Call) RunAndReturn(run func(start string, end string) (*biz.ScanSummary, error)) *ScanEventRepo_Summary_Call { - _c.Call.Return(run) - return _c -} - -// TopPorts provides a mock function for the type ScanEventRepo -func (_mock *ScanEventRepo) TopPorts(start string, end string, limit uint) ([]*biz.ScanPortRank, error) { - ret := _mock.Called(start, end, limit) - - if len(ret) == 0 { - panic("no return value specified for TopPorts") - } - - var r0 []*biz.ScanPortRank - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, uint) ([]*biz.ScanPortRank, error)); ok { - return returnFunc(start, end, limit) - } - if returnFunc, ok := ret.Get(0).(func(string, string, uint) []*biz.ScanPortRank); ok { - r0 = returnFunc(start, end, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.ScanPortRank) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, uint) error); ok { - r1 = returnFunc(start, end, limit) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ScanEventRepo_TopPorts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TopPorts' -type ScanEventRepo_TopPorts_Call struct { - *mock.Call -} - -// TopPorts is a helper method to define mock.On call -// - start string -// - end string -// - limit uint -func (_e *ScanEventRepo_Expecter) TopPorts(start any, end any, limit any) *ScanEventRepo_TopPorts_Call { - return &ScanEventRepo_TopPorts_Call{Call: _e.mock.On("TopPorts", start, end, limit)} -} - -func (_c *ScanEventRepo_TopPorts_Call) Run(run func(start string, end string, limit uint)) *ScanEventRepo_TopPorts_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 uint - if args[2] != nil { - arg2 = args[2].(uint) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *ScanEventRepo_TopPorts_Call) Return(scanPortRanks []*biz.ScanPortRank, err error) *ScanEventRepo_TopPorts_Call { - _c.Call.Return(scanPortRanks, err) - return _c -} - -func (_c *ScanEventRepo_TopPorts_Call) RunAndReturn(run func(start string, end string, limit uint) ([]*biz.ScanPortRank, error)) *ScanEventRepo_TopPorts_Call { - _c.Call.Return(run) - return _c -} - -// TopSourceIPs provides a mock function for the type ScanEventRepo -func (_mock *ScanEventRepo) TopSourceIPs(start string, end string, limit uint) ([]*biz.ScanSourceRank, error) { - ret := _mock.Called(start, end, limit) - - if len(ret) == 0 { - panic("no return value specified for TopSourceIPs") - } - - var r0 []*biz.ScanSourceRank - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, uint) ([]*biz.ScanSourceRank, error)); ok { - return returnFunc(start, end, limit) - } - if returnFunc, ok := ret.Get(0).(func(string, string, uint) []*biz.ScanSourceRank); ok { - r0 = returnFunc(start, end, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.ScanSourceRank) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, uint) error); ok { - r1 = returnFunc(start, end, limit) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ScanEventRepo_TopSourceIPs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TopSourceIPs' -type ScanEventRepo_TopSourceIPs_Call struct { - *mock.Call -} - -// TopSourceIPs is a helper method to define mock.On call -// - start string -// - end string -// - limit uint -func (_e *ScanEventRepo_Expecter) TopSourceIPs(start any, end any, limit any) *ScanEventRepo_TopSourceIPs_Call { - return &ScanEventRepo_TopSourceIPs_Call{Call: _e.mock.On("TopSourceIPs", start, end, limit)} -} - -func (_c *ScanEventRepo_TopSourceIPs_Call) Run(run func(start string, end string, limit uint)) *ScanEventRepo_TopSourceIPs_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 uint - if args[2] != nil { - arg2 = args[2].(uint) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *ScanEventRepo_TopSourceIPs_Call) Return(scanSourceRanks []*biz.ScanSourceRank, err error) *ScanEventRepo_TopSourceIPs_Call { - _c.Call.Return(scanSourceRanks, err) - return _c -} - -func (_c *ScanEventRepo_TopSourceIPs_Call) RunAndReturn(run func(start string, end string, limit uint) ([]*biz.ScanSourceRank, error)) *ScanEventRepo_TopSourceIPs_Call { - _c.Call.Return(run) - return _c -} - -// Trend provides a mock function for the type ScanEventRepo -func (_mock *ScanEventRepo) Trend(start string, end string) ([]*biz.ScanDayTrend, error) { - ret := _mock.Called(start, end) - - if len(ret) == 0 { - panic("no return value specified for Trend") - } - - var r0 []*biz.ScanDayTrend - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string) ([]*biz.ScanDayTrend, error)); ok { - return returnFunc(start, end) - } - if returnFunc, ok := ret.Get(0).(func(string, string) []*biz.ScanDayTrend); ok { - r0 = returnFunc(start, end) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.ScanDayTrend) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string) error); ok { - r1 = returnFunc(start, end) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// ScanEventRepo_Trend_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Trend' -type ScanEventRepo_Trend_Call struct { - *mock.Call -} - -// Trend is a helper method to define mock.On call -// - start string -// - end string -func (_e *ScanEventRepo_Expecter) Trend(start any, end any) *ScanEventRepo_Trend_Call { - return &ScanEventRepo_Trend_Call{Call: _e.mock.On("Trend", start, end)} -} - -func (_c *ScanEventRepo_Trend_Call) Run(run func(start string, end string)) *ScanEventRepo_Trend_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *ScanEventRepo_Trend_Call) Return(scanDayTrends []*biz.ScanDayTrend, err error) *ScanEventRepo_Trend_Call { - _c.Call.Return(scanDayTrends, err) - return _c -} - -func (_c *ScanEventRepo_Trend_Call) RunAndReturn(run func(start string, end string) ([]*biz.ScanDayTrend, error)) *ScanEventRepo_Trend_Call { - _c.Call.Return(run) - return _c -} - -// Upsert provides a mock function for the type ScanEventRepo -func (_mock *ScanEventRepo) Upsert(events []*biz.ScanEvent) error { - ret := _mock.Called(events) - - if len(ret) == 0 { - panic("no return value specified for Upsert") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func([]*biz.ScanEvent) error); ok { - r0 = returnFunc(events) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ScanEventRepo_Upsert_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Upsert' -type ScanEventRepo_Upsert_Call struct { - *mock.Call -} - -// Upsert is a helper method to define mock.On call -// - events []*biz.ScanEvent -func (_e *ScanEventRepo_Expecter) Upsert(events any) *ScanEventRepo_Upsert_Call { - return &ScanEventRepo_Upsert_Call{Call: _e.mock.On("Upsert", events)} -} - -func (_c *ScanEventRepo_Upsert_Call) Run(run func(events []*biz.ScanEvent)) *ScanEventRepo_Upsert_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []*biz.ScanEvent - if args[0] != nil { - arg0 = args[0].([]*biz.ScanEvent) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *ScanEventRepo_Upsert_Call) Return(err error) *ScanEventRepo_Upsert_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ScanEventRepo_Upsert_Call) RunAndReturn(run func(events []*biz.ScanEvent) error) *ScanEventRepo_Upsert_Call { - _c.Call.Return(run) - return _c -} - -// VacuumDB provides a mock function for the type ScanEventRepo -func (_mock *ScanEventRepo) VacuumDB() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for VacuumDB") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// ScanEventRepo_VacuumDB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VacuumDB' -type ScanEventRepo_VacuumDB_Call struct { - *mock.Call -} - -// VacuumDB is a helper method to define mock.On call -func (_e *ScanEventRepo_Expecter) VacuumDB() *ScanEventRepo_VacuumDB_Call { - return &ScanEventRepo_VacuumDB_Call{Call: _e.mock.On("VacuumDB")} -} - -func (_c *ScanEventRepo_VacuumDB_Call) Run(run func()) *ScanEventRepo_VacuumDB_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *ScanEventRepo_VacuumDB_Call) Return(err error) *ScanEventRepo_VacuumDB_Call { - _c.Call.Return(err) - return _c -} - -func (_c *ScanEventRepo_VacuumDB_Call) RunAndReturn(run func() error) *ScanEventRepo_VacuumDB_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/SettingRepo.go b/mocks/biz/SettingRepo.go deleted file mode 100644 index 438fdbb80..000000000 --- a/mocks/biz/SettingRepo.go +++ /dev/null @@ -1,569 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/internal/request" - mock "github.com/stretchr/testify/mock" -) - -// NewSettingRepo creates a new instance of SettingRepo. 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 NewSettingRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *SettingRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &SettingRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// SettingRepo is an autogenerated mock type for the SettingRepo type -type SettingRepo struct { - mock.Mock -} - -type SettingRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *SettingRepo) EXPECT() *SettingRepo_Expecter { - return &SettingRepo_Expecter{mock: &_m.Mock} -} - -// Delete provides a mock function for the type SettingRepo -func (_mock *SettingRepo) Delete(key biz.SettingKey) error { - ret := _mock.Called(key) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(biz.SettingKey) error); ok { - r0 = returnFunc(key) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// SettingRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type SettingRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - key biz.SettingKey -func (_e *SettingRepo_Expecter) Delete(key any) *SettingRepo_Delete_Call { - return &SettingRepo_Delete_Call{Call: _e.mock.On("Delete", key)} -} - -func (_c *SettingRepo_Delete_Call) Run(run func(key biz.SettingKey)) *SettingRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.SettingKey - if args[0] != nil { - arg0 = args[0].(biz.SettingKey) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *SettingRepo_Delete_Call) Return(err error) *SettingRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *SettingRepo_Delete_Call) RunAndReturn(run func(key biz.SettingKey) error) *SettingRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type SettingRepo -func (_mock *SettingRepo) Get(key biz.SettingKey, defaultValue ...string) (string, error) { - var tmpRet mock.Arguments - if len(defaultValue) > 0 { - tmpRet = _mock.Called(key, defaultValue) - } else { - tmpRet = _mock.Called(key) - } - ret := tmpRet - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(biz.SettingKey, ...string) (string, error)); ok { - return returnFunc(key, defaultValue...) - } - if returnFunc, ok := ret.Get(0).(func(biz.SettingKey, ...string) string); ok { - r0 = returnFunc(key, defaultValue...) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(biz.SettingKey, ...string) error); ok { - r1 = returnFunc(key, defaultValue...) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// SettingRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type SettingRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - key biz.SettingKey -// - defaultValue ...string -func (_e *SettingRepo_Expecter) Get(key any, defaultValue ...any) *SettingRepo_Get_Call { - return &SettingRepo_Get_Call{Call: _e.mock.On("Get", - append([]any{key}, defaultValue...)...)} -} - -func (_c *SettingRepo_Get_Call) Run(run func(key biz.SettingKey, defaultValue ...string)) *SettingRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.SettingKey - if args[0] != nil { - arg0 = args[0].(biz.SettingKey) - } - var arg1 []string - var variadicArgs []string - if len(args) > 1 { - variadicArgs = args[1].([]string) - } - arg1 = variadicArgs - run( - arg0, - arg1..., - ) - }) - return _c -} - -func (_c *SettingRepo_Get_Call) Return(s string, err error) *SettingRepo_Get_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *SettingRepo_Get_Call) RunAndReturn(run func(key biz.SettingKey, defaultValue ...string) (string, error)) *SettingRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// GetBool provides a mock function for the type SettingRepo -func (_mock *SettingRepo) GetBool(key biz.SettingKey, defaultValue ...bool) (bool, error) { - var tmpRet mock.Arguments - if len(defaultValue) > 0 { - tmpRet = _mock.Called(key, defaultValue) - } else { - tmpRet = _mock.Called(key) - } - ret := tmpRet - - if len(ret) == 0 { - panic("no return value specified for GetBool") - } - - var r0 bool - var r1 error - if returnFunc, ok := ret.Get(0).(func(biz.SettingKey, ...bool) (bool, error)); ok { - return returnFunc(key, defaultValue...) - } - if returnFunc, ok := ret.Get(0).(func(biz.SettingKey, ...bool) bool); ok { - r0 = returnFunc(key, defaultValue...) - } else { - r0 = ret.Get(0).(bool) - } - if returnFunc, ok := ret.Get(1).(func(biz.SettingKey, ...bool) error); ok { - r1 = returnFunc(key, defaultValue...) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// SettingRepo_GetBool_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBool' -type SettingRepo_GetBool_Call struct { - *mock.Call -} - -// GetBool is a helper method to define mock.On call -// - key biz.SettingKey -// - defaultValue ...bool -func (_e *SettingRepo_Expecter) GetBool(key any, defaultValue ...any) *SettingRepo_GetBool_Call { - return &SettingRepo_GetBool_Call{Call: _e.mock.On("GetBool", - append([]any{key}, defaultValue...)...)} -} - -func (_c *SettingRepo_GetBool_Call) Run(run func(key biz.SettingKey, defaultValue ...bool)) *SettingRepo_GetBool_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.SettingKey - if args[0] != nil { - arg0 = args[0].(biz.SettingKey) - } - var arg1 []bool - var variadicArgs []bool - if len(args) > 1 { - variadicArgs = args[1].([]bool) - } - arg1 = variadicArgs - run( - arg0, - arg1..., - ) - }) - return _c -} - -func (_c *SettingRepo_GetBool_Call) Return(b bool, err error) *SettingRepo_GetBool_Call { - _c.Call.Return(b, err) - return _c -} - -func (_c *SettingRepo_GetBool_Call) RunAndReturn(run func(key biz.SettingKey, defaultValue ...bool) (bool, error)) *SettingRepo_GetBool_Call { - _c.Call.Return(run) - return _c -} - -// GetInt provides a mock function for the type SettingRepo -func (_mock *SettingRepo) GetInt(key biz.SettingKey, defaultValue ...int) (int, error) { - var tmpRet mock.Arguments - if len(defaultValue) > 0 { - tmpRet = _mock.Called(key, defaultValue) - } else { - tmpRet = _mock.Called(key) - } - ret := tmpRet - - if len(ret) == 0 { - panic("no return value specified for GetInt") - } - - var r0 int - var r1 error - if returnFunc, ok := ret.Get(0).(func(biz.SettingKey, ...int) (int, error)); ok { - return returnFunc(key, defaultValue...) - } - if returnFunc, ok := ret.Get(0).(func(biz.SettingKey, ...int) int); ok { - r0 = returnFunc(key, defaultValue...) - } else { - r0 = ret.Get(0).(int) - } - if returnFunc, ok := ret.Get(1).(func(biz.SettingKey, ...int) error); ok { - r1 = returnFunc(key, defaultValue...) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// SettingRepo_GetInt_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetInt' -type SettingRepo_GetInt_Call struct { - *mock.Call -} - -// GetInt is a helper method to define mock.On call -// - key biz.SettingKey -// - defaultValue ...int -func (_e *SettingRepo_Expecter) GetInt(key any, defaultValue ...any) *SettingRepo_GetInt_Call { - return &SettingRepo_GetInt_Call{Call: _e.mock.On("GetInt", - append([]any{key}, defaultValue...)...)} -} - -func (_c *SettingRepo_GetInt_Call) Run(run func(key biz.SettingKey, defaultValue ...int)) *SettingRepo_GetInt_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.SettingKey - if args[0] != nil { - arg0 = args[0].(biz.SettingKey) - } - var arg1 []int - var variadicArgs []int - if len(args) > 1 { - variadicArgs = args[1].([]int) - } - arg1 = variadicArgs - run( - arg0, - arg1..., - ) - }) - return _c -} - -func (_c *SettingRepo_GetInt_Call) Return(n int, err error) *SettingRepo_GetInt_Call { - _c.Call.Return(n, err) - return _c -} - -func (_c *SettingRepo_GetInt_Call) RunAndReturn(run func(key biz.SettingKey, defaultValue ...int) (int, error)) *SettingRepo_GetInt_Call { - _c.Call.Return(run) - return _c -} - -// GetPanel provides a mock function for the type SettingRepo -func (_mock *SettingRepo) GetPanel() (*request.SettingPanel, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for GetPanel") - } - - var r0 *request.SettingPanel - var r1 error - if returnFunc, ok := ret.Get(0).(func() (*request.SettingPanel, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() *request.SettingPanel); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*request.SettingPanel) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// SettingRepo_GetPanel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPanel' -type SettingRepo_GetPanel_Call struct { - *mock.Call -} - -// GetPanel is a helper method to define mock.On call -func (_e *SettingRepo_Expecter) GetPanel() *SettingRepo_GetPanel_Call { - return &SettingRepo_GetPanel_Call{Call: _e.mock.On("GetPanel")} -} - -func (_c *SettingRepo_GetPanel_Call) Run(run func()) *SettingRepo_GetPanel_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *SettingRepo_GetPanel_Call) Return(settingPanel *request.SettingPanel, err error) *SettingRepo_GetPanel_Call { - _c.Call.Return(settingPanel, err) - return _c -} - -func (_c *SettingRepo_GetPanel_Call) RunAndReturn(run func() (*request.SettingPanel, error)) *SettingRepo_GetPanel_Call { - _c.Call.Return(run) - return _c -} - -// GetSlice provides a mock function for the type SettingRepo -func (_mock *SettingRepo) GetSlice(key biz.SettingKey, defaultValue ...[]string) ([]string, error) { - var tmpRet mock.Arguments - if len(defaultValue) > 0 { - tmpRet = _mock.Called(key, defaultValue) - } else { - tmpRet = _mock.Called(key) - } - ret := tmpRet - - if len(ret) == 0 { - panic("no return value specified for GetSlice") - } - - var r0 []string - var r1 error - if returnFunc, ok := ret.Get(0).(func(biz.SettingKey, ...[]string) ([]string, error)); ok { - return returnFunc(key, defaultValue...) - } - if returnFunc, ok := ret.Get(0).(func(biz.SettingKey, ...[]string) []string); ok { - r0 = returnFunc(key, defaultValue...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]string) - } - } - if returnFunc, ok := ret.Get(1).(func(biz.SettingKey, ...[]string) error); ok { - r1 = returnFunc(key, defaultValue...) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// SettingRepo_GetSlice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSlice' -type SettingRepo_GetSlice_Call struct { - *mock.Call -} - -// GetSlice is a helper method to define mock.On call -// - key biz.SettingKey -// - defaultValue ...[]string -func (_e *SettingRepo_Expecter) GetSlice(key any, defaultValue ...any) *SettingRepo_GetSlice_Call { - return &SettingRepo_GetSlice_Call{Call: _e.mock.On("GetSlice", - append([]any{key}, defaultValue...)...)} -} - -func (_c *SettingRepo_GetSlice_Call) Run(run func(key biz.SettingKey, defaultValue ...[]string)) *SettingRepo_GetSlice_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.SettingKey - if args[0] != nil { - arg0 = args[0].(biz.SettingKey) - } - var arg1 [][]string - var variadicArgs [][]string - if len(args) > 1 { - variadicArgs = args[1].([][]string) - } - arg1 = variadicArgs - run( - arg0, - arg1..., - ) - }) - return _c -} - -func (_c *SettingRepo_GetSlice_Call) Return(strings []string, err error) *SettingRepo_GetSlice_Call { - _c.Call.Return(strings, err) - return _c -} - -func (_c *SettingRepo_GetSlice_Call) RunAndReturn(run func(key biz.SettingKey, defaultValue ...[]string) ([]string, error)) *SettingRepo_GetSlice_Call { - _c.Call.Return(run) - return _c -} - -// Set provides a mock function for the type SettingRepo -func (_mock *SettingRepo) Set(key biz.SettingKey, value string) error { - ret := _mock.Called(key, value) - - if len(ret) == 0 { - panic("no return value specified for Set") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(biz.SettingKey, string) error); ok { - r0 = returnFunc(key, value) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// SettingRepo_Set_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Set' -type SettingRepo_Set_Call struct { - *mock.Call -} - -// Set is a helper method to define mock.On call -// - key biz.SettingKey -// - value string -func (_e *SettingRepo_Expecter) Set(key any, value any) *SettingRepo_Set_Call { - return &SettingRepo_Set_Call{Call: _e.mock.On("Set", key, value)} -} - -func (_c *SettingRepo_Set_Call) Run(run func(key biz.SettingKey, value string)) *SettingRepo_Set_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.SettingKey - if args[0] != nil { - arg0 = args[0].(biz.SettingKey) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *SettingRepo_Set_Call) Return(err error) *SettingRepo_Set_Call { - _c.Call.Return(err) - return _c -} - -func (_c *SettingRepo_Set_Call) RunAndReturn(run func(key biz.SettingKey, value string) error) *SettingRepo_Set_Call { - _c.Call.Return(run) - return _c -} - -// SetSlice provides a mock function for the type SettingRepo -func (_mock *SettingRepo) SetSlice(key biz.SettingKey, value []string) error { - ret := _mock.Called(key, value) - - if len(ret) == 0 { - panic("no return value specified for SetSlice") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(biz.SettingKey, []string) error); ok { - r0 = returnFunc(key, value) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// SettingRepo_SetSlice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetSlice' -type SettingRepo_SetSlice_Call struct { - *mock.Call -} - -// SetSlice is a helper method to define mock.On call -// - key biz.SettingKey -// - value []string -func (_e *SettingRepo_Expecter) SetSlice(key any, value any) *SettingRepo_SetSlice_Call { - return &SettingRepo_SetSlice_Call{Call: _e.mock.On("SetSlice", key, value)} -} - -func (_c *SettingRepo_SetSlice_Call) Run(run func(key biz.SettingKey, value []string)) *SettingRepo_SetSlice_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 biz.SettingKey - if args[0] != nil { - arg0 = args[0].(biz.SettingKey) - } - var arg1 []string - if args[1] != nil { - arg1 = args[1].([]string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *SettingRepo_SetSlice_Call) Return(err error) *SettingRepo_SetSlice_Call { - _c.Call.Return(err) - return _c -} - -func (_c *SettingRepo_SetSlice_Call) RunAndReturn(run func(key biz.SettingKey, value []string) error) *SettingRepo_SetSlice_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/TamperRepo.go b/mocks/biz/TamperRepo.go deleted file mode 100644 index 53acf954a..000000000 --- a/mocks/biz/TamperRepo.go +++ /dev/null @@ -1,644 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "time" - - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewTamperRepo creates a new instance of TamperRepo. 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 NewTamperRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *TamperRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &TamperRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// TamperRepo is an autogenerated mock type for the TamperRepo type -type TamperRepo struct { - mock.Mock -} - -type TamperRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *TamperRepo) EXPECT() *TamperRepo_Expecter { - return &TamperRepo_Expecter{mock: &_m.Mock} -} - -// AddLogs provides a mock function for the type TamperRepo -func (_mock *TamperRepo) AddLogs(logs []*biz.TamperLog) error { - ret := _mock.Called(logs) - - if len(ret) == 0 { - panic("no return value specified for AddLogs") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func([]*biz.TamperLog) error); ok { - r0 = returnFunc(logs) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TamperRepo_AddLogs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddLogs' -type TamperRepo_AddLogs_Call struct { - *mock.Call -} - -// AddLogs is a helper method to define mock.On call -// - logs []*biz.TamperLog -func (_e *TamperRepo_Expecter) AddLogs(logs any) *TamperRepo_AddLogs_Call { - return &TamperRepo_AddLogs_Call{Call: _e.mock.On("AddLogs", logs)} -} - -func (_c *TamperRepo_AddLogs_Call) Run(run func(logs []*biz.TamperLog)) *TamperRepo_AddLogs_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []*biz.TamperLog - if args[0] != nil { - arg0 = args[0].([]*biz.TamperLog) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TamperRepo_AddLogs_Call) Return(err error) *TamperRepo_AddLogs_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TamperRepo_AddLogs_Call) RunAndReturn(run func(logs []*biz.TamperLog) error) *TamperRepo_AddLogs_Call { - _c.Call.Return(run) - return _c -} - -// ClearLogs provides a mock function for the type TamperRepo -func (_mock *TamperRepo) ClearLogs() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for ClearLogs") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TamperRepo_ClearLogs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearLogs' -type TamperRepo_ClearLogs_Call struct { - *mock.Call -} - -// ClearLogs is a helper method to define mock.On call -func (_e *TamperRepo_Expecter) ClearLogs() *TamperRepo_ClearLogs_Call { - return &TamperRepo_ClearLogs_Call{Call: _e.mock.On("ClearLogs")} -} - -func (_c *TamperRepo_ClearLogs_Call) Run(run func()) *TamperRepo_ClearLogs_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *TamperRepo_ClearLogs_Call) Return(err error) *TamperRepo_ClearLogs_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TamperRepo_ClearLogs_Call) RunAndReturn(run func() error) *TamperRepo_ClearLogs_Call { - _c.Call.Return(run) - return _c -} - -// ClearLogsBefore provides a mock function for the type TamperRepo -func (_mock *TamperRepo) ClearLogsBefore(t time.Time) error { - ret := _mock.Called(t) - - if len(ret) == 0 { - panic("no return value specified for ClearLogsBefore") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(time.Time) error); ok { - r0 = returnFunc(t) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TamperRepo_ClearLogsBefore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearLogsBefore' -type TamperRepo_ClearLogsBefore_Call struct { - *mock.Call -} - -// ClearLogsBefore is a helper method to define mock.On call -// - t time.Time -func (_e *TamperRepo_Expecter) ClearLogsBefore(t any) *TamperRepo_ClearLogsBefore_Call { - return &TamperRepo_ClearLogsBefore_Call{Call: _e.mock.On("ClearLogsBefore", t)} -} - -func (_c *TamperRepo_ClearLogsBefore_Call) Run(run func(t time.Time)) *TamperRepo_ClearLogsBefore_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 time.Time - if args[0] != nil { - arg0 = args[0].(time.Time) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TamperRepo_ClearLogsBefore_Call) Return(err error) *TamperRepo_ClearLogsBefore_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TamperRepo_ClearLogsBefore_Call) RunAndReturn(run func(t time.Time) error) *TamperRepo_ClearLogsBefore_Call { - _c.Call.Return(run) - return _c -} - -// CreateRule provides a mock function for the type TamperRepo -func (_mock *TamperRepo) CreateRule(rule *biz.TamperRule) error { - ret := _mock.Called(rule) - - if len(ret) == 0 { - panic("no return value specified for CreateRule") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.TamperRule) error); ok { - r0 = returnFunc(rule) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TamperRepo_CreateRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateRule' -type TamperRepo_CreateRule_Call struct { - *mock.Call -} - -// CreateRule is a helper method to define mock.On call -// - rule *biz.TamperRule -func (_e *TamperRepo_Expecter) CreateRule(rule any) *TamperRepo_CreateRule_Call { - return &TamperRepo_CreateRule_Call{Call: _e.mock.On("CreateRule", rule)} -} - -func (_c *TamperRepo_CreateRule_Call) Run(run func(rule *biz.TamperRule)) *TamperRepo_CreateRule_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.TamperRule - if args[0] != nil { - arg0 = args[0].(*biz.TamperRule) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TamperRepo_CreateRule_Call) Return(err error) *TamperRepo_CreateRule_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TamperRepo_CreateRule_Call) RunAndReturn(run func(rule *biz.TamperRule) error) *TamperRepo_CreateRule_Call { - _c.Call.Return(run) - return _c -} - -// DeleteRule provides a mock function for the type TamperRepo -func (_mock *TamperRepo) DeleteRule(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for DeleteRule") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TamperRepo_DeleteRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteRule' -type TamperRepo_DeleteRule_Call struct { - *mock.Call -} - -// DeleteRule is a helper method to define mock.On call -// - id uint -func (_e *TamperRepo_Expecter) DeleteRule(id any) *TamperRepo_DeleteRule_Call { - return &TamperRepo_DeleteRule_Call{Call: _e.mock.On("DeleteRule", id)} -} - -func (_c *TamperRepo_DeleteRule_Call) Run(run func(id uint)) *TamperRepo_DeleteRule_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TamperRepo_DeleteRule_Call) Return(err error) *TamperRepo_DeleteRule_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TamperRepo_DeleteRule_Call) RunAndReturn(run func(id uint) error) *TamperRepo_DeleteRule_Call { - _c.Call.Return(run) - return _c -} - -// GetRule provides a mock function for the type TamperRepo -func (_mock *TamperRepo) GetRule(id uint) (*biz.TamperRule, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for GetRule") - } - - var r0 *biz.TamperRule - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.TamperRule, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.TamperRule); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.TamperRule) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// TamperRepo_GetRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRule' -type TamperRepo_GetRule_Call struct { - *mock.Call -} - -// GetRule is a helper method to define mock.On call -// - id uint -func (_e *TamperRepo_Expecter) GetRule(id any) *TamperRepo_GetRule_Call { - return &TamperRepo_GetRule_Call{Call: _e.mock.On("GetRule", id)} -} - -func (_c *TamperRepo_GetRule_Call) Run(run func(id uint)) *TamperRepo_GetRule_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TamperRepo_GetRule_Call) Return(tamperRule *biz.TamperRule, err error) *TamperRepo_GetRule_Call { - _c.Call.Return(tamperRule, err) - return _c -} - -func (_c *TamperRepo_GetRule_Call) RunAndReturn(run func(id uint) (*biz.TamperRule, error)) *TamperRepo_GetRule_Call { - _c.Call.Return(run) - return _c -} - -// GetRuleByName provides a mock function for the type TamperRepo -func (_mock *TamperRepo) GetRuleByName(name string) (*biz.TamperRule, error) { - ret := _mock.Called(name) - - if len(ret) == 0 { - panic("no return value specified for GetRuleByName") - } - - var r0 *biz.TamperRule - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) (*biz.TamperRule, error)); ok { - return returnFunc(name) - } - if returnFunc, ok := ret.Get(0).(func(string) *biz.TamperRule); ok { - r0 = returnFunc(name) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.TamperRule) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(name) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// TamperRepo_GetRuleByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRuleByName' -type TamperRepo_GetRuleByName_Call struct { - *mock.Call -} - -// GetRuleByName is a helper method to define mock.On call -// - name string -func (_e *TamperRepo_Expecter) GetRuleByName(name any) *TamperRepo_GetRuleByName_Call { - return &TamperRepo_GetRuleByName_Call{Call: _e.mock.On("GetRuleByName", name)} -} - -func (_c *TamperRepo_GetRuleByName_Call) Run(run func(name string)) *TamperRepo_GetRuleByName_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TamperRepo_GetRuleByName_Call) Return(tamperRule *biz.TamperRule, err error) *TamperRepo_GetRuleByName_Call { - _c.Call.Return(tamperRule, err) - return _c -} - -func (_c *TamperRepo_GetRuleByName_Call) RunAndReturn(run func(name string) (*biz.TamperRule, error)) *TamperRepo_GetRuleByName_Call { - _c.Call.Return(run) - return _c -} - -// ListLogs provides a mock function for the type TamperRepo -func (_mock *TamperRepo) ListLogs(page uint, limit uint) ([]*biz.TamperLog, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for ListLogs") - } - - var r0 []*biz.TamperLog - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.TamperLog, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.TamperLog); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.TamperLog) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// TamperRepo_ListLogs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListLogs' -type TamperRepo_ListLogs_Call struct { - *mock.Call -} - -// ListLogs is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *TamperRepo_Expecter) ListLogs(page any, limit any) *TamperRepo_ListLogs_Call { - return &TamperRepo_ListLogs_Call{Call: _e.mock.On("ListLogs", page, limit)} -} - -func (_c *TamperRepo_ListLogs_Call) Run(run func(page uint, limit uint)) *TamperRepo_ListLogs_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *TamperRepo_ListLogs_Call) Return(tamperLogs []*biz.TamperLog, n int64, err error) *TamperRepo_ListLogs_Call { - _c.Call.Return(tamperLogs, n, err) - return _c -} - -func (_c *TamperRepo_ListLogs_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.TamperLog, int64, error)) *TamperRepo_ListLogs_Call { - _c.Call.Return(run) - return _c -} - -// ListRules provides a mock function for the type TamperRepo -func (_mock *TamperRepo) ListRules() ([]*biz.TamperRule, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for ListRules") - } - - var r0 []*biz.TamperRule - var r1 error - if returnFunc, ok := ret.Get(0).(func() ([]*biz.TamperRule, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() []*biz.TamperRule); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.TamperRule) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// TamperRepo_ListRules_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListRules' -type TamperRepo_ListRules_Call struct { - *mock.Call -} - -// ListRules is a helper method to define mock.On call -func (_e *TamperRepo_Expecter) ListRules() *TamperRepo_ListRules_Call { - return &TamperRepo_ListRules_Call{Call: _e.mock.On("ListRules")} -} - -func (_c *TamperRepo_ListRules_Call) Run(run func()) *TamperRepo_ListRules_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *TamperRepo_ListRules_Call) Return(tamperRules []*biz.TamperRule, err error) *TamperRepo_ListRules_Call { - _c.Call.Return(tamperRules, err) - return _c -} - -func (_c *TamperRepo_ListRules_Call) RunAndReturn(run func() ([]*biz.TamperRule, error)) *TamperRepo_ListRules_Call { - _c.Call.Return(run) - return _c -} - -// UpdateRule provides a mock function for the type TamperRepo -func (_mock *TamperRepo) UpdateRule(rule *biz.TamperRule) error { - ret := _mock.Called(rule) - - if len(ret) == 0 { - panic("no return value specified for UpdateRule") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.TamperRule) error); ok { - r0 = returnFunc(rule) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TamperRepo_UpdateRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRule' -type TamperRepo_UpdateRule_Call struct { - *mock.Call -} - -// UpdateRule is a helper method to define mock.On call -// - rule *biz.TamperRule -func (_e *TamperRepo_Expecter) UpdateRule(rule any) *TamperRepo_UpdateRule_Call { - return &TamperRepo_UpdateRule_Call{Call: _e.mock.On("UpdateRule", rule)} -} - -func (_c *TamperRepo_UpdateRule_Call) Run(run func(rule *biz.TamperRule)) *TamperRepo_UpdateRule_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.TamperRule - if args[0] != nil { - arg0 = args[0].(*biz.TamperRule) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TamperRepo_UpdateRule_Call) Return(err error) *TamperRepo_UpdateRule_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TamperRepo_UpdateRule_Call) RunAndReturn(run func(rule *biz.TamperRule) error) *TamperRepo_UpdateRule_Call { - _c.Call.Return(run) - return _c -} - -// VacuumDB provides a mock function for the type TamperRepo -func (_mock *TamperRepo) VacuumDB() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for VacuumDB") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TamperRepo_VacuumDB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VacuumDB' -type TamperRepo_VacuumDB_Call struct { - *mock.Call -} - -// VacuumDB is a helper method to define mock.On call -func (_e *TamperRepo_Expecter) VacuumDB() *TamperRepo_VacuumDB_Call { - return &TamperRepo_VacuumDB_Call{Call: _e.mock.On("VacuumDB")} -} - -func (_c *TamperRepo_VacuumDB_Call) Run(run func()) *TamperRepo_VacuumDB_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *TamperRepo_VacuumDB_Call) Return(err error) *TamperRepo_VacuumDB_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TamperRepo_VacuumDB_Call) RunAndReturn(run func() error) *TamperRepo_VacuumDB_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/TaskRepo.go b/mocks/biz/TaskRepo.go deleted file mode 100644 index 1553c0c98..000000000 --- a/mocks/biz/TaskRepo.go +++ /dev/null @@ -1,493 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewTaskRepo creates a new instance of TaskRepo. 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 NewTaskRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *TaskRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &TaskRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// TaskRepo is an autogenerated mock type for the TaskRepo type -type TaskRepo struct { - mock.Mock -} - -type TaskRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *TaskRepo) EXPECT() *TaskRepo_Expecter { - return &TaskRepo_Expecter{mock: &_m.Mock} -} - -// Cancel provides a mock function for the type TaskRepo -func (_mock *TaskRepo) Cancel(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Cancel") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TaskRepo_Cancel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Cancel' -type TaskRepo_Cancel_Call struct { - *mock.Call -} - -// Cancel is a helper method to define mock.On call -// - id uint -func (_e *TaskRepo_Expecter) Cancel(id any) *TaskRepo_Cancel_Call { - return &TaskRepo_Cancel_Call{Call: _e.mock.On("Cancel", id)} -} - -func (_c *TaskRepo_Cancel_Call) Run(run func(id uint)) *TaskRepo_Cancel_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TaskRepo_Cancel_Call) Return(err error) *TaskRepo_Cancel_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TaskRepo_Cancel_Call) RunAndReturn(run func(id uint) error) *TaskRepo_Cancel_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type TaskRepo -func (_mock *TaskRepo) Delete(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TaskRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type TaskRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *TaskRepo_Expecter) Delete(id any) *TaskRepo_Delete_Call { - return &TaskRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *TaskRepo_Delete_Call) Run(run func(id uint)) *TaskRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TaskRepo_Delete_Call) Return(err error) *TaskRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TaskRepo_Delete_Call) RunAndReturn(run func(id uint) error) *TaskRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type TaskRepo -func (_mock *TaskRepo) Get(id uint) (*biz.Task, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.Task - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.Task, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.Task); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.Task) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// TaskRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type TaskRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *TaskRepo_Expecter) Get(id any) *TaskRepo_Get_Call { - return &TaskRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *TaskRepo_Get_Call) Run(run func(id uint)) *TaskRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TaskRepo_Get_Call) Return(task *biz.Task, err error) *TaskRepo_Get_Call { - _c.Call.Return(task, err) - return _c -} - -func (_c *TaskRepo_Get_Call) RunAndReturn(run func(id uint) (*biz.Task, error)) *TaskRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// HasRunningTask provides a mock function for the type TaskRepo -func (_mock *TaskRepo) HasRunningTask() bool { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for HasRunningTask") - } - - var r0 bool - if returnFunc, ok := ret.Get(0).(func() bool); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(bool) - } - return r0 -} - -// TaskRepo_HasRunningTask_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasRunningTask' -type TaskRepo_HasRunningTask_Call struct { - *mock.Call -} - -// HasRunningTask is a helper method to define mock.On call -func (_e *TaskRepo_Expecter) HasRunningTask() *TaskRepo_HasRunningTask_Call { - return &TaskRepo_HasRunningTask_Call{Call: _e.mock.On("HasRunningTask")} -} - -func (_c *TaskRepo_HasRunningTask_Call) Run(run func()) *TaskRepo_HasRunningTask_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *TaskRepo_HasRunningTask_Call) Return(b bool) *TaskRepo_HasRunningTask_Call { - _c.Call.Return(b) - return _c -} - -func (_c *TaskRepo_HasRunningTask_Call) RunAndReturn(run func() bool) *TaskRepo_HasRunningTask_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type TaskRepo -func (_mock *TaskRepo) List(page uint, limit uint) ([]*biz.Task, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.Task - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.Task, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.Task); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.Task) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// TaskRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type TaskRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *TaskRepo_Expecter) List(page any, limit any) *TaskRepo_List_Call { - return &TaskRepo_List_Call{Call: _e.mock.On("List", page, limit)} -} - -func (_c *TaskRepo_List_Call) Run(run func(page uint, limit uint)) *TaskRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *TaskRepo_List_Call) Return(tasks []*biz.Task, n int64, err error) *TaskRepo_List_Call { - _c.Call.Return(tasks, n, err) - return _c -} - -func (_c *TaskRepo_List_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.Task, int64, error)) *TaskRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// Push provides a mock function for the type TaskRepo -func (_mock *TaskRepo) Push(task *biz.Task) error { - ret := _mock.Called(task) - - if len(ret) == 0 { - panic("no return value specified for Push") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Task) error); ok { - r0 = returnFunc(task) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TaskRepo_Push_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Push' -type TaskRepo_Push_Call struct { - *mock.Call -} - -// Push is a helper method to define mock.On call -// - task *biz.Task -func (_e *TaskRepo_Expecter) Push(task any) *TaskRepo_Push_Call { - return &TaskRepo_Push_Call{Call: _e.mock.On("Push", task)} -} - -func (_c *TaskRepo_Push_Call) Run(run func(task *biz.Task)) *TaskRepo_Push_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Task - if args[0] != nil { - arg0 = args[0].(*biz.Task) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TaskRepo_Push_Call) Return(err error) *TaskRepo_Push_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TaskRepo_Push_Call) RunAndReturn(run func(task *biz.Task) error) *TaskRepo_Push_Call { - _c.Call.Return(run) - return _c -} - -// UpdateLog provides a mock function for the type TaskRepo -func (_mock *TaskRepo) UpdateLog(id uint, log string) error { - ret := _mock.Called(id, log) - - if len(ret) == 0 { - panic("no return value specified for UpdateLog") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, string) error); ok { - r0 = returnFunc(id, log) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TaskRepo_UpdateLog_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateLog' -type TaskRepo_UpdateLog_Call struct { - *mock.Call -} - -// UpdateLog is a helper method to define mock.On call -// - id uint -// - log string -func (_e *TaskRepo_Expecter) UpdateLog(id any, log any) *TaskRepo_UpdateLog_Call { - return &TaskRepo_UpdateLog_Call{Call: _e.mock.On("UpdateLog", id, log)} -} - -func (_c *TaskRepo_UpdateLog_Call) Run(run func(id uint, log string)) *TaskRepo_UpdateLog_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *TaskRepo_UpdateLog_Call) Return(err error) *TaskRepo_UpdateLog_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TaskRepo_UpdateLog_Call) RunAndReturn(run func(id uint, log string) error) *TaskRepo_UpdateLog_Call { - _c.Call.Return(run) - return _c -} - -// UpdateStatus provides a mock function for the type TaskRepo -func (_mock *TaskRepo) UpdateStatus(id uint, status biz.TaskStatus) error { - ret := _mock.Called(id, status) - - if len(ret) == 0 { - panic("no return value specified for UpdateStatus") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, biz.TaskStatus) error); ok { - r0 = returnFunc(id, status) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TaskRepo_UpdateStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateStatus' -type TaskRepo_UpdateStatus_Call struct { - *mock.Call -} - -// UpdateStatus is a helper method to define mock.On call -// - id uint -// - status biz.TaskStatus -func (_e *TaskRepo_Expecter) UpdateStatus(id any, status any) *TaskRepo_UpdateStatus_Call { - return &TaskRepo_UpdateStatus_Call{Call: _e.mock.On("UpdateStatus", id, status)} -} - -func (_c *TaskRepo_UpdateStatus_Call) Run(run func(id uint, status biz.TaskStatus)) *TaskRepo_UpdateStatus_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 biz.TaskStatus - if args[1] != nil { - arg1 = args[1].(biz.TaskStatus) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *TaskRepo_UpdateStatus_Call) Return(err error) *TaskRepo_UpdateStatus_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TaskRepo_UpdateStatus_Call) RunAndReturn(run func(id uint, status biz.TaskStatus) error) *TaskRepo_UpdateStatus_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/TemplateRepo.go b/mocks/biz/TemplateRepo.go deleted file mode 100644 index 0dba0bd50..000000000 --- a/mocks/biz/TemplateRepo.go +++ /dev/null @@ -1,216 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/pkg/api" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewTemplateRepo creates a new instance of TemplateRepo. 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 NewTemplateRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *TemplateRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &TemplateRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// TemplateRepo is an autogenerated mock type for the TemplateRepo type -type TemplateRepo struct { - mock.Mock -} - -type TemplateRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *TemplateRepo) EXPECT() *TemplateRepo_Expecter { - return &TemplateRepo_Expecter{mock: &_m.Mock} -} - -// Callback provides a mock function for the type TemplateRepo -func (_mock *TemplateRepo) Callback(slug string) error { - ret := _mock.Called(slug) - - if len(ret) == 0 { - panic("no return value specified for Callback") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(slug) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// TemplateRepo_Callback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Callback' -type TemplateRepo_Callback_Call struct { - *mock.Call -} - -// Callback is a helper method to define mock.On call -// - slug string -func (_e *TemplateRepo_Expecter) Callback(slug any) *TemplateRepo_Callback_Call { - return &TemplateRepo_Callback_Call{Call: _e.mock.On("Callback", slug)} -} - -func (_c *TemplateRepo_Callback_Call) Run(run func(slug string)) *TemplateRepo_Callback_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *TemplateRepo_Callback_Call) Return(err error) *TemplateRepo_Callback_Call { - _c.Call.Return(err) - return _c -} - -func (_c *TemplateRepo_Callback_Call) RunAndReturn(run func(slug string) error) *TemplateRepo_Callback_Call { - _c.Call.Return(run) - return _c -} - -// LoadLocalTemplates provides a mock function for the type TemplateRepo -func (_mock *TemplateRepo) LoadLocalTemplates() api.Templates { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for LoadLocalTemplates") - } - - var r0 api.Templates - if returnFunc, ok := ret.Get(0).(func() api.Templates); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(api.Templates) - } - } - return r0 -} - -// TemplateRepo_LoadLocalTemplates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadLocalTemplates' -type TemplateRepo_LoadLocalTemplates_Call struct { - *mock.Call -} - -// LoadLocalTemplates is a helper method to define mock.On call -func (_e *TemplateRepo_Expecter) LoadLocalTemplates() *TemplateRepo_LoadLocalTemplates_Call { - return &TemplateRepo_LoadLocalTemplates_Call{Call: _e.mock.On("LoadLocalTemplates")} -} - -func (_c *TemplateRepo_LoadLocalTemplates_Call) Run(run func()) *TemplateRepo_LoadLocalTemplates_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *TemplateRepo_LoadLocalTemplates_Call) Return(templates api.Templates) *TemplateRepo_LoadLocalTemplates_Call { - _c.Call.Return(templates) - return _c -} - -func (_c *TemplateRepo_LoadLocalTemplates_Call) RunAndReturn(run func() api.Templates) *TemplateRepo_LoadLocalTemplates_Call { - _c.Call.Return(run) - return _c -} - -// WriteCompose provides a mock function for the type TemplateRepo -func (_mock *TemplateRepo) WriteCompose(name string, compose string, envs []types.KV) (string, error) { - ret := _mock.Called(name, compose, envs) - - if len(ret) == 0 { - panic("no return value specified for WriteCompose") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, []types.KV) (string, error)); ok { - return returnFunc(name, compose, envs) - } - if returnFunc, ok := ret.Get(0).(func(string, string, []types.KV) string); ok { - r0 = returnFunc(name, compose, envs) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(string, string, []types.KV) error); ok { - r1 = returnFunc(name, compose, envs) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// TemplateRepo_WriteCompose_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteCompose' -type TemplateRepo_WriteCompose_Call struct { - *mock.Call -} - -// WriteCompose is a helper method to define mock.On call -// - name string -// - compose string -// - envs []types.KV -func (_e *TemplateRepo_Expecter) WriteCompose(name any, compose any, envs any) *TemplateRepo_WriteCompose_Call { - return &TemplateRepo_WriteCompose_Call{Call: _e.mock.On("WriteCompose", name, compose, envs)} -} - -func (_c *TemplateRepo_WriteCompose_Call) Run(run func(name string, compose string, envs []types.KV)) *TemplateRepo_WriteCompose_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []types.KV - if args[2] != nil { - arg2 = args[2].([]types.KV) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *TemplateRepo_WriteCompose_Call) Return(s string, err error) *TemplateRepo_WriteCompose_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *TemplateRepo_WriteCompose_Call) RunAndReturn(run func(name string, compose string, envs []types.KV) (string, error)) *TemplateRepo_WriteCompose_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/UserPasskeyRepo.go b/mocks/biz/UserPasskeyRepo.go deleted file mode 100644 index 2c25357ec..000000000 --- a/mocks/biz/UserPasskeyRepo.go +++ /dev/null @@ -1,558 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewUserPasskeyRepo creates a new instance of UserPasskeyRepo. 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 NewUserPasskeyRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *UserPasskeyRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &UserPasskeyRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// UserPasskeyRepo is an autogenerated mock type for the UserPasskeyRepo type -type UserPasskeyRepo struct { - mock.Mock -} - -type UserPasskeyRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *UserPasskeyRepo) EXPECT() *UserPasskeyRepo_Expecter { - return &UserPasskeyRepo_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function for the type UserPasskeyRepo -func (_mock *UserPasskeyRepo) Create(passkey *biz.UserPasskey) error { - ret := _mock.Called(passkey) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.UserPasskey) error); ok { - r0 = returnFunc(passkey) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// UserPasskeyRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type UserPasskeyRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - passkey *biz.UserPasskey -func (_e *UserPasskeyRepo_Expecter) Create(passkey any) *UserPasskeyRepo_Create_Call { - return &UserPasskeyRepo_Create_Call{Call: _e.mock.On("Create", passkey)} -} - -func (_c *UserPasskeyRepo_Create_Call) Run(run func(passkey *biz.UserPasskey)) *UserPasskeyRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.UserPasskey - if args[0] != nil { - arg0 = args[0].(*biz.UserPasskey) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserPasskeyRepo_Create_Call) Return(err error) *UserPasskeyRepo_Create_Call { - _c.Call.Return(err) - return _c -} - -func (_c *UserPasskeyRepo_Create_Call) RunAndReturn(run func(passkey *biz.UserPasskey) error) *UserPasskeyRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type UserPasskeyRepo -func (_mock *UserPasskeyRepo) Delete(userID uint, id uint) error { - ret := _mock.Called(userID, id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) error); ok { - r0 = returnFunc(userID, id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// UserPasskeyRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type UserPasskeyRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - userID uint -// - id uint -func (_e *UserPasskeyRepo_Expecter) Delete(userID any, id any) *UserPasskeyRepo_Delete_Call { - return &UserPasskeyRepo_Delete_Call{Call: _e.mock.On("Delete", userID, id)} -} - -func (_c *UserPasskeyRepo_Delete_Call) Run(run func(userID uint, id uint)) *UserPasskeyRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *UserPasskeyRepo_Delete_Call) Return(err error) *UserPasskeyRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *UserPasskeyRepo_Delete_Call) RunAndReturn(run func(userID uint, id uint) error) *UserPasskeyRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// DeleteAllByUserID provides a mock function for the type UserPasskeyRepo -func (_mock *UserPasskeyRepo) DeleteAllByUserID(userID uint) error { - ret := _mock.Called(userID) - - if len(ret) == 0 { - panic("no return value specified for DeleteAllByUserID") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(userID) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// UserPasskeyRepo_DeleteAllByUserID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteAllByUserID' -type UserPasskeyRepo_DeleteAllByUserID_Call struct { - *mock.Call -} - -// DeleteAllByUserID is a helper method to define mock.On call -// - userID uint -func (_e *UserPasskeyRepo_Expecter) DeleteAllByUserID(userID any) *UserPasskeyRepo_DeleteAllByUserID_Call { - return &UserPasskeyRepo_DeleteAllByUserID_Call{Call: _e.mock.On("DeleteAllByUserID", userID)} -} - -func (_c *UserPasskeyRepo_DeleteAllByUserID_Call) Run(run func(userID uint)) *UserPasskeyRepo_DeleteAllByUserID_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserPasskeyRepo_DeleteAllByUserID_Call) Return(err error) *UserPasskeyRepo_DeleteAllByUserID_Call { - _c.Call.Return(err) - return _c -} - -func (_c *UserPasskeyRepo_DeleteAllByUserID_Call) RunAndReturn(run func(userID uint) error) *UserPasskeyRepo_DeleteAllByUserID_Call { - _c.Call.Return(run) - return _c -} - -// GetByCredentialID provides a mock function for the type UserPasskeyRepo -func (_mock *UserPasskeyRepo) GetByCredentialID(credentialID []byte) (*biz.UserPasskey, *biz.User, error) { - ret := _mock.Called(credentialID) - - if len(ret) == 0 { - panic("no return value specified for GetByCredentialID") - } - - var r0 *biz.UserPasskey - var r1 *biz.User - var r2 error - if returnFunc, ok := ret.Get(0).(func([]byte) (*biz.UserPasskey, *biz.User, error)); ok { - return returnFunc(credentialID) - } - if returnFunc, ok := ret.Get(0).(func([]byte) *biz.UserPasskey); ok { - r0 = returnFunc(credentialID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.UserPasskey) - } - } - if returnFunc, ok := ret.Get(1).(func([]byte) *biz.User); ok { - r1 = returnFunc(credentialID) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*biz.User) - } - } - if returnFunc, ok := ret.Get(2).(func([]byte) error); ok { - r2 = returnFunc(credentialID) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// UserPasskeyRepo_GetByCredentialID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByCredentialID' -type UserPasskeyRepo_GetByCredentialID_Call struct { - *mock.Call -} - -// GetByCredentialID is a helper method to define mock.On call -// - credentialID []byte -func (_e *UserPasskeyRepo_Expecter) GetByCredentialID(credentialID any) *UserPasskeyRepo_GetByCredentialID_Call { - return &UserPasskeyRepo_GetByCredentialID_Call{Call: _e.mock.On("GetByCredentialID", credentialID)} -} - -func (_c *UserPasskeyRepo_GetByCredentialID_Call) Run(run func(credentialID []byte)) *UserPasskeyRepo_GetByCredentialID_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []byte - if args[0] != nil { - arg0 = args[0].([]byte) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserPasskeyRepo_GetByCredentialID_Call) Return(userPasskey *biz.UserPasskey, user *biz.User, err error) *UserPasskeyRepo_GetByCredentialID_Call { - _c.Call.Return(userPasskey, user, err) - return _c -} - -func (_c *UserPasskeyRepo_GetByCredentialID_Call) RunAndReturn(run func(credentialID []byte) (*biz.UserPasskey, *biz.User, error)) *UserPasskeyRepo_GetByCredentialID_Call { - _c.Call.Return(run) - return _c -} - -// HasAny provides a mock function for the type UserPasskeyRepo -func (_mock *UserPasskeyRepo) HasAny() (bool, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for HasAny") - } - - var r0 bool - var r1 error - if returnFunc, ok := ret.Get(0).(func() (bool, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() bool); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(bool) - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserPasskeyRepo_HasAny_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasAny' -type UserPasskeyRepo_HasAny_Call struct { - *mock.Call -} - -// HasAny is a helper method to define mock.On call -func (_e *UserPasskeyRepo_Expecter) HasAny() *UserPasskeyRepo_HasAny_Call { - return &UserPasskeyRepo_HasAny_Call{Call: _e.mock.On("HasAny")} -} - -func (_c *UserPasskeyRepo_HasAny_Call) Run(run func()) *UserPasskeyRepo_HasAny_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *UserPasskeyRepo_HasAny_Call) Return(b bool, err error) *UserPasskeyRepo_HasAny_Call { - _c.Call.Return(b, err) - return _c -} - -func (_c *UserPasskeyRepo_HasAny_Call) RunAndReturn(run func() (bool, error)) *UserPasskeyRepo_HasAny_Call { - _c.Call.Return(run) - return _c -} - -// HasPasskey provides a mock function for the type UserPasskeyRepo -func (_mock *UserPasskeyRepo) HasPasskey(userID uint) (bool, error) { - ret := _mock.Called(userID) - - if len(ret) == 0 { - panic("no return value specified for HasPasskey") - } - - var r0 bool - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (bool, error)); ok { - return returnFunc(userID) - } - if returnFunc, ok := ret.Get(0).(func(uint) bool); ok { - r0 = returnFunc(userID) - } else { - r0 = ret.Get(0).(bool) - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(userID) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserPasskeyRepo_HasPasskey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasPasskey' -type UserPasskeyRepo_HasPasskey_Call struct { - *mock.Call -} - -// HasPasskey is a helper method to define mock.On call -// - userID uint -func (_e *UserPasskeyRepo_Expecter) HasPasskey(userID any) *UserPasskeyRepo_HasPasskey_Call { - return &UserPasskeyRepo_HasPasskey_Call{Call: _e.mock.On("HasPasskey", userID)} -} - -func (_c *UserPasskeyRepo_HasPasskey_Call) Run(run func(userID uint)) *UserPasskeyRepo_HasPasskey_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserPasskeyRepo_HasPasskey_Call) Return(b bool, err error) *UserPasskeyRepo_HasPasskey_Call { - _c.Call.Return(b, err) - return _c -} - -func (_c *UserPasskeyRepo_HasPasskey_Call) RunAndReturn(run func(userID uint) (bool, error)) *UserPasskeyRepo_HasPasskey_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type UserPasskeyRepo -func (_mock *UserPasskeyRepo) List(userID uint) ([]*biz.UserPasskey, error) { - ret := _mock.Called(userID) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.UserPasskey - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) ([]*biz.UserPasskey, error)); ok { - return returnFunc(userID) - } - if returnFunc, ok := ret.Get(0).(func(uint) []*biz.UserPasskey); ok { - r0 = returnFunc(userID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.UserPasskey) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(userID) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserPasskeyRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type UserPasskeyRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - userID uint -func (_e *UserPasskeyRepo_Expecter) List(userID any) *UserPasskeyRepo_List_Call { - return &UserPasskeyRepo_List_Call{Call: _e.mock.On("List", userID)} -} - -func (_c *UserPasskeyRepo_List_Call) Run(run func(userID uint)) *UserPasskeyRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserPasskeyRepo_List_Call) Return(userPasskeys []*biz.UserPasskey, err error) *UserPasskeyRepo_List_Call { - _c.Call.Return(userPasskeys, err) - return _c -} - -func (_c *UserPasskeyRepo_List_Call) RunAndReturn(run func(userID uint) ([]*biz.UserPasskey, error)) *UserPasskeyRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// UpdateLastUsed provides a mock function for the type UserPasskeyRepo -func (_mock *UserPasskeyRepo) UpdateLastUsed(credentialID []byte) error { - ret := _mock.Called(credentialID) - - if len(ret) == 0 { - panic("no return value specified for UpdateLastUsed") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func([]byte) error); ok { - r0 = returnFunc(credentialID) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// UserPasskeyRepo_UpdateLastUsed_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateLastUsed' -type UserPasskeyRepo_UpdateLastUsed_Call struct { - *mock.Call -} - -// UpdateLastUsed is a helper method to define mock.On call -// - credentialID []byte -func (_e *UserPasskeyRepo_Expecter) UpdateLastUsed(credentialID any) *UserPasskeyRepo_UpdateLastUsed_Call { - return &UserPasskeyRepo_UpdateLastUsed_Call{Call: _e.mock.On("UpdateLastUsed", credentialID)} -} - -func (_c *UserPasskeyRepo_UpdateLastUsed_Call) Run(run func(credentialID []byte)) *UserPasskeyRepo_UpdateLastUsed_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []byte - if args[0] != nil { - arg0 = args[0].([]byte) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserPasskeyRepo_UpdateLastUsed_Call) Return(err error) *UserPasskeyRepo_UpdateLastUsed_Call { - _c.Call.Return(err) - return _c -} - -func (_c *UserPasskeyRepo_UpdateLastUsed_Call) RunAndReturn(run func(credentialID []byte) error) *UserPasskeyRepo_UpdateLastUsed_Call { - _c.Call.Return(run) - return _c -} - -// UpdateSignCount provides a mock function for the type UserPasskeyRepo -func (_mock *UserPasskeyRepo) UpdateSignCount(credentialID []byte, signCount uint32) error { - ret := _mock.Called(credentialID, signCount) - - if len(ret) == 0 { - panic("no return value specified for UpdateSignCount") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func([]byte, uint32) error); ok { - r0 = returnFunc(credentialID, signCount) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// UserPasskeyRepo_UpdateSignCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateSignCount' -type UserPasskeyRepo_UpdateSignCount_Call struct { - *mock.Call -} - -// UpdateSignCount is a helper method to define mock.On call -// - credentialID []byte -// - signCount uint32 -func (_e *UserPasskeyRepo_Expecter) UpdateSignCount(credentialID any, signCount any) *UserPasskeyRepo_UpdateSignCount_Call { - return &UserPasskeyRepo_UpdateSignCount_Call{Call: _e.mock.On("UpdateSignCount", credentialID, signCount)} -} - -func (_c *UserPasskeyRepo_UpdateSignCount_Call) Run(run func(credentialID []byte, signCount uint32)) *UserPasskeyRepo_UpdateSignCount_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []byte - if args[0] != nil { - arg0 = args[0].([]byte) - } - var arg1 uint32 - if args[1] != nil { - arg1 = args[1].(uint32) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *UserPasskeyRepo_UpdateSignCount_Call) Return(err error) *UserPasskeyRepo_UpdateSignCount_Call { - _c.Call.Return(err) - return _c -} - -func (_c *UserPasskeyRepo_UpdateSignCount_Call) RunAndReturn(run func(credentialID []byte, signCount uint32) error) *UserPasskeyRepo_UpdateSignCount_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/UserRepo.go b/mocks/biz/UserRepo.go deleted file mode 100644 index df748f4f1..000000000 --- a/mocks/biz/UserRepo.go +++ /dev/null @@ -1,807 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "image" - - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewUserRepo creates a new instance of UserRepo. 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 NewUserRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *UserRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &UserRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// UserRepo is an autogenerated mock type for the UserRepo type -type UserRepo struct { - mock.Mock -} - -type UserRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *UserRepo) EXPECT() *UserRepo_Expecter { - return &UserRepo_Expecter{mock: &_m.Mock} -} - -// CheckPassword provides a mock function for the type UserRepo -func (_mock *UserRepo) CheckPassword(username string, password string) (*biz.User, error) { - ret := _mock.Called(username, password) - - if len(ret) == 0 { - panic("no return value specified for CheckPassword") - } - - var r0 *biz.User - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string) (*biz.User, error)); ok { - return returnFunc(username, password) - } - if returnFunc, ok := ret.Get(0).(func(string, string) *biz.User); ok { - r0 = returnFunc(username, password) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.User) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string) error); ok { - r1 = returnFunc(username, password) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserRepo_CheckPassword_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckPassword' -type UserRepo_CheckPassword_Call struct { - *mock.Call -} - -// CheckPassword is a helper method to define mock.On call -// - username string -// - password string -func (_e *UserRepo_Expecter) CheckPassword(username any, password any) *UserRepo_CheckPassword_Call { - return &UserRepo_CheckPassword_Call{Call: _e.mock.On("CheckPassword", username, password)} -} - -func (_c *UserRepo_CheckPassword_Call) Run(run func(username string, password string)) *UserRepo_CheckPassword_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *UserRepo_CheckPassword_Call) Return(user *biz.User, err error) *UserRepo_CheckPassword_Call { - _c.Call.Return(user, err) - return _c -} - -func (_c *UserRepo_CheckPassword_Call) RunAndReturn(run func(username string, password string) (*biz.User, error)) *UserRepo_CheckPassword_Call { - _c.Call.Return(run) - return _c -} - -// Count provides a mock function for the type UserRepo -func (_mock *UserRepo) Count() (int64, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for Count") - } - - var r0 int64 - var r1 error - if returnFunc, ok := ret.Get(0).(func() (int64, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() int64); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(int64) - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserRepo_Count_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Count' -type UserRepo_Count_Call struct { - *mock.Call -} - -// Count is a helper method to define mock.On call -func (_e *UserRepo_Expecter) Count() *UserRepo_Count_Call { - return &UserRepo_Count_Call{Call: _e.mock.On("Count")} -} - -func (_c *UserRepo_Count_Call) Run(run func()) *UserRepo_Count_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *UserRepo_Count_Call) Return(n int64, err error) *UserRepo_Count_Call { - _c.Call.Return(n, err) - return _c -} - -func (_c *UserRepo_Count_Call) RunAndReturn(run func() (int64, error)) *UserRepo_Count_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function for the type UserRepo -func (_mock *UserRepo) Create(username string, password string, email string) (*biz.User, error) { - ret := _mock.Called(username, password, email) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *biz.User - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, string) (*biz.User, error)); ok { - return returnFunc(username, password, email) - } - if returnFunc, ok := ret.Get(0).(func(string, string, string) *biz.User); ok { - r0 = returnFunc(username, password, email) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.User) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, string) error); ok { - r1 = returnFunc(username, password, email) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type UserRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - username string -// - password string -// - email string -func (_e *UserRepo_Expecter) Create(username any, password any, email any) *UserRepo_Create_Call { - return &UserRepo_Create_Call{Call: _e.mock.On("Create", username, password, email)} -} - -func (_c *UserRepo_Create_Call) Run(run func(username string, password string, email string)) *UserRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *UserRepo_Create_Call) Return(user *biz.User, err error) *UserRepo_Create_Call { - _c.Call.Return(user, err) - return _c -} - -func (_c *UserRepo_Create_Call) RunAndReturn(run func(username string, password string, email string) (*biz.User, error)) *UserRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type UserRepo -func (_mock *UserRepo) Delete(id uint) (string, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (string, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) string); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type UserRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *UserRepo_Expecter) Delete(id any) *UserRepo_Delete_Call { - return &UserRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *UserRepo_Delete_Call) Run(run func(id uint)) *UserRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserRepo_Delete_Call) Return(s string, err error) *UserRepo_Delete_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *UserRepo_Delete_Call) RunAndReturn(run func(id uint) (string, error)) *UserRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// GenerateTwoFA provides a mock function for the type UserRepo -func (_mock *UserRepo) GenerateTwoFA(id uint) (image.Image, string, string, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for GenerateTwoFA") - } - - var r0 image.Image - var r1 string - var r2 string - var r3 error - if returnFunc, ok := ret.Get(0).(func(uint) (image.Image, string, string, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) image.Image); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(image.Image) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) string); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Get(1).(string) - } - if returnFunc, ok := ret.Get(2).(func(uint) string); ok { - r2 = returnFunc(id) - } else { - r2 = ret.Get(2).(string) - } - if returnFunc, ok := ret.Get(3).(func(uint) error); ok { - r3 = returnFunc(id) - } else { - r3 = ret.Error(3) - } - return r0, r1, r2, r3 -} - -// UserRepo_GenerateTwoFA_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GenerateTwoFA' -type UserRepo_GenerateTwoFA_Call struct { - *mock.Call -} - -// GenerateTwoFA is a helper method to define mock.On call -// - id uint -func (_e *UserRepo_Expecter) GenerateTwoFA(id any) *UserRepo_GenerateTwoFA_Call { - return &UserRepo_GenerateTwoFA_Call{Call: _e.mock.On("GenerateTwoFA", id)} -} - -func (_c *UserRepo_GenerateTwoFA_Call) Run(run func(id uint)) *UserRepo_GenerateTwoFA_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserRepo_GenerateTwoFA_Call) Return(image1 image.Image, s string, s1 string, err error) *UserRepo_GenerateTwoFA_Call { - _c.Call.Return(image1, s, s1, err) - return _c -} - -func (_c *UserRepo_GenerateTwoFA_Call) RunAndReturn(run func(id uint) (image.Image, string, string, error)) *UserRepo_GenerateTwoFA_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type UserRepo -func (_mock *UserRepo) Get(id uint) (*biz.User, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.User - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.User, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.User); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.User) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type UserRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *UserRepo_Expecter) Get(id any) *UserRepo_Get_Call { - return &UserRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *UserRepo_Get_Call) Run(run func(id uint)) *UserRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserRepo_Get_Call) Return(user *biz.User, err error) *UserRepo_Get_Call { - _c.Call.Return(user, err) - return _c -} - -func (_c *UserRepo_Get_Call) RunAndReturn(run func(id uint) (*biz.User, error)) *UserRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// IsTwoFA provides a mock function for the type UserRepo -func (_mock *UserRepo) IsTwoFA(username string) (bool, error) { - ret := _mock.Called(username) - - if len(ret) == 0 { - panic("no return value specified for IsTwoFA") - } - - var r0 bool - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) (bool, error)); ok { - return returnFunc(username) - } - if returnFunc, ok := ret.Get(0).(func(string) bool); ok { - r0 = returnFunc(username) - } else { - r0 = ret.Get(0).(bool) - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(username) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserRepo_IsTwoFA_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsTwoFA' -type UserRepo_IsTwoFA_Call struct { - *mock.Call -} - -// IsTwoFA is a helper method to define mock.On call -// - username string -func (_e *UserRepo_Expecter) IsTwoFA(username any) *UserRepo_IsTwoFA_Call { - return &UserRepo_IsTwoFA_Call{Call: _e.mock.On("IsTwoFA", username)} -} - -func (_c *UserRepo_IsTwoFA_Call) Run(run func(username string)) *UserRepo_IsTwoFA_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserRepo_IsTwoFA_Call) Return(b bool, err error) *UserRepo_IsTwoFA_Call { - _c.Call.Return(b, err) - return _c -} - -func (_c *UserRepo_IsTwoFA_Call) RunAndReturn(run func(username string) (bool, error)) *UserRepo_IsTwoFA_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type UserRepo -func (_mock *UserRepo) List(page uint, limit uint) ([]*biz.User, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.User - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.User, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.User); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.User) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// UserRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type UserRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *UserRepo_Expecter) List(page any, limit any) *UserRepo_List_Call { - return &UserRepo_List_Call{Call: _e.mock.On("List", page, limit)} -} - -func (_c *UserRepo_List_Call) Run(run func(page uint, limit uint)) *UserRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *UserRepo_List_Call) Return(users []*biz.User, n int64, err error) *UserRepo_List_Call { - _c.Call.Return(users, n, err) - return _c -} - -func (_c *UserRepo_List_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.User, int64, error)) *UserRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// UpdateEmail provides a mock function for the type UserRepo -func (_mock *UserRepo) UpdateEmail(id uint, email string) error { - ret := _mock.Called(id, email) - - if len(ret) == 0 { - panic("no return value specified for UpdateEmail") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, string) error); ok { - r0 = returnFunc(id, email) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// UserRepo_UpdateEmail_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateEmail' -type UserRepo_UpdateEmail_Call struct { - *mock.Call -} - -// UpdateEmail is a helper method to define mock.On call -// - id uint -// - email string -func (_e *UserRepo_Expecter) UpdateEmail(id any, email any) *UserRepo_UpdateEmail_Call { - return &UserRepo_UpdateEmail_Call{Call: _e.mock.On("UpdateEmail", id, email)} -} - -func (_c *UserRepo_UpdateEmail_Call) Run(run func(id uint, email string)) *UserRepo_UpdateEmail_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *UserRepo_UpdateEmail_Call) Return(err error) *UserRepo_UpdateEmail_Call { - _c.Call.Return(err) - return _c -} - -func (_c *UserRepo_UpdateEmail_Call) RunAndReturn(run func(id uint, email string) error) *UserRepo_UpdateEmail_Call { - _c.Call.Return(run) - return _c -} - -// UpdatePassword provides a mock function for the type UserRepo -func (_mock *UserRepo) UpdatePassword(id uint, password string) error { - ret := _mock.Called(id, password) - - if len(ret) == 0 { - panic("no return value specified for UpdatePassword") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, string) error); ok { - r0 = returnFunc(id, password) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// UserRepo_UpdatePassword_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdatePassword' -type UserRepo_UpdatePassword_Call struct { - *mock.Call -} - -// UpdatePassword is a helper method to define mock.On call -// - id uint -// - password string -func (_e *UserRepo_Expecter) UpdatePassword(id any, password any) *UserRepo_UpdatePassword_Call { - return &UserRepo_UpdatePassword_Call{Call: _e.mock.On("UpdatePassword", id, password)} -} - -func (_c *UserRepo_UpdatePassword_Call) Run(run func(id uint, password string)) *UserRepo_UpdatePassword_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *UserRepo_UpdatePassword_Call) Return(err error) *UserRepo_UpdatePassword_Call { - _c.Call.Return(err) - return _c -} - -func (_c *UserRepo_UpdatePassword_Call) RunAndReturn(run func(id uint, password string) error) *UserRepo_UpdatePassword_Call { - _c.Call.Return(run) - return _c -} - -// UpdateTwoFA provides a mock function for the type UserRepo -func (_mock *UserRepo) UpdateTwoFA(id uint, code string, secret string) error { - ret := _mock.Called(id, code, secret) - - if len(ret) == 0 { - panic("no return value specified for UpdateTwoFA") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, string, string) error); ok { - r0 = returnFunc(id, code, secret) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// UserRepo_UpdateTwoFA_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateTwoFA' -type UserRepo_UpdateTwoFA_Call struct { - *mock.Call -} - -// UpdateTwoFA is a helper method to define mock.On call -// - id uint -// - code string -// - secret string -func (_e *UserRepo_Expecter) UpdateTwoFA(id any, code any, secret any) *UserRepo_UpdateTwoFA_Call { - return &UserRepo_UpdateTwoFA_Call{Call: _e.mock.On("UpdateTwoFA", id, code, secret)} -} - -func (_c *UserRepo_UpdateTwoFA_Call) Run(run func(id uint, code string, secret string)) *UserRepo_UpdateTwoFA_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *UserRepo_UpdateTwoFA_Call) Return(err error) *UserRepo_UpdateTwoFA_Call { - _c.Call.Return(err) - return _c -} - -func (_c *UserRepo_UpdateTwoFA_Call) RunAndReturn(run func(id uint, code string, secret string) error) *UserRepo_UpdateTwoFA_Call { - _c.Call.Return(run) - return _c -} - -// UpdateUsername provides a mock function for the type UserRepo -func (_mock *UserRepo) UpdateUsername(id uint, username string) error { - ret := _mock.Called(id, username) - - if len(ret) == 0 { - panic("no return value specified for UpdateUsername") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, string) error); ok { - r0 = returnFunc(id, username) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// UserRepo_UpdateUsername_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUsername' -type UserRepo_UpdateUsername_Call struct { - *mock.Call -} - -// UpdateUsername is a helper method to define mock.On call -// - id uint -// - username string -func (_e *UserRepo_Expecter) UpdateUsername(id any, username any) *UserRepo_UpdateUsername_Call { - return &UserRepo_UpdateUsername_Call{Call: _e.mock.On("UpdateUsername", id, username)} -} - -func (_c *UserRepo_UpdateUsername_Call) Run(run func(id uint, username string)) *UserRepo_UpdateUsername_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *UserRepo_UpdateUsername_Call) Return(err error) *UserRepo_UpdateUsername_Call { - _c.Call.Return(err) - return _c -} - -func (_c *UserRepo_UpdateUsername_Call) RunAndReturn(run func(id uint, username string) error) *UserRepo_UpdateUsername_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/UserTokenRepo.go b/mocks/biz/UserTokenRepo.go deleted file mode 100644 index 8b30eccf3..000000000 --- a/mocks/biz/UserTokenRepo.go +++ /dev/null @@ -1,450 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "net/http" - "time" - - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewUserTokenRepo creates a new instance of UserTokenRepo. 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 NewUserTokenRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *UserTokenRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &UserTokenRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// UserTokenRepo is an autogenerated mock type for the UserTokenRepo type -type UserTokenRepo struct { - mock.Mock -} - -type UserTokenRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *UserTokenRepo) EXPECT() *UserTokenRepo_Expecter { - return &UserTokenRepo_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function for the type UserTokenRepo -func (_mock *UserTokenRepo) Create(userID uint, ips []string, expired time.Time) (*biz.UserToken, error) { - ret := _mock.Called(userID, ips, expired) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *biz.UserToken - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint, []string, time.Time) (*biz.UserToken, error)); ok { - return returnFunc(userID, ips, expired) - } - if returnFunc, ok := ret.Get(0).(func(uint, []string, time.Time) *biz.UserToken); ok { - r0 = returnFunc(userID, ips, expired) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.UserToken) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, []string, time.Time) error); ok { - r1 = returnFunc(userID, ips, expired) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserTokenRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type UserTokenRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - userID uint -// - ips []string -// - expired time.Time -func (_e *UserTokenRepo_Expecter) Create(userID any, ips any, expired any) *UserTokenRepo_Create_Call { - return &UserTokenRepo_Create_Call{Call: _e.mock.On("Create", userID, ips, expired)} -} - -func (_c *UserTokenRepo_Create_Call) Run(run func(userID uint, ips []string, expired time.Time)) *UserTokenRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 []string - if args[1] != nil { - arg1 = args[1].([]string) - } - var arg2 time.Time - if args[2] != nil { - arg2 = args[2].(time.Time) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *UserTokenRepo_Create_Call) Return(userToken *biz.UserToken, err error) *UserTokenRepo_Create_Call { - _c.Call.Return(userToken, err) - return _c -} - -func (_c *UserTokenRepo_Create_Call) RunAndReturn(run func(userID uint, ips []string, expired time.Time) (*biz.UserToken, error)) *UserTokenRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type UserTokenRepo -func (_mock *UserTokenRepo) Delete(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// UserTokenRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type UserTokenRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *UserTokenRepo_Expecter) Delete(id any) *UserTokenRepo_Delete_Call { - return &UserTokenRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *UserTokenRepo_Delete_Call) Run(run func(id uint)) *UserTokenRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserTokenRepo_Delete_Call) Return(err error) *UserTokenRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *UserTokenRepo_Delete_Call) RunAndReturn(run func(id uint) error) *UserTokenRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type UserTokenRepo -func (_mock *UserTokenRepo) Get(id uint) (*biz.UserToken, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.UserToken - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.UserToken, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.UserToken); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.UserToken) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserTokenRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type UserTokenRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *UserTokenRepo_Expecter) Get(id any) *UserTokenRepo_Get_Call { - return &UserTokenRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *UserTokenRepo_Get_Call) Run(run func(id uint)) *UserTokenRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserTokenRepo_Get_Call) Return(userToken *biz.UserToken, err error) *UserTokenRepo_Get_Call { - _c.Call.Return(userToken, err) - return _c -} - -func (_c *UserTokenRepo_Get_Call) RunAndReturn(run func(id uint) (*biz.UserToken, error)) *UserTokenRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type UserTokenRepo -func (_mock *UserTokenRepo) List(userID uint, page uint, limit uint) ([]*biz.UserToken, int64, error) { - ret := _mock.Called(userID, page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.UserToken - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint, uint) ([]*biz.UserToken, int64, error)); ok { - return returnFunc(userID, page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint, uint) []*biz.UserToken); ok { - r0 = returnFunc(userID, page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.UserToken) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint, uint) int64); ok { - r1 = returnFunc(userID, page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint, uint) error); ok { - r2 = returnFunc(userID, page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// UserTokenRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type UserTokenRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - userID uint -// - page uint -// - limit uint -func (_e *UserTokenRepo_Expecter) List(userID any, page any, limit any) *UserTokenRepo_List_Call { - return &UserTokenRepo_List_Call{Call: _e.mock.On("List", userID, page, limit)} -} - -func (_c *UserTokenRepo_List_Call) Run(run func(userID uint, page uint, limit uint)) *UserTokenRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - var arg2 uint - if args[2] != nil { - arg2 = args[2].(uint) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *UserTokenRepo_List_Call) Return(userTokens []*biz.UserToken, n int64, err error) *UserTokenRepo_List_Call { - _c.Call.Return(userTokens, n, err) - return _c -} - -func (_c *UserTokenRepo_List_Call) RunAndReturn(run func(userID uint, page uint, limit uint) ([]*biz.UserToken, int64, error)) *UserTokenRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function for the type UserTokenRepo -func (_mock *UserTokenRepo) Update(id uint, ips []string, expired time.Time) (*biz.UserToken, error) { - ret := _mock.Called(id, ips, expired) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 *biz.UserToken - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint, []string, time.Time) (*biz.UserToken, error)); ok { - return returnFunc(id, ips, expired) - } - if returnFunc, ok := ret.Get(0).(func(uint, []string, time.Time) *biz.UserToken); ok { - r0 = returnFunc(id, ips, expired) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.UserToken) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, []string, time.Time) error); ok { - r1 = returnFunc(id, ips, expired) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserTokenRepo_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type UserTokenRepo_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - id uint -// - ips []string -// - expired time.Time -func (_e *UserTokenRepo_Expecter) Update(id any, ips any, expired any) *UserTokenRepo_Update_Call { - return &UserTokenRepo_Update_Call{Call: _e.mock.On("Update", id, ips, expired)} -} - -func (_c *UserTokenRepo_Update_Call) Run(run func(id uint, ips []string, expired time.Time)) *UserTokenRepo_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 []string - if args[1] != nil { - arg1 = args[1].([]string) - } - var arg2 time.Time - if args[2] != nil { - arg2 = args[2].(time.Time) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *UserTokenRepo_Update_Call) Return(userToken *biz.UserToken, err error) *UserTokenRepo_Update_Call { - _c.Call.Return(userToken, err) - return _c -} - -func (_c *UserTokenRepo_Update_Call) RunAndReturn(run func(id uint, ips []string, expired time.Time) (*biz.UserToken, error)) *UserTokenRepo_Update_Call { - _c.Call.Return(run) - return _c -} - -// ValidateReq provides a mock function for the type UserTokenRepo -func (_mock *UserTokenRepo) ValidateReq(req *http.Request) (uint, error) { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for ValidateReq") - } - - var r0 uint - var r1 error - if returnFunc, ok := ret.Get(0).(func(*http.Request) (uint, error)); ok { - return returnFunc(req) - } - if returnFunc, ok := ret.Get(0).(func(*http.Request) uint); ok { - r0 = returnFunc(req) - } else { - r0 = ret.Get(0).(uint) - } - if returnFunc, ok := ret.Get(1).(func(*http.Request) error); ok { - r1 = returnFunc(req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// UserTokenRepo_ValidateReq_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ValidateReq' -type UserTokenRepo_ValidateReq_Call struct { - *mock.Call -} - -// ValidateReq is a helper method to define mock.On call -// - req *http.Request -func (_e *UserTokenRepo_Expecter) ValidateReq(req any) *UserTokenRepo_ValidateReq_Call { - return &UserTokenRepo_ValidateReq_Call{Call: _e.mock.On("ValidateReq", req)} -} - -func (_c *UserTokenRepo_ValidateReq_Call) Run(run func(req *http.Request)) *UserTokenRepo_ValidateReq_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *http.Request - if args[0] != nil { - arg0 = args[0].(*http.Request) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *UserTokenRepo_ValidateReq_Call) Return(v uint, err error) *UserTokenRepo_ValidateReq_Call { - _c.Call.Return(v, err) - return _c -} - -func (_c *UserTokenRepo_ValidateReq_Call) RunAndReturn(run func(req *http.Request) (uint, error)) *UserTokenRepo_ValidateReq_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/WebHookRepo.go b/mocks/biz/WebHookRepo.go deleted file mode 100644 index 97ae9fa13..000000000 --- a/mocks/biz/WebHookRepo.go +++ /dev/null @@ -1,521 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/internal/request" - mock "github.com/stretchr/testify/mock" -) - -// NewWebHookRepo creates a new instance of WebHookRepo. 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 NewWebHookRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *WebHookRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &WebHookRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// WebHookRepo is an autogenerated mock type for the WebHookRepo type -type WebHookRepo struct { - mock.Mock -} - -type WebHookRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *WebHookRepo) EXPECT() *WebHookRepo_Expecter { - return &WebHookRepo_Expecter{mock: &_m.Mock} -} - -// Call provides a mock function for the type WebHookRepo -func (_mock *WebHookRepo) Call(key string) (string, error) { - ret := _mock.Called(key) - - if len(ret) == 0 { - panic("no return value specified for Call") - } - - var r0 string - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) (string, error)); ok { - return returnFunc(key) - } - if returnFunc, ok := ret.Get(0).(func(string) string); ok { - r0 = returnFunc(key) - } else { - r0 = ret.Get(0).(string) - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(key) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebHookRepo_Call_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Call' -type WebHookRepo_Call_Call struct { - *mock.Call -} - -// Call is a helper method to define mock.On call -// - key string -func (_e *WebHookRepo_Expecter) Call(key any) *WebHookRepo_Call_Call { - return &WebHookRepo_Call_Call{Call: _e.mock.On("Call", key)} -} - -func (_c *WebHookRepo_Call_Call) Run(run func(key string)) *WebHookRepo_Call_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebHookRepo_Call_Call) Return(s string, err error) *WebHookRepo_Call_Call { - _c.Call.Return(s, err) - return _c -} - -func (_c *WebHookRepo_Call_Call) RunAndReturn(run func(key string) (string, error)) *WebHookRepo_Call_Call { - _c.Call.Return(run) - return _c -} - -// CreateWithScript provides a mock function for the type WebHookRepo -func (_mock *WebHookRepo) CreateWithScript(webhook *biz.WebHook, script string) error { - ret := _mock.Called(webhook, script) - - if len(ret) == 0 { - panic("no return value specified for CreateWithScript") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.WebHook, string) error); ok { - r0 = returnFunc(webhook, script) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebHookRepo_CreateWithScript_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateWithScript' -type WebHookRepo_CreateWithScript_Call struct { - *mock.Call -} - -// CreateWithScript is a helper method to define mock.On call -// - webhook *biz.WebHook -// - script string -func (_e *WebHookRepo_Expecter) CreateWithScript(webhook any, script any) *WebHookRepo_CreateWithScript_Call { - return &WebHookRepo_CreateWithScript_Call{Call: _e.mock.On("CreateWithScript", webhook, script)} -} - -func (_c *WebHookRepo_CreateWithScript_Call) Run(run func(webhook *biz.WebHook, script string)) *WebHookRepo_CreateWithScript_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.WebHook - if args[0] != nil { - arg0 = args[0].(*biz.WebHook) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *WebHookRepo_CreateWithScript_Call) Return(err error) *WebHookRepo_CreateWithScript_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebHookRepo_CreateWithScript_Call) RunAndReturn(run func(webhook *biz.WebHook, script string) error) *WebHookRepo_CreateWithScript_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type WebHookRepo -func (_mock *WebHookRepo) Delete(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebHookRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type WebHookRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - id uint -func (_e *WebHookRepo_Expecter) Delete(id any) *WebHookRepo_Delete_Call { - return &WebHookRepo_Delete_Call{Call: _e.mock.On("Delete", id)} -} - -func (_c *WebHookRepo_Delete_Call) Run(run func(id uint)) *WebHookRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebHookRepo_Delete_Call) Return(err error) *WebHookRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebHookRepo_Delete_Call) RunAndReturn(run func(id uint) error) *WebHookRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type WebHookRepo -func (_mock *WebHookRepo) Get(id uint) (*biz.WebHook, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *biz.WebHook - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.WebHook, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.WebHook); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.WebHook) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebHookRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type WebHookRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *WebHookRepo_Expecter) Get(id any) *WebHookRepo_Get_Call { - return &WebHookRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *WebHookRepo_Get_Call) Run(run func(id uint)) *WebHookRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebHookRepo_Get_Call) Return(webHook *biz.WebHook, err error) *WebHookRepo_Get_Call { - _c.Call.Return(webHook, err) - return _c -} - -func (_c *WebHookRepo_Get_Call) RunAndReturn(run func(id uint) (*biz.WebHook, error)) *WebHookRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// GetByKey provides a mock function for the type WebHookRepo -func (_mock *WebHookRepo) GetByKey(key string) (*biz.WebHook, error) { - ret := _mock.Called(key) - - if len(ret) == 0 { - panic("no return value specified for GetByKey") - } - - var r0 *biz.WebHook - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) (*biz.WebHook, error)); ok { - return returnFunc(key) - } - if returnFunc, ok := ret.Get(0).(func(string) *biz.WebHook); ok { - r0 = returnFunc(key) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.WebHook) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(key) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebHookRepo_GetByKey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByKey' -type WebHookRepo_GetByKey_Call struct { - *mock.Call -} - -// GetByKey is a helper method to define mock.On call -// - key string -func (_e *WebHookRepo_Expecter) GetByKey(key any) *WebHookRepo_GetByKey_Call { - return &WebHookRepo_GetByKey_Call{Call: _e.mock.On("GetByKey", key)} -} - -func (_c *WebHookRepo_GetByKey_Call) Run(run func(key string)) *WebHookRepo_GetByKey_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebHookRepo_GetByKey_Call) Return(webHook *biz.WebHook, err error) *WebHookRepo_GetByKey_Call { - _c.Call.Return(webHook, err) - return _c -} - -func (_c *WebHookRepo_GetByKey_Call) RunAndReturn(run func(key string) (*biz.WebHook, error)) *WebHookRepo_GetByKey_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type WebHookRepo -func (_mock *WebHookRepo) List(page uint, limit uint) ([]*biz.WebHook, int64, error) { - ret := _mock.Called(page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.WebHook - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(uint, uint) ([]*biz.WebHook, int64, error)); ok { - return returnFunc(page, limit) - } - if returnFunc, ok := ret.Get(0).(func(uint, uint) []*biz.WebHook); ok { - r0 = returnFunc(page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebHook) - } - } - if returnFunc, ok := ret.Get(1).(func(uint, uint) int64); ok { - r1 = returnFunc(page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(uint, uint) error); ok { - r2 = returnFunc(page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// WebHookRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type WebHookRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - page uint -// - limit uint -func (_e *WebHookRepo_Expecter) List(page any, limit any) *WebHookRepo_List_Call { - return &WebHookRepo_List_Call{Call: _e.mock.On("List", page, limit)} -} - -func (_c *WebHookRepo_List_Call) Run(run func(page uint, limit uint)) *WebHookRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *WebHookRepo_List_Call) Return(webHooks []*biz.WebHook, n int64, err error) *WebHookRepo_List_Call { - _c.Call.Return(webHooks, n, err) - return _c -} - -func (_c *WebHookRepo_List_Call) RunAndReturn(run func(page uint, limit uint) ([]*biz.WebHook, int64, error)) *WebHookRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// RemoveScript provides a mock function for the type WebHookRepo -func (_mock *WebHookRepo) RemoveScript(key string) error { - ret := _mock.Called(key) - - if len(ret) == 0 { - panic("no return value specified for RemoveScript") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(key) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebHookRepo_RemoveScript_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveScript' -type WebHookRepo_RemoveScript_Call struct { - *mock.Call -} - -// RemoveScript is a helper method to define mock.On call -// - key string -func (_e *WebHookRepo_Expecter) RemoveScript(key any) *WebHookRepo_RemoveScript_Call { - return &WebHookRepo_RemoveScript_Call{Call: _e.mock.On("RemoveScript", key)} -} - -func (_c *WebHookRepo_RemoveScript_Call) Run(run func(key string)) *WebHookRepo_RemoveScript_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebHookRepo_RemoveScript_Call) Return(err error) *WebHookRepo_RemoveScript_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebHookRepo_RemoveScript_Call) RunAndReturn(run func(key string) error) *WebHookRepo_RemoveScript_Call { - _c.Call.Return(run) - return _c -} - -// UpdateWithScript provides a mock function for the type WebHookRepo -func (_mock *WebHookRepo) UpdateWithScript(webhook *biz.WebHook, req *request.WebHookUpdate) error { - ret := _mock.Called(webhook, req) - - if len(ret) == 0 { - panic("no return value specified for UpdateWithScript") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.WebHook, *request.WebHookUpdate) error); ok { - r0 = returnFunc(webhook, req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebHookRepo_UpdateWithScript_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateWithScript' -type WebHookRepo_UpdateWithScript_Call struct { - *mock.Call -} - -// UpdateWithScript is a helper method to define mock.On call -// - webhook *biz.WebHook -// - req *request.WebHookUpdate -func (_e *WebHookRepo_Expecter) UpdateWithScript(webhook any, req any) *WebHookRepo_UpdateWithScript_Call { - return &WebHookRepo_UpdateWithScript_Call{Call: _e.mock.On("UpdateWithScript", webhook, req)} -} - -func (_c *WebHookRepo_UpdateWithScript_Call) Run(run func(webhook *biz.WebHook, req *request.WebHookUpdate)) *WebHookRepo_UpdateWithScript_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.WebHook - if args[0] != nil { - arg0 = args[0].(*biz.WebHook) - } - var arg1 *request.WebHookUpdate - if args[1] != nil { - arg1 = args[1].(*request.WebHookUpdate) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *WebHookRepo_UpdateWithScript_Call) Return(err error) *WebHookRepo_UpdateWithScript_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebHookRepo_UpdateWithScript_Call) RunAndReturn(run func(webhook *biz.WebHook, req *request.WebHookUpdate) error) *WebHookRepo_UpdateWithScript_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/WebsiteRepo.go b/mocks/biz/WebsiteRepo.go deleted file mode 100644 index 17b0580ae..000000000 --- a/mocks/biz/WebsiteRepo.go +++ /dev/null @@ -1,1154 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "time" - - "github.com/acepanel/panel/v3/internal/biz" - "github.com/acepanel/panel/v3/internal/request" - "github.com/acepanel/panel/v3/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// NewWebsiteRepo creates a new instance of WebsiteRepo. 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 NewWebsiteRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *WebsiteRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &WebsiteRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// WebsiteRepo is an autogenerated mock type for the WebsiteRepo type -type WebsiteRepo struct { - mock.Mock -} - -type WebsiteRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *WebsiteRepo) EXPECT() *WebsiteRepo_Expecter { - return &WebsiteRepo_Expecter{mock: &_m.Mock} -} - -// Count provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) Count() (int64, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for Count") - } - - var r0 int64 - var r1 error - if returnFunc, ok := ret.Get(0).(func() (int64, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() int64); ok { - r0 = returnFunc() - } else { - r0 = ret.Get(0).(int64) - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteRepo_Count_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Count' -type WebsiteRepo_Count_Call struct { - *mock.Call -} - -// Count is a helper method to define mock.On call -func (_e *WebsiteRepo_Expecter) Count() *WebsiteRepo_Count_Call { - return &WebsiteRepo_Count_Call{Call: _e.mock.On("Count")} -} - -func (_c *WebsiteRepo_Count_Call) Run(run func()) *WebsiteRepo_Count_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *WebsiteRepo_Count_Call) Return(n int64, err error) *WebsiteRepo_Count_Call { - _c.Call.Return(n, err) - return _c -} - -func (_c *WebsiteRepo_Count_Call) RunAndReturn(run func() (int64, error)) *WebsiteRepo_Count_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) Create(req *request.WebsiteCreate) (*biz.Website, error) { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *biz.Website - var r1 error - if returnFunc, ok := ret.Get(0).(func(*request.WebsiteCreate) (*biz.Website, error)); ok { - return returnFunc(req) - } - if returnFunc, ok := ret.Get(0).(func(*request.WebsiteCreate) *biz.Website); ok { - r0 = returnFunc(req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.Website) - } - } - if returnFunc, ok := ret.Get(1).(func(*request.WebsiteCreate) error); ok { - r1 = returnFunc(req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteRepo_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type WebsiteRepo_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - req *request.WebsiteCreate -func (_e *WebsiteRepo_Expecter) Create(req any) *WebsiteRepo_Create_Call { - return &WebsiteRepo_Create_Call{Call: _e.mock.On("Create", req)} -} - -func (_c *WebsiteRepo_Create_Call) Run(run func(req *request.WebsiteCreate)) *WebsiteRepo_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.WebsiteCreate - if args[0] != nil { - arg0 = args[0].(*request.WebsiteCreate) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteRepo_Create_Call) Return(website *biz.Website, err error) *WebsiteRepo_Create_Call { - _c.Call.Return(website, err) - return _c -} - -func (_c *WebsiteRepo_Create_Call) RunAndReturn(run func(req *request.WebsiteCreate) (*biz.Website, error)) *WebsiteRepo_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) Delete(website *biz.Website) error { - ret := _mock.Called(website) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*biz.Website) error); ok { - r0 = returnFunc(website) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteRepo_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type WebsiteRepo_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - website *biz.Website -func (_e *WebsiteRepo_Expecter) Delete(website any) *WebsiteRepo_Delete_Call { - return &WebsiteRepo_Delete_Call{Call: _e.mock.On("Delete", website)} -} - -func (_c *WebsiteRepo_Delete_Call) Run(run func(website *biz.Website)) *WebsiteRepo_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Website - if args[0] != nil { - arg0 = args[0].(*biz.Website) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteRepo_Delete_Call) Return(err error) *WebsiteRepo_Delete_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteRepo_Delete_Call) RunAndReturn(run func(website *biz.Website) error) *WebsiteRepo_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) Get(id uint) (*types.WebsiteSetting, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *types.WebsiteSetting - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*types.WebsiteSetting, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *types.WebsiteSetting); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*types.WebsiteSetting) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteRepo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type WebsiteRepo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - id uint -func (_e *WebsiteRepo_Expecter) Get(id any) *WebsiteRepo_Get_Call { - return &WebsiteRepo_Get_Call{Call: _e.mock.On("Get", id)} -} - -func (_c *WebsiteRepo_Get_Call) Run(run func(id uint)) *WebsiteRepo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteRepo_Get_Call) Return(websiteSetting *types.WebsiteSetting, err error) *WebsiteRepo_Get_Call { - _c.Call.Return(websiteSetting, err) - return _c -} - -func (_c *WebsiteRepo_Get_Call) RunAndReturn(run func(id uint) (*types.WebsiteSetting, error)) *WebsiteRepo_Get_Call { - _c.Call.Return(run) - return _c -} - -// GetByName provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) GetByName(name string) (*types.WebsiteSetting, error) { - ret := _mock.Called(name) - - if len(ret) == 0 { - panic("no return value specified for GetByName") - } - - var r0 *types.WebsiteSetting - var r1 error - if returnFunc, ok := ret.Get(0).(func(string) (*types.WebsiteSetting, error)); ok { - return returnFunc(name) - } - if returnFunc, ok := ret.Get(0).(func(string) *types.WebsiteSetting); ok { - r0 = returnFunc(name) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*types.WebsiteSetting) - } - } - if returnFunc, ok := ret.Get(1).(func(string) error); ok { - r1 = returnFunc(name) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteRepo_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' -type WebsiteRepo_GetByName_Call struct { - *mock.Call -} - -// GetByName is a helper method to define mock.On call -// - name string -func (_e *WebsiteRepo_Expecter) GetByName(name any) *WebsiteRepo_GetByName_Call { - return &WebsiteRepo_GetByName_Call{Call: _e.mock.On("GetByName", name)} -} - -func (_c *WebsiteRepo_GetByName_Call) Run(run func(name string)) *WebsiteRepo_GetByName_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteRepo_GetByName_Call) Return(websiteSetting *types.WebsiteSetting, err error) *WebsiteRepo_GetByName_Call { - _c.Call.Return(websiteSetting, err) - return _c -} - -func (_c *WebsiteRepo_GetByName_Call) RunAndReturn(run func(name string) (*types.WebsiteSetting, error)) *WebsiteRepo_GetByName_Call { - _c.Call.Return(run) - return _c -} - -// GetForDelete provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) GetForDelete(id uint) (*biz.Website, error) { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for GetForDelete") - } - - var r0 *biz.Website - var r1 error - if returnFunc, ok := ret.Get(0).(func(uint) (*biz.Website, error)); ok { - return returnFunc(id) - } - if returnFunc, ok := ret.Get(0).(func(uint) *biz.Website); ok { - r0 = returnFunc(id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.Website) - } - } - if returnFunc, ok := ret.Get(1).(func(uint) error); ok { - r1 = returnFunc(id) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteRepo_GetForDelete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetForDelete' -type WebsiteRepo_GetForDelete_Call struct { - *mock.Call -} - -// GetForDelete is a helper method to define mock.On call -// - id uint -func (_e *WebsiteRepo_Expecter) GetForDelete(id any) *WebsiteRepo_GetForDelete_Call { - return &WebsiteRepo_GetForDelete_Call{Call: _e.mock.On("GetForDelete", id)} -} - -func (_c *WebsiteRepo_GetForDelete_Call) Run(run func(id uint)) *WebsiteRepo_GetForDelete_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteRepo_GetForDelete_Call) Return(website *biz.Website, err error) *WebsiteRepo_GetForDelete_Call { - _c.Call.Return(website, err) - return _c -} - -func (_c *WebsiteRepo_GetForDelete_Call) RunAndReturn(run func(id uint) (*biz.Website, error)) *WebsiteRepo_GetForDelete_Call { - _c.Call.Return(run) - return _c -} - -// GetRewrites provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) GetRewrites() (map[string]string, error) { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for GetRewrites") - } - - var r0 map[string]string - var r1 error - if returnFunc, ok := ret.Get(0).(func() (map[string]string, error)); ok { - return returnFunc() - } - if returnFunc, ok := ret.Get(0).(func() map[string]string); ok { - r0 = returnFunc() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(map[string]string) - } - } - if returnFunc, ok := ret.Get(1).(func() error); ok { - r1 = returnFunc() - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteRepo_GetRewrites_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRewrites' -type WebsiteRepo_GetRewrites_Call struct { - *mock.Call -} - -// GetRewrites is a helper method to define mock.On call -func (_e *WebsiteRepo_Expecter) GetRewrites() *WebsiteRepo_GetRewrites_Call { - return &WebsiteRepo_GetRewrites_Call{Call: _e.mock.On("GetRewrites")} -} - -func (_c *WebsiteRepo_GetRewrites_Call) Run(run func()) *WebsiteRepo_GetRewrites_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *WebsiteRepo_GetRewrites_Call) Return(stringToString map[string]string, err error) *WebsiteRepo_GetRewrites_Call { - _c.Call.Return(stringToString, err) - return _c -} - -func (_c *WebsiteRepo_GetRewrites_Call) RunAndReturn(run func() (map[string]string, error)) *WebsiteRepo_GetRewrites_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) List(typ string, page uint, limit uint) ([]*biz.Website, int64, error) { - ret := _mock.Called(typ, page, limit) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*biz.Website - var r1 int64 - var r2 error - if returnFunc, ok := ret.Get(0).(func(string, uint, uint) ([]*biz.Website, int64, error)); ok { - return returnFunc(typ, page, limit) - } - if returnFunc, ok := ret.Get(0).(func(string, uint, uint) []*biz.Website); ok { - r0 = returnFunc(typ, page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.Website) - } - } - if returnFunc, ok := ret.Get(1).(func(string, uint, uint) int64); ok { - r1 = returnFunc(typ, page, limit) - } else { - r1 = ret.Get(1).(int64) - } - if returnFunc, ok := ret.Get(2).(func(string, uint, uint) error); ok { - r2 = returnFunc(typ, page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// WebsiteRepo_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type WebsiteRepo_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - typ string -// - page uint -// - limit uint -func (_e *WebsiteRepo_Expecter) List(typ any, page any, limit any) *WebsiteRepo_List_Call { - return &WebsiteRepo_List_Call{Call: _e.mock.On("List", typ, page, limit)} -} - -func (_c *WebsiteRepo_List_Call) Run(run func(typ string, page uint, limit uint)) *WebsiteRepo_List_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 uint - if args[1] != nil { - arg1 = args[1].(uint) - } - var arg2 uint - if args[2] != nil { - arg2 = args[2].(uint) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *WebsiteRepo_List_Call) Return(websites []*biz.Website, n int64, err error) *WebsiteRepo_List_Call { - _c.Call.Return(websites, n, err) - return _c -} - -func (_c *WebsiteRepo_List_Call) RunAndReturn(run func(typ string, page uint, limit uint) ([]*biz.Website, int64, error)) *WebsiteRepo_List_Call { - _c.Call.Return(run) - return _c -} - -// Rebuild provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) Rebuild(website *biz.Website) (bool, []string, error) { - ret := _mock.Called(website) - - if len(ret) == 0 { - panic("no return value specified for Rebuild") - } - - var r0 bool - var r1 []string - var r2 error - if returnFunc, ok := ret.Get(0).(func(*biz.Website) (bool, []string, error)); ok { - return returnFunc(website) - } - if returnFunc, ok := ret.Get(0).(func(*biz.Website) bool); ok { - r0 = returnFunc(website) - } else { - r0 = ret.Get(0).(bool) - } - if returnFunc, ok := ret.Get(1).(func(*biz.Website) []string); ok { - r1 = returnFunc(website) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).([]string) - } - } - if returnFunc, ok := ret.Get(2).(func(*biz.Website) error); ok { - r2 = returnFunc(website) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// WebsiteRepo_Rebuild_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Rebuild' -type WebsiteRepo_Rebuild_Call struct { - *mock.Call -} - -// Rebuild is a helper method to define mock.On call -// - website *biz.Website -func (_e *WebsiteRepo_Expecter) Rebuild(website any) *WebsiteRepo_Rebuild_Call { - return &WebsiteRepo_Rebuild_Call{Call: _e.mock.On("Rebuild", website)} -} - -func (_c *WebsiteRepo_Rebuild_Call) Run(run func(website *biz.Website)) *WebsiteRepo_Rebuild_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *biz.Website - if args[0] != nil { - arg0 = args[0].(*biz.Website) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteRepo_Rebuild_Call) Return(b bool, strings []string, err error) *WebsiteRepo_Rebuild_Call { - _c.Call.Return(b, strings, err) - return _c -} - -func (_c *WebsiteRepo_Rebuild_Call) RunAndReturn(run func(website *biz.Website) (bool, []string, error)) *WebsiteRepo_Rebuild_Call { - _c.Call.Return(run) - return _c -} - -// ReloadWebServer provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) ReloadWebServer() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for ReloadWebServer") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteRepo_ReloadWebServer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReloadWebServer' -type WebsiteRepo_ReloadWebServer_Call struct { - *mock.Call -} - -// ReloadWebServer is a helper method to define mock.On call -func (_e *WebsiteRepo_Expecter) ReloadWebServer() *WebsiteRepo_ReloadWebServer_Call { - return &WebsiteRepo_ReloadWebServer_Call{Call: _e.mock.On("ReloadWebServer")} -} - -func (_c *WebsiteRepo_ReloadWebServer_Call) Run(run func()) *WebsiteRepo_ReloadWebServer_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *WebsiteRepo_ReloadWebServer_Call) Return(err error) *WebsiteRepo_ReloadWebServer_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteRepo_ReloadWebServer_Call) RunAndReturn(run func() error) *WebsiteRepo_ReloadWebServer_Call { - _c.Call.Return(run) - return _c -} - -// RemoveFiles provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) RemoveFiles(name string, removePath bool) error { - ret := _mock.Called(name, removePath) - - if len(ret) == 0 { - panic("no return value specified for RemoveFiles") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string, bool) error); ok { - r0 = returnFunc(name, removePath) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteRepo_RemoveFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveFiles' -type WebsiteRepo_RemoveFiles_Call struct { - *mock.Call -} - -// RemoveFiles is a helper method to define mock.On call -// - name string -// - removePath bool -func (_e *WebsiteRepo_Expecter) RemoveFiles(name any, removePath any) *WebsiteRepo_RemoveFiles_Call { - return &WebsiteRepo_RemoveFiles_Call{Call: _e.mock.On("RemoveFiles", name, removePath)} -} - -func (_c *WebsiteRepo_RemoveFiles_Call) Run(run func(name string, removePath bool)) *WebsiteRepo_RemoveFiles_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 bool - if args[1] != nil { - arg1 = args[1].(bool) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *WebsiteRepo_RemoveFiles_Call) Return(err error) *WebsiteRepo_RemoveFiles_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteRepo_RemoveFiles_Call) RunAndReturn(run func(name string, removePath bool) error) *WebsiteRepo_RemoveFiles_Call { - _c.Call.Return(run) - return _c -} - -// ResetConfig provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) ResetConfig(id uint) error { - ret := _mock.Called(id) - - if len(ret) == 0 { - panic("no return value specified for ResetConfig") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint) error); ok { - r0 = returnFunc(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteRepo_ResetConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResetConfig' -type WebsiteRepo_ResetConfig_Call struct { - *mock.Call -} - -// ResetConfig is a helper method to define mock.On call -// - id uint -func (_e *WebsiteRepo_Expecter) ResetConfig(id any) *WebsiteRepo_ResetConfig_Call { - return &WebsiteRepo_ResetConfig_Call{Call: _e.mock.On("ResetConfig", id)} -} - -func (_c *WebsiteRepo_ResetConfig_Call) Run(run func(id uint)) *WebsiteRepo_ResetConfig_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteRepo_ResetConfig_Call) Return(err error) *WebsiteRepo_ResetConfig_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteRepo_ResetConfig_Call) RunAndReturn(run func(id uint) error) *WebsiteRepo_ResetConfig_Call { - _c.Call.Return(run) - return _c -} - -// SwitchType provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) SwitchType(req *request.WebsiteSwitchType) (*biz.Website, error) { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for SwitchType") - } - - var r0 *biz.Website - var r1 error - if returnFunc, ok := ret.Get(0).(func(*request.WebsiteSwitchType) (*biz.Website, error)); ok { - return returnFunc(req) - } - if returnFunc, ok := ret.Get(0).(func(*request.WebsiteSwitchType) *biz.Website); ok { - r0 = returnFunc(req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.Website) - } - } - if returnFunc, ok := ret.Get(1).(func(*request.WebsiteSwitchType) error); ok { - r1 = returnFunc(req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteRepo_SwitchType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SwitchType' -type WebsiteRepo_SwitchType_Call struct { - *mock.Call -} - -// SwitchType is a helper method to define mock.On call -// - req *request.WebsiteSwitchType -func (_e *WebsiteRepo_Expecter) SwitchType(req any) *WebsiteRepo_SwitchType_Call { - return &WebsiteRepo_SwitchType_Call{Call: _e.mock.On("SwitchType", req)} -} - -func (_c *WebsiteRepo_SwitchType_Call) Run(run func(req *request.WebsiteSwitchType)) *WebsiteRepo_SwitchType_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.WebsiteSwitchType - if args[0] != nil { - arg0 = args[0].(*request.WebsiteSwitchType) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteRepo_SwitchType_Call) Return(website *biz.Website, err error) *WebsiteRepo_SwitchType_Call { - _c.Call.Return(website, err) - return _c -} - -func (_c *WebsiteRepo_SwitchType_Call) RunAndReturn(run func(req *request.WebsiteSwitchType) (*biz.Website, error)) *WebsiteRepo_SwitchType_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) Update(req *request.WebsiteUpdate) (*biz.Website, error) { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 *biz.Website - var r1 error - if returnFunc, ok := ret.Get(0).(func(*request.WebsiteUpdate) (*biz.Website, error)); ok { - return returnFunc(req) - } - if returnFunc, ok := ret.Get(0).(func(*request.WebsiteUpdate) *biz.Website); ok { - r0 = returnFunc(req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*biz.Website) - } - } - if returnFunc, ok := ret.Get(1).(func(*request.WebsiteUpdate) error); ok { - r1 = returnFunc(req) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteRepo_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type WebsiteRepo_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - req *request.WebsiteUpdate -func (_e *WebsiteRepo_Expecter) Update(req any) *WebsiteRepo_Update_Call { - return &WebsiteRepo_Update_Call{Call: _e.mock.On("Update", req)} -} - -func (_c *WebsiteRepo_Update_Call) Run(run func(req *request.WebsiteUpdate)) *WebsiteRepo_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.WebsiteUpdate - if args[0] != nil { - arg0 = args[0].(*request.WebsiteUpdate) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteRepo_Update_Call) Return(website *biz.Website, err error) *WebsiteRepo_Update_Call { - _c.Call.Return(website, err) - return _c -} - -func (_c *WebsiteRepo_Update_Call) RunAndReturn(run func(req *request.WebsiteUpdate) (*biz.Website, error)) *WebsiteRepo_Update_Call { - _c.Call.Return(run) - return _c -} - -// UpdateCert provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) UpdateCert(req *request.WebsiteUpdateCert) error { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for UpdateCert") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*request.WebsiteUpdateCert) error); ok { - r0 = returnFunc(req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteRepo_UpdateCert_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateCert' -type WebsiteRepo_UpdateCert_Call struct { - *mock.Call -} - -// UpdateCert is a helper method to define mock.On call -// - req *request.WebsiteUpdateCert -func (_e *WebsiteRepo_Expecter) UpdateCert(req any) *WebsiteRepo_UpdateCert_Call { - return &WebsiteRepo_UpdateCert_Call{Call: _e.mock.On("UpdateCert", req)} -} - -func (_c *WebsiteRepo_UpdateCert_Call) Run(run func(req *request.WebsiteUpdateCert)) *WebsiteRepo_UpdateCert_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.WebsiteUpdateCert - if args[0] != nil { - arg0 = args[0].(*request.WebsiteUpdateCert) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteRepo_UpdateCert_Call) Return(err error) *WebsiteRepo_UpdateCert_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteRepo_UpdateCert_Call) RunAndReturn(run func(req *request.WebsiteUpdateCert) error) *WebsiteRepo_UpdateCert_Call { - _c.Call.Return(run) - return _c -} - -// UpdateDefaultConfig provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) UpdateDefaultConfig(req *request.WebsiteDefaultConfig) error { - ret := _mock.Called(req) - - if len(ret) == 0 { - panic("no return value specified for UpdateDefaultConfig") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(*request.WebsiteDefaultConfig) error); ok { - r0 = returnFunc(req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteRepo_UpdateDefaultConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDefaultConfig' -type WebsiteRepo_UpdateDefaultConfig_Call struct { - *mock.Call -} - -// UpdateDefaultConfig is a helper method to define mock.On call -// - req *request.WebsiteDefaultConfig -func (_e *WebsiteRepo_Expecter) UpdateDefaultConfig(req any) *WebsiteRepo_UpdateDefaultConfig_Call { - return &WebsiteRepo_UpdateDefaultConfig_Call{Call: _e.mock.On("UpdateDefaultConfig", req)} -} - -func (_c *WebsiteRepo_UpdateDefaultConfig_Call) Run(run func(req *request.WebsiteDefaultConfig)) *WebsiteRepo_UpdateDefaultConfig_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 *request.WebsiteDefaultConfig - if args[0] != nil { - arg0 = args[0].(*request.WebsiteDefaultConfig) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteRepo_UpdateDefaultConfig_Call) Return(err error) *WebsiteRepo_UpdateDefaultConfig_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteRepo_UpdateDefaultConfig_Call) RunAndReturn(run func(req *request.WebsiteDefaultConfig) error) *WebsiteRepo_UpdateDefaultConfig_Call { - _c.Call.Return(run) - return _c -} - -// UpdateExpireAt provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) UpdateExpireAt(id uint, expireAt *time.Time) error { - ret := _mock.Called(id, expireAt) - - if len(ret) == 0 { - panic("no return value specified for UpdateExpireAt") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, *time.Time) error); ok { - r0 = returnFunc(id, expireAt) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteRepo_UpdateExpireAt_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateExpireAt' -type WebsiteRepo_UpdateExpireAt_Call struct { - *mock.Call -} - -// UpdateExpireAt is a helper method to define mock.On call -// - id uint -// - expireAt *time.Time -func (_e *WebsiteRepo_Expecter) UpdateExpireAt(id any, expireAt any) *WebsiteRepo_UpdateExpireAt_Call { - return &WebsiteRepo_UpdateExpireAt_Call{Call: _e.mock.On("UpdateExpireAt", id, expireAt)} -} - -func (_c *WebsiteRepo_UpdateExpireAt_Call) Run(run func(id uint, expireAt *time.Time)) *WebsiteRepo_UpdateExpireAt_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 *time.Time - if args[1] != nil { - arg1 = args[1].(*time.Time) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *WebsiteRepo_UpdateExpireAt_Call) Return(err error) *WebsiteRepo_UpdateExpireAt_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteRepo_UpdateExpireAt_Call) RunAndReturn(run func(id uint, expireAt *time.Time) error) *WebsiteRepo_UpdateExpireAt_Call { - _c.Call.Return(run) - return _c -} - -// UpdateRemark provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) UpdateRemark(id uint, remark string) error { - ret := _mock.Called(id, remark) - - if len(ret) == 0 { - panic("no return value specified for UpdateRemark") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, string) error); ok { - r0 = returnFunc(id, remark) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteRepo_UpdateRemark_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRemark' -type WebsiteRepo_UpdateRemark_Call struct { - *mock.Call -} - -// UpdateRemark is a helper method to define mock.On call -// - id uint -// - remark string -func (_e *WebsiteRepo_Expecter) UpdateRemark(id any, remark any) *WebsiteRepo_UpdateRemark_Call { - return &WebsiteRepo_UpdateRemark_Call{Call: _e.mock.On("UpdateRemark", id, remark)} -} - -func (_c *WebsiteRepo_UpdateRemark_Call) Run(run func(id uint, remark string)) *WebsiteRepo_UpdateRemark_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *WebsiteRepo_UpdateRemark_Call) Return(err error) *WebsiteRepo_UpdateRemark_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteRepo_UpdateRemark_Call) RunAndReturn(run func(id uint, remark string) error) *WebsiteRepo_UpdateRemark_Call { - _c.Call.Return(run) - return _c -} - -// UpdateStatus provides a mock function for the type WebsiteRepo -func (_mock *WebsiteRepo) UpdateStatus(id uint, status bool) error { - ret := _mock.Called(id, status) - - if len(ret) == 0 { - panic("no return value specified for UpdateStatus") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(uint, bool) error); ok { - r0 = returnFunc(id, status) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteRepo_UpdateStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateStatus' -type WebsiteRepo_UpdateStatus_Call struct { - *mock.Call -} - -// UpdateStatus is a helper method to define mock.On call -// - id uint -// - status bool -func (_e *WebsiteRepo_Expecter) UpdateStatus(id any, status any) *WebsiteRepo_UpdateStatus_Call { - return &WebsiteRepo_UpdateStatus_Call{Call: _e.mock.On("UpdateStatus", id, status)} -} - -func (_c *WebsiteRepo_UpdateStatus_Call) Run(run func(id uint, status bool)) *WebsiteRepo_UpdateStatus_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 uint - if args[0] != nil { - arg0 = args[0].(uint) - } - var arg1 bool - if args[1] != nil { - arg1 = args[1].(bool) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *WebsiteRepo_UpdateStatus_Call) Return(err error) *WebsiteRepo_UpdateStatus_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteRepo_UpdateStatus_Call) RunAndReturn(run func(id uint, status bool) error) *WebsiteRepo_UpdateStatus_Call { - _c.Call.Return(run) - return _c -} diff --git a/mocks/biz/WebsiteStatRepo.go b/mocks/biz/WebsiteStatRepo.go deleted file mode 100644 index c1d6b5013..000000000 --- a/mocks/biz/WebsiteStatRepo.go +++ /dev/null @@ -1,1721 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery -// template: testify - -package biz - -import ( - "time" - - "github.com/acepanel/panel/v3/internal/biz" - mock "github.com/stretchr/testify/mock" -) - -// NewWebsiteStatRepo creates a new instance of WebsiteStatRepo. 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 NewWebsiteStatRepo(t interface { - mock.TestingT - Cleanup(func()) -}) *WebsiteStatRepo { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - - mock := &WebsiteStatRepo{} - mock.Mock.Test(t) - - t.Cleanup(func() { - if helper, ok := t.(interface{ Helper() }); ok { - helper.Helper() - } - mock.AssertExpectations(t) - }) - - return mock -} - -// WebsiteStatRepo is an autogenerated mock type for the WebsiteStatRepo type -type WebsiteStatRepo struct { - mock.Mock -} - -type WebsiteStatRepo_Expecter struct { - mock *mock.Mock -} - -func (_m *WebsiteStatRepo) EXPECT() *WebsiteStatRepo_Expecter { - return &WebsiteStatRepo_Expecter{mock: &_m.Mock} -} - -// Clear provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) Clear() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for Clear") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_Clear_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Clear' -type WebsiteStatRepo_Clear_Call struct { - *mock.Call -} - -// Clear is a helper method to define mock.On call -func (_e *WebsiteStatRepo_Expecter) Clear() *WebsiteStatRepo_Clear_Call { - return &WebsiteStatRepo_Clear_Call{Call: _e.mock.On("Clear")} -} - -func (_c *WebsiteStatRepo_Clear_Call) Run(run func()) *WebsiteStatRepo_Clear_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *WebsiteStatRepo_Clear_Call) Return(err error) *WebsiteStatRepo_Clear_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_Clear_Call) RunAndReturn(run func() error) *WebsiteStatRepo_Clear_Call { - _c.Call.Return(run) - return _c -} - -// ClearBefore provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) ClearBefore(date string) error { - ret := _mock.Called(date) - - if len(ret) == 0 { - panic("no return value specified for ClearBefore") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(date) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_ClearBefore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearBefore' -type WebsiteStatRepo_ClearBefore_Call struct { - *mock.Call -} - -// ClearBefore is a helper method to define mock.On call -// - date string -func (_e *WebsiteStatRepo_Expecter) ClearBefore(date any) *WebsiteStatRepo_ClearBefore_Call { - return &WebsiteStatRepo_ClearBefore_Call{Call: _e.mock.On("ClearBefore", date)} -} - -func (_c *WebsiteStatRepo_ClearBefore_Call) Run(run func(date string)) *WebsiteStatRepo_ClearBefore_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_ClearBefore_Call) Return(err error) *WebsiteStatRepo_ClearBefore_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_ClearBefore_Call) RunAndReturn(run func(date string) error) *WebsiteStatRepo_ClearBefore_Call { - _c.Call.Return(run) - return _c -} - -// ClearClientsBefore provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) ClearClientsBefore(date string) error { - ret := _mock.Called(date) - - if len(ret) == 0 { - panic("no return value specified for ClearClientsBefore") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(date) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_ClearClientsBefore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearClientsBefore' -type WebsiteStatRepo_ClearClientsBefore_Call struct { - *mock.Call -} - -// ClearClientsBefore is a helper method to define mock.On call -// - date string -func (_e *WebsiteStatRepo_Expecter) ClearClientsBefore(date any) *WebsiteStatRepo_ClearClientsBefore_Call { - return &WebsiteStatRepo_ClearClientsBefore_Call{Call: _e.mock.On("ClearClientsBefore", date)} -} - -func (_c *WebsiteStatRepo_ClearClientsBefore_Call) Run(run func(date string)) *WebsiteStatRepo_ClearClientsBefore_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_ClearClientsBefore_Call) Return(err error) *WebsiteStatRepo_ClearClientsBefore_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_ClearClientsBefore_Call) RunAndReturn(run func(date string) error) *WebsiteStatRepo_ClearClientsBefore_Call { - _c.Call.Return(run) - return _c -} - -// ClearErrorsBefore provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) ClearErrorsBefore(t time.Time) error { - ret := _mock.Called(t) - - if len(ret) == 0 { - panic("no return value specified for ClearErrorsBefore") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(time.Time) error); ok { - r0 = returnFunc(t) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_ClearErrorsBefore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearErrorsBefore' -type WebsiteStatRepo_ClearErrorsBefore_Call struct { - *mock.Call -} - -// ClearErrorsBefore is a helper method to define mock.On call -// - t time.Time -func (_e *WebsiteStatRepo_Expecter) ClearErrorsBefore(t any) *WebsiteStatRepo_ClearErrorsBefore_Call { - return &WebsiteStatRepo_ClearErrorsBefore_Call{Call: _e.mock.On("ClearErrorsBefore", t)} -} - -func (_c *WebsiteStatRepo_ClearErrorsBefore_Call) Run(run func(t time.Time)) *WebsiteStatRepo_ClearErrorsBefore_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 time.Time - if args[0] != nil { - arg0 = args[0].(time.Time) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_ClearErrorsBefore_Call) Return(err error) *WebsiteStatRepo_ClearErrorsBefore_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_ClearErrorsBefore_Call) RunAndReturn(run func(t time.Time) error) *WebsiteStatRepo_ClearErrorsBefore_Call { - _c.Call.Return(run) - return _c -} - -// ClearIPsBefore provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) ClearIPsBefore(date string) error { - ret := _mock.Called(date) - - if len(ret) == 0 { - panic("no return value specified for ClearIPsBefore") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(date) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_ClearIPsBefore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearIPsBefore' -type WebsiteStatRepo_ClearIPsBefore_Call struct { - *mock.Call -} - -// ClearIPsBefore is a helper method to define mock.On call -// - date string -func (_e *WebsiteStatRepo_Expecter) ClearIPsBefore(date any) *WebsiteStatRepo_ClearIPsBefore_Call { - return &WebsiteStatRepo_ClearIPsBefore_Call{Call: _e.mock.On("ClearIPsBefore", date)} -} - -func (_c *WebsiteStatRepo_ClearIPsBefore_Call) Run(run func(date string)) *WebsiteStatRepo_ClearIPsBefore_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_ClearIPsBefore_Call) Return(err error) *WebsiteStatRepo_ClearIPsBefore_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_ClearIPsBefore_Call) RunAndReturn(run func(date string) error) *WebsiteStatRepo_ClearIPsBefore_Call { - _c.Call.Return(run) - return _c -} - -// ClearSpidersBefore provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) ClearSpidersBefore(date string) error { - ret := _mock.Called(date) - - if len(ret) == 0 { - panic("no return value specified for ClearSpidersBefore") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(date) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_ClearSpidersBefore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearSpidersBefore' -type WebsiteStatRepo_ClearSpidersBefore_Call struct { - *mock.Call -} - -// ClearSpidersBefore is a helper method to define mock.On call -// - date string -func (_e *WebsiteStatRepo_Expecter) ClearSpidersBefore(date any) *WebsiteStatRepo_ClearSpidersBefore_Call { - return &WebsiteStatRepo_ClearSpidersBefore_Call{Call: _e.mock.On("ClearSpidersBefore", date)} -} - -func (_c *WebsiteStatRepo_ClearSpidersBefore_Call) Run(run func(date string)) *WebsiteStatRepo_ClearSpidersBefore_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_ClearSpidersBefore_Call) Return(err error) *WebsiteStatRepo_ClearSpidersBefore_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_ClearSpidersBefore_Call) RunAndReturn(run func(date string) error) *WebsiteStatRepo_ClearSpidersBefore_Call { - _c.Call.Return(run) - return _c -} - -// ClearURIsBefore provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) ClearURIsBefore(date string) error { - ret := _mock.Called(date) - - if len(ret) == 0 { - panic("no return value specified for ClearURIsBefore") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(date) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_ClearURIsBefore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearURIsBefore' -type WebsiteStatRepo_ClearURIsBefore_Call struct { - *mock.Call -} - -// ClearURIsBefore is a helper method to define mock.On call -// - date string -func (_e *WebsiteStatRepo_Expecter) ClearURIsBefore(date any) *WebsiteStatRepo_ClearURIsBefore_Call { - return &WebsiteStatRepo_ClearURIsBefore_Call{Call: _e.mock.On("ClearURIsBefore", date)} -} - -func (_c *WebsiteStatRepo_ClearURIsBefore_Call) Run(run func(date string)) *WebsiteStatRepo_ClearURIsBefore_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_ClearURIsBefore_Call) Return(err error) *WebsiteStatRepo_ClearURIsBefore_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_ClearURIsBefore_Call) RunAndReturn(run func(date string) error) *WebsiteStatRepo_ClearURIsBefore_Call { - _c.Call.Return(run) - return _c -} - -// DailySeries provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) DailySeries(start string, end string, sites []string) ([]*biz.WebsiteStatSeries, error) { - ret := _mock.Called(start, end, sites) - - if len(ret) == 0 { - panic("no return value specified for DailySeries") - } - - var r0 []*biz.WebsiteStatSeries - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, []string) ([]*biz.WebsiteStatSeries, error)); ok { - return returnFunc(start, end, sites) - } - if returnFunc, ok := ret.Get(0).(func(string, string, []string) []*biz.WebsiteStatSeries); ok { - r0 = returnFunc(start, end, sites) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteStatSeries) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, []string) error); ok { - r1 = returnFunc(start, end, sites) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteStatRepo_DailySeries_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DailySeries' -type WebsiteStatRepo_DailySeries_Call struct { - *mock.Call -} - -// DailySeries is a helper method to define mock.On call -// - start string -// - end string -// - sites []string -func (_e *WebsiteStatRepo_Expecter) DailySeries(start any, end any, sites any) *WebsiteStatRepo_DailySeries_Call { - return &WebsiteStatRepo_DailySeries_Call{Call: _e.mock.On("DailySeries", start, end, sites)} -} - -func (_c *WebsiteStatRepo_DailySeries_Call) Run(run func(start string, end string, sites []string)) *WebsiteStatRepo_DailySeries_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []string - if args[2] != nil { - arg2 = args[2].([]string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_DailySeries_Call) Return(websiteStatSeriess []*biz.WebsiteStatSeries, err error) *WebsiteStatRepo_DailySeries_Call { - _c.Call.Return(websiteStatSeriess, err) - return _c -} - -func (_c *WebsiteStatRepo_DailySeries_Call) RunAndReturn(run func(start string, end string, sites []string) ([]*biz.WebsiteStatSeries, error)) *WebsiteStatRepo_DailySeries_Call { - _c.Call.Return(run) - return _c -} - -// DeleteBySite provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) DeleteBySite(site string) error { - ret := _mock.Called(site) - - if len(ret) == 0 { - panic("no return value specified for DeleteBySite") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func(string) error); ok { - r0 = returnFunc(site) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_DeleteBySite_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteBySite' -type WebsiteStatRepo_DeleteBySite_Call struct { - *mock.Call -} - -// DeleteBySite is a helper method to define mock.On call -// - site string -func (_e *WebsiteStatRepo_Expecter) DeleteBySite(site any) *WebsiteStatRepo_DeleteBySite_Call { - return &WebsiteStatRepo_DeleteBySite_Call{Call: _e.mock.On("DeleteBySite", site)} -} - -func (_c *WebsiteStatRepo_DeleteBySite_Call) Run(run func(site string)) *WebsiteStatRepo_DeleteBySite_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_DeleteBySite_Call) Return(err error) *WebsiteStatRepo_DeleteBySite_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_DeleteBySite_Call) RunAndReturn(run func(site string) error) *WebsiteStatRepo_DeleteBySite_Call { - _c.Call.Return(run) - return _c -} - -// HourlySeries provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) HourlySeries(date string, sites []string) ([]*biz.WebsiteStatSeries, error) { - ret := _mock.Called(date, sites) - - if len(ret) == 0 { - panic("no return value specified for HourlySeries") - } - - var r0 []*biz.WebsiteStatSeries - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, []string) ([]*biz.WebsiteStatSeries, error)); ok { - return returnFunc(date, sites) - } - if returnFunc, ok := ret.Get(0).(func(string, []string) []*biz.WebsiteStatSeries); ok { - r0 = returnFunc(date, sites) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteStatSeries) - } - } - if returnFunc, ok := ret.Get(1).(func(string, []string) error); ok { - r1 = returnFunc(date, sites) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteStatRepo_HourlySeries_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HourlySeries' -type WebsiteStatRepo_HourlySeries_Call struct { - *mock.Call -} - -// HourlySeries is a helper method to define mock.On call -// - date string -// - sites []string -func (_e *WebsiteStatRepo_Expecter) HourlySeries(date any, sites any) *WebsiteStatRepo_HourlySeries_Call { - return &WebsiteStatRepo_HourlySeries_Call{Call: _e.mock.On("HourlySeries", date, sites)} -} - -func (_c *WebsiteStatRepo_HourlySeries_Call) Run(run func(date string, sites []string)) *WebsiteStatRepo_HourlySeries_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 []string - if args[1] != nil { - arg1 = args[1].([]string) - } - run( - arg0, - arg1, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_HourlySeries_Call) Return(websiteStatSeriess []*biz.WebsiteStatSeries, err error) *WebsiteStatRepo_HourlySeries_Call { - _c.Call.Return(websiteStatSeriess, err) - return _c -} - -func (_c *WebsiteStatRepo_HourlySeries_Call) RunAndReturn(run func(date string, sites []string) ([]*biz.WebsiteStatSeries, error)) *WebsiteStatRepo_HourlySeries_Call { - _c.Call.Return(run) - return _c -} - -// InsertErrors provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) InsertErrors(errors []*biz.WebsiteErrorLog) error { - ret := _mock.Called(errors) - - if len(ret) == 0 { - panic("no return value specified for InsertErrors") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func([]*biz.WebsiteErrorLog) error); ok { - r0 = returnFunc(errors) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_InsertErrors_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'InsertErrors' -type WebsiteStatRepo_InsertErrors_Call struct { - *mock.Call -} - -// InsertErrors is a helper method to define mock.On call -// - errors []*biz.WebsiteErrorLog -func (_e *WebsiteStatRepo_Expecter) InsertErrors(errors any) *WebsiteStatRepo_InsertErrors_Call { - return &WebsiteStatRepo_InsertErrors_Call{Call: _e.mock.On("InsertErrors", errors)} -} - -func (_c *WebsiteStatRepo_InsertErrors_Call) Run(run func(errors []*biz.WebsiteErrorLog)) *WebsiteStatRepo_InsertErrors_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []*biz.WebsiteErrorLog - if args[0] != nil { - arg0 = args[0].([]*biz.WebsiteErrorLog) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_InsertErrors_Call) Return(err error) *WebsiteStatRepo_InsertErrors_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_InsertErrors_Call) RunAndReturn(run func(errors []*biz.WebsiteErrorLog) error) *WebsiteStatRepo_InsertErrors_Call { - _c.Call.Return(run) - return _c -} - -// ListByDateRange provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) ListByDateRange(start string, end string, sites []string) ([]*biz.WebsiteStat, error) { - ret := _mock.Called(start, end, sites) - - if len(ret) == 0 { - panic("no return value specified for ListByDateRange") - } - - var r0 []*biz.WebsiteStat - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, []string) ([]*biz.WebsiteStat, error)); ok { - return returnFunc(start, end, sites) - } - if returnFunc, ok := ret.Get(0).(func(string, string, []string) []*biz.WebsiteStat); ok { - r0 = returnFunc(start, end, sites) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteStat) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, []string) error); ok { - r1 = returnFunc(start, end, sites) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteStatRepo_ListByDateRange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListByDateRange' -type WebsiteStatRepo_ListByDateRange_Call struct { - *mock.Call -} - -// ListByDateRange is a helper method to define mock.On call -// - start string -// - end string -// - sites []string -func (_e *WebsiteStatRepo_Expecter) ListByDateRange(start any, end any, sites any) *WebsiteStatRepo_ListByDateRange_Call { - return &WebsiteStatRepo_ListByDateRange_Call{Call: _e.mock.On("ListByDateRange", start, end, sites)} -} - -func (_c *WebsiteStatRepo_ListByDateRange_Call) Run(run func(start string, end string, sites []string)) *WebsiteStatRepo_ListByDateRange_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []string - if args[2] != nil { - arg2 = args[2].([]string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_ListByDateRange_Call) Return(websiteStats []*biz.WebsiteStat, err error) *WebsiteStatRepo_ListByDateRange_Call { - _c.Call.Return(websiteStats, err) - return _c -} - -func (_c *WebsiteStatRepo_ListByDateRange_Call) RunAndReturn(run func(start string, end string, sites []string) ([]*biz.WebsiteStat, error)) *WebsiteStatRepo_ListByDateRange_Call { - _c.Call.Return(run) - return _c -} - -// ListErrors provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) ListErrors(start string, end string, sites []string, status int, page uint, limit uint) ([]*biz.WebsiteErrorLog, uint, error) { - ret := _mock.Called(start, end, sites, status, page, limit) - - if len(ret) == 0 { - panic("no return value specified for ListErrors") - } - - var r0 []*biz.WebsiteErrorLog - var r1 uint - var r2 error - if returnFunc, ok := ret.Get(0).(func(string, string, []string, int, uint, uint) ([]*biz.WebsiteErrorLog, uint, error)); ok { - return returnFunc(start, end, sites, status, page, limit) - } - if returnFunc, ok := ret.Get(0).(func(string, string, []string, int, uint, uint) []*biz.WebsiteErrorLog); ok { - r0 = returnFunc(start, end, sites, status, page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteErrorLog) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, []string, int, uint, uint) uint); ok { - r1 = returnFunc(start, end, sites, status, page, limit) - } else { - r1 = ret.Get(1).(uint) - } - if returnFunc, ok := ret.Get(2).(func(string, string, []string, int, uint, uint) error); ok { - r2 = returnFunc(start, end, sites, status, page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// WebsiteStatRepo_ListErrors_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListErrors' -type WebsiteStatRepo_ListErrors_Call struct { - *mock.Call -} - -// ListErrors is a helper method to define mock.On call -// - start string -// - end string -// - sites []string -// - status int -// - page uint -// - limit uint -func (_e *WebsiteStatRepo_Expecter) ListErrors(start any, end any, sites any, status any, page any, limit any) *WebsiteStatRepo_ListErrors_Call { - return &WebsiteStatRepo_ListErrors_Call{Call: _e.mock.On("ListErrors", start, end, sites, status, page, limit)} -} - -func (_c *WebsiteStatRepo_ListErrors_Call) Run(run func(start string, end string, sites []string, status int, page uint, limit uint)) *WebsiteStatRepo_ListErrors_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []string - if args[2] != nil { - arg2 = args[2].([]string) - } - var arg3 int - if args[3] != nil { - arg3 = args[3].(int) - } - var arg4 uint - if args[4] != nil { - arg4 = args[4].(uint) - } - var arg5 uint - if args[5] != nil { - arg5 = args[5].(uint) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_ListErrors_Call) Return(websiteErrorLogs []*biz.WebsiteErrorLog, v uint, err error) *WebsiteStatRepo_ListErrors_Call { - _c.Call.Return(websiteErrorLogs, v, err) - return _c -} - -func (_c *WebsiteStatRepo_ListErrors_Call) RunAndReturn(run func(start string, end string, sites []string, status int, page uint, limit uint) ([]*biz.WebsiteErrorLog, uint, error)) *WebsiteStatRepo_ListErrors_Call { - _c.Call.Return(run) - return _c -} - -// ListSiteStats provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) ListSiteStats(start string, end string, sites []string) ([]*biz.WebsiteStatSiteItem, error) { - ret := _mock.Called(start, end, sites) - - if len(ret) == 0 { - panic("no return value specified for ListSiteStats") - } - - var r0 []*biz.WebsiteStatSiteItem - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, []string) ([]*biz.WebsiteStatSiteItem, error)); ok { - return returnFunc(start, end, sites) - } - if returnFunc, ok := ret.Get(0).(func(string, string, []string) []*biz.WebsiteStatSiteItem); ok { - r0 = returnFunc(start, end, sites) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteStatSiteItem) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, []string) error); ok { - r1 = returnFunc(start, end, sites) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteStatRepo_ListSiteStats_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListSiteStats' -type WebsiteStatRepo_ListSiteStats_Call struct { - *mock.Call -} - -// ListSiteStats is a helper method to define mock.On call -// - start string -// - end string -// - sites []string -func (_e *WebsiteStatRepo_Expecter) ListSiteStats(start any, end any, sites any) *WebsiteStatRepo_ListSiteStats_Call { - return &WebsiteStatRepo_ListSiteStats_Call{Call: _e.mock.On("ListSiteStats", start, end, sites)} -} - -func (_c *WebsiteStatRepo_ListSiteStats_Call) Run(run func(start string, end string, sites []string)) *WebsiteStatRepo_ListSiteStats_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []string - if args[2] != nil { - arg2 = args[2].([]string) - } - run( - arg0, - arg1, - arg2, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_ListSiteStats_Call) Return(websiteStatSiteItems []*biz.WebsiteStatSiteItem, err error) *WebsiteStatRepo_ListSiteStats_Call { - _c.Call.Return(websiteStatSiteItems, err) - return _c -} - -func (_c *WebsiteStatRepo_ListSiteStats_Call) RunAndReturn(run func(start string, end string, sites []string) ([]*biz.WebsiteStatSiteItem, error)) *WebsiteStatRepo_ListSiteStats_Call { - _c.Call.Return(run) - return _c -} - -// TopClients provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) TopClients(start string, end string, sites []string, limit uint) ([]*biz.WebsiteStatClientRank, error) { - ret := _mock.Called(start, end, sites, limit) - - if len(ret) == 0 { - panic("no return value specified for TopClients") - } - - var r0 []*biz.WebsiteStatClientRank - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, []string, uint) ([]*biz.WebsiteStatClientRank, error)); ok { - return returnFunc(start, end, sites, limit) - } - if returnFunc, ok := ret.Get(0).(func(string, string, []string, uint) []*biz.WebsiteStatClientRank); ok { - r0 = returnFunc(start, end, sites, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteStatClientRank) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, []string, uint) error); ok { - r1 = returnFunc(start, end, sites, limit) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteStatRepo_TopClients_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TopClients' -type WebsiteStatRepo_TopClients_Call struct { - *mock.Call -} - -// TopClients is a helper method to define mock.On call -// - start string -// - end string -// - sites []string -// - limit uint -func (_e *WebsiteStatRepo_Expecter) TopClients(start any, end any, sites any, limit any) *WebsiteStatRepo_TopClients_Call { - return &WebsiteStatRepo_TopClients_Call{Call: _e.mock.On("TopClients", start, end, sites, limit)} -} - -func (_c *WebsiteStatRepo_TopClients_Call) Run(run func(start string, end string, sites []string, limit uint)) *WebsiteStatRepo_TopClients_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []string - if args[2] != nil { - arg2 = args[2].([]string) - } - var arg3 uint - if args[3] != nil { - arg3 = args[3].(uint) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_TopClients_Call) Return(websiteStatClientRanks []*biz.WebsiteStatClientRank, err error) *WebsiteStatRepo_TopClients_Call { - _c.Call.Return(websiteStatClientRanks, err) - return _c -} - -func (_c *WebsiteStatRepo_TopClients_Call) RunAndReturn(run func(start string, end string, sites []string, limit uint) ([]*biz.WebsiteStatClientRank, error)) *WebsiteStatRepo_TopClients_Call { - _c.Call.Return(run) - return _c -} - -// TopGeos provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) TopGeos(start string, end string, sites []string, groupBy string, country string, limit uint) ([]*biz.WebsiteStatGeoRank, error) { - ret := _mock.Called(start, end, sites, groupBy, country, limit) - - if len(ret) == 0 { - panic("no return value specified for TopGeos") - } - - var r0 []*biz.WebsiteStatGeoRank - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, []string, string, string, uint) ([]*biz.WebsiteStatGeoRank, error)); ok { - return returnFunc(start, end, sites, groupBy, country, limit) - } - if returnFunc, ok := ret.Get(0).(func(string, string, []string, string, string, uint) []*biz.WebsiteStatGeoRank); ok { - r0 = returnFunc(start, end, sites, groupBy, country, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteStatGeoRank) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, []string, string, string, uint) error); ok { - r1 = returnFunc(start, end, sites, groupBy, country, limit) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteStatRepo_TopGeos_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TopGeos' -type WebsiteStatRepo_TopGeos_Call struct { - *mock.Call -} - -// TopGeos is a helper method to define mock.On call -// - start string -// - end string -// - sites []string -// - groupBy string -// - country string -// - limit uint -func (_e *WebsiteStatRepo_Expecter) TopGeos(start any, end any, sites any, groupBy any, country any, limit any) *WebsiteStatRepo_TopGeos_Call { - return &WebsiteStatRepo_TopGeos_Call{Call: _e.mock.On("TopGeos", start, end, sites, groupBy, country, limit)} -} - -func (_c *WebsiteStatRepo_TopGeos_Call) Run(run func(start string, end string, sites []string, groupBy string, country string, limit uint)) *WebsiteStatRepo_TopGeos_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []string - if args[2] != nil { - arg2 = args[2].([]string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - var arg4 string - if args[4] != nil { - arg4 = args[4].(string) - } - var arg5 uint - if args[5] != nil { - arg5 = args[5].(uint) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_TopGeos_Call) Return(websiteStatGeoRanks []*biz.WebsiteStatGeoRank, err error) *WebsiteStatRepo_TopGeos_Call { - _c.Call.Return(websiteStatGeoRanks, err) - return _c -} - -func (_c *WebsiteStatRepo_TopGeos_Call) RunAndReturn(run func(start string, end string, sites []string, groupBy string, country string, limit uint) ([]*biz.WebsiteStatGeoRank, error)) *WebsiteStatRepo_TopGeos_Call { - _c.Call.Return(run) - return _c -} - -// TopIPs provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) TopIPs(start string, end string, sites []string, page uint, limit uint) ([]*biz.WebsiteStatIPRank, uint, error) { - ret := _mock.Called(start, end, sites, page, limit) - - if len(ret) == 0 { - panic("no return value specified for TopIPs") - } - - var r0 []*biz.WebsiteStatIPRank - var r1 uint - var r2 error - if returnFunc, ok := ret.Get(0).(func(string, string, []string, uint, uint) ([]*biz.WebsiteStatIPRank, uint, error)); ok { - return returnFunc(start, end, sites, page, limit) - } - if returnFunc, ok := ret.Get(0).(func(string, string, []string, uint, uint) []*biz.WebsiteStatIPRank); ok { - r0 = returnFunc(start, end, sites, page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteStatIPRank) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, []string, uint, uint) uint); ok { - r1 = returnFunc(start, end, sites, page, limit) - } else { - r1 = ret.Get(1).(uint) - } - if returnFunc, ok := ret.Get(2).(func(string, string, []string, uint, uint) error); ok { - r2 = returnFunc(start, end, sites, page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// WebsiteStatRepo_TopIPs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TopIPs' -type WebsiteStatRepo_TopIPs_Call struct { - *mock.Call -} - -// TopIPs is a helper method to define mock.On call -// - start string -// - end string -// - sites []string -// - page uint -// - limit uint -func (_e *WebsiteStatRepo_Expecter) TopIPs(start any, end any, sites any, page any, limit any) *WebsiteStatRepo_TopIPs_Call { - return &WebsiteStatRepo_TopIPs_Call{Call: _e.mock.On("TopIPs", start, end, sites, page, limit)} -} - -func (_c *WebsiteStatRepo_TopIPs_Call) Run(run func(start string, end string, sites []string, page uint, limit uint)) *WebsiteStatRepo_TopIPs_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []string - if args[2] != nil { - arg2 = args[2].([]string) - } - var arg3 uint - if args[3] != nil { - arg3 = args[3].(uint) - } - var arg4 uint - if args[4] != nil { - arg4 = args[4].(uint) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_TopIPs_Call) Return(websiteStatIPRanks []*biz.WebsiteStatIPRank, v uint, err error) *WebsiteStatRepo_TopIPs_Call { - _c.Call.Return(websiteStatIPRanks, v, err) - return _c -} - -func (_c *WebsiteStatRepo_TopIPs_Call) RunAndReturn(run func(start string, end string, sites []string, page uint, limit uint) ([]*biz.WebsiteStatIPRank, uint, error)) *WebsiteStatRepo_TopIPs_Call { - _c.Call.Return(run) - return _c -} - -// TopSlowURIs provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) TopSlowURIs(start string, end string, sites []string, threshold uint, page uint, limit uint) ([]*biz.WebsiteStatURIRank, uint, error) { - ret := _mock.Called(start, end, sites, threshold, page, limit) - - if len(ret) == 0 { - panic("no return value specified for TopSlowURIs") - } - - var r0 []*biz.WebsiteStatURIRank - var r1 uint - var r2 error - if returnFunc, ok := ret.Get(0).(func(string, string, []string, uint, uint, uint) ([]*biz.WebsiteStatURIRank, uint, error)); ok { - return returnFunc(start, end, sites, threshold, page, limit) - } - if returnFunc, ok := ret.Get(0).(func(string, string, []string, uint, uint, uint) []*biz.WebsiteStatURIRank); ok { - r0 = returnFunc(start, end, sites, threshold, page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteStatURIRank) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, []string, uint, uint, uint) uint); ok { - r1 = returnFunc(start, end, sites, threshold, page, limit) - } else { - r1 = ret.Get(1).(uint) - } - if returnFunc, ok := ret.Get(2).(func(string, string, []string, uint, uint, uint) error); ok { - r2 = returnFunc(start, end, sites, threshold, page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// WebsiteStatRepo_TopSlowURIs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TopSlowURIs' -type WebsiteStatRepo_TopSlowURIs_Call struct { - *mock.Call -} - -// TopSlowURIs is a helper method to define mock.On call -// - start string -// - end string -// - sites []string -// - threshold uint -// - page uint -// - limit uint -func (_e *WebsiteStatRepo_Expecter) TopSlowURIs(start any, end any, sites any, threshold any, page any, limit any) *WebsiteStatRepo_TopSlowURIs_Call { - return &WebsiteStatRepo_TopSlowURIs_Call{Call: _e.mock.On("TopSlowURIs", start, end, sites, threshold, page, limit)} -} - -func (_c *WebsiteStatRepo_TopSlowURIs_Call) Run(run func(start string, end string, sites []string, threshold uint, page uint, limit uint)) *WebsiteStatRepo_TopSlowURIs_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []string - if args[2] != nil { - arg2 = args[2].([]string) - } - var arg3 uint - if args[3] != nil { - arg3 = args[3].(uint) - } - var arg4 uint - if args[4] != nil { - arg4 = args[4].(uint) - } - var arg5 uint - if args[5] != nil { - arg5 = args[5].(uint) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_TopSlowURIs_Call) Return(websiteStatURIRanks []*biz.WebsiteStatURIRank, v uint, err error) *WebsiteStatRepo_TopSlowURIs_Call { - _c.Call.Return(websiteStatURIRanks, v, err) - return _c -} - -func (_c *WebsiteStatRepo_TopSlowURIs_Call) RunAndReturn(run func(start string, end string, sites []string, threshold uint, page uint, limit uint) ([]*biz.WebsiteStatURIRank, uint, error)) *WebsiteStatRepo_TopSlowURIs_Call { - _c.Call.Return(run) - return _c -} - -// TopSpiders provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) TopSpiders(start string, end string, sites []string, limit uint) ([]*biz.WebsiteStatSpiderRank, error) { - ret := _mock.Called(start, end, sites, limit) - - if len(ret) == 0 { - panic("no return value specified for TopSpiders") - } - - var r0 []*biz.WebsiteStatSpiderRank - var r1 error - if returnFunc, ok := ret.Get(0).(func(string, string, []string, uint) ([]*biz.WebsiteStatSpiderRank, error)); ok { - return returnFunc(start, end, sites, limit) - } - if returnFunc, ok := ret.Get(0).(func(string, string, []string, uint) []*biz.WebsiteStatSpiderRank); ok { - r0 = returnFunc(start, end, sites, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteStatSpiderRank) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, []string, uint) error); ok { - r1 = returnFunc(start, end, sites, limit) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// WebsiteStatRepo_TopSpiders_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TopSpiders' -type WebsiteStatRepo_TopSpiders_Call struct { - *mock.Call -} - -// TopSpiders is a helper method to define mock.On call -// - start string -// - end string -// - sites []string -// - limit uint -func (_e *WebsiteStatRepo_Expecter) TopSpiders(start any, end any, sites any, limit any) *WebsiteStatRepo_TopSpiders_Call { - return &WebsiteStatRepo_TopSpiders_Call{Call: _e.mock.On("TopSpiders", start, end, sites, limit)} -} - -func (_c *WebsiteStatRepo_TopSpiders_Call) Run(run func(start string, end string, sites []string, limit uint)) *WebsiteStatRepo_TopSpiders_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []string - if args[2] != nil { - arg2 = args[2].([]string) - } - var arg3 uint - if args[3] != nil { - arg3 = args[3].(uint) - } - run( - arg0, - arg1, - arg2, - arg3, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_TopSpiders_Call) Return(websiteStatSpiderRanks []*biz.WebsiteStatSpiderRank, err error) *WebsiteStatRepo_TopSpiders_Call { - _c.Call.Return(websiteStatSpiderRanks, err) - return _c -} - -func (_c *WebsiteStatRepo_TopSpiders_Call) RunAndReturn(run func(start string, end string, sites []string, limit uint) ([]*biz.WebsiteStatSpiderRank, error)) *WebsiteStatRepo_TopSpiders_Call { - _c.Call.Return(run) - return _c -} - -// TopURIs provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) TopURIs(start string, end string, sites []string, page uint, limit uint) ([]*biz.WebsiteStatURIRank, uint, error) { - ret := _mock.Called(start, end, sites, page, limit) - - if len(ret) == 0 { - panic("no return value specified for TopURIs") - } - - var r0 []*biz.WebsiteStatURIRank - var r1 uint - var r2 error - if returnFunc, ok := ret.Get(0).(func(string, string, []string, uint, uint) ([]*biz.WebsiteStatURIRank, uint, error)); ok { - return returnFunc(start, end, sites, page, limit) - } - if returnFunc, ok := ret.Get(0).(func(string, string, []string, uint, uint) []*biz.WebsiteStatURIRank); ok { - r0 = returnFunc(start, end, sites, page, limit) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*biz.WebsiteStatURIRank) - } - } - if returnFunc, ok := ret.Get(1).(func(string, string, []string, uint, uint) uint); ok { - r1 = returnFunc(start, end, sites, page, limit) - } else { - r1 = ret.Get(1).(uint) - } - if returnFunc, ok := ret.Get(2).(func(string, string, []string, uint, uint) error); ok { - r2 = returnFunc(start, end, sites, page, limit) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 -} - -// WebsiteStatRepo_TopURIs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TopURIs' -type WebsiteStatRepo_TopURIs_Call struct { - *mock.Call -} - -// TopURIs is a helper method to define mock.On call -// - start string -// - end string -// - sites []string -// - page uint -// - limit uint -func (_e *WebsiteStatRepo_Expecter) TopURIs(start any, end any, sites any, page any, limit any) *WebsiteStatRepo_TopURIs_Call { - return &WebsiteStatRepo_TopURIs_Call{Call: _e.mock.On("TopURIs", start, end, sites, page, limit)} -} - -func (_c *WebsiteStatRepo_TopURIs_Call) Run(run func(start string, end string, sites []string, page uint, limit uint)) *WebsiteStatRepo_TopURIs_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 []string - if args[2] != nil { - arg2 = args[2].([]string) - } - var arg3 uint - if args[3] != nil { - arg3 = args[3].(uint) - } - var arg4 uint - if args[4] != nil { - arg4 = args[4].(uint) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_TopURIs_Call) Return(websiteStatURIRanks []*biz.WebsiteStatURIRank, v uint, err error) *WebsiteStatRepo_TopURIs_Call { - _c.Call.Return(websiteStatURIRanks, v, err) - return _c -} - -func (_c *WebsiteStatRepo_TopURIs_Call) RunAndReturn(run func(start string, end string, sites []string, page uint, limit uint) ([]*biz.WebsiteStatURIRank, uint, error)) *WebsiteStatRepo_TopURIs_Call { - _c.Call.Return(run) - return _c -} - -// Upsert provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) Upsert(stats []*biz.WebsiteStat) error { - ret := _mock.Called(stats) - - if len(ret) == 0 { - panic("no return value specified for Upsert") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func([]*biz.WebsiteStat) error); ok { - r0 = returnFunc(stats) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_Upsert_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Upsert' -type WebsiteStatRepo_Upsert_Call struct { - *mock.Call -} - -// Upsert is a helper method to define mock.On call -// - stats []*biz.WebsiteStat -func (_e *WebsiteStatRepo_Expecter) Upsert(stats any) *WebsiteStatRepo_Upsert_Call { - return &WebsiteStatRepo_Upsert_Call{Call: _e.mock.On("Upsert", stats)} -} - -func (_c *WebsiteStatRepo_Upsert_Call) Run(run func(stats []*biz.WebsiteStat)) *WebsiteStatRepo_Upsert_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []*biz.WebsiteStat - if args[0] != nil { - arg0 = args[0].([]*biz.WebsiteStat) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_Upsert_Call) Return(err error) *WebsiteStatRepo_Upsert_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_Upsert_Call) RunAndReturn(run func(stats []*biz.WebsiteStat) error) *WebsiteStatRepo_Upsert_Call { - _c.Call.Return(run) - return _c -} - -// UpsertClients provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) UpsertClients(stats []*biz.WebsiteStatClient) error { - ret := _mock.Called(stats) - - if len(ret) == 0 { - panic("no return value specified for UpsertClients") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func([]*biz.WebsiteStatClient) error); ok { - r0 = returnFunc(stats) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_UpsertClients_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpsertClients' -type WebsiteStatRepo_UpsertClients_Call struct { - *mock.Call -} - -// UpsertClients is a helper method to define mock.On call -// - stats []*biz.WebsiteStatClient -func (_e *WebsiteStatRepo_Expecter) UpsertClients(stats any) *WebsiteStatRepo_UpsertClients_Call { - return &WebsiteStatRepo_UpsertClients_Call{Call: _e.mock.On("UpsertClients", stats)} -} - -func (_c *WebsiteStatRepo_UpsertClients_Call) Run(run func(stats []*biz.WebsiteStatClient)) *WebsiteStatRepo_UpsertClients_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []*biz.WebsiteStatClient - if args[0] != nil { - arg0 = args[0].([]*biz.WebsiteStatClient) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_UpsertClients_Call) Return(err error) *WebsiteStatRepo_UpsertClients_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_UpsertClients_Call) RunAndReturn(run func(stats []*biz.WebsiteStatClient) error) *WebsiteStatRepo_UpsertClients_Call { - _c.Call.Return(run) - return _c -} - -// UpsertIPs provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) UpsertIPs(stats []*biz.WebsiteStatIP) error { - ret := _mock.Called(stats) - - if len(ret) == 0 { - panic("no return value specified for UpsertIPs") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func([]*biz.WebsiteStatIP) error); ok { - r0 = returnFunc(stats) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_UpsertIPs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpsertIPs' -type WebsiteStatRepo_UpsertIPs_Call struct { - *mock.Call -} - -// UpsertIPs is a helper method to define mock.On call -// - stats []*biz.WebsiteStatIP -func (_e *WebsiteStatRepo_Expecter) UpsertIPs(stats any) *WebsiteStatRepo_UpsertIPs_Call { - return &WebsiteStatRepo_UpsertIPs_Call{Call: _e.mock.On("UpsertIPs", stats)} -} - -func (_c *WebsiteStatRepo_UpsertIPs_Call) Run(run func(stats []*biz.WebsiteStatIP)) *WebsiteStatRepo_UpsertIPs_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []*biz.WebsiteStatIP - if args[0] != nil { - arg0 = args[0].([]*biz.WebsiteStatIP) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_UpsertIPs_Call) Return(err error) *WebsiteStatRepo_UpsertIPs_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_UpsertIPs_Call) RunAndReturn(run func(stats []*biz.WebsiteStatIP) error) *WebsiteStatRepo_UpsertIPs_Call { - _c.Call.Return(run) - return _c -} - -// UpsertSpiders provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) UpsertSpiders(stats []*biz.WebsiteStatSpider) error { - ret := _mock.Called(stats) - - if len(ret) == 0 { - panic("no return value specified for UpsertSpiders") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func([]*biz.WebsiteStatSpider) error); ok { - r0 = returnFunc(stats) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_UpsertSpiders_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpsertSpiders' -type WebsiteStatRepo_UpsertSpiders_Call struct { - *mock.Call -} - -// UpsertSpiders is a helper method to define mock.On call -// - stats []*biz.WebsiteStatSpider -func (_e *WebsiteStatRepo_Expecter) UpsertSpiders(stats any) *WebsiteStatRepo_UpsertSpiders_Call { - return &WebsiteStatRepo_UpsertSpiders_Call{Call: _e.mock.On("UpsertSpiders", stats)} -} - -func (_c *WebsiteStatRepo_UpsertSpiders_Call) Run(run func(stats []*biz.WebsiteStatSpider)) *WebsiteStatRepo_UpsertSpiders_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []*biz.WebsiteStatSpider - if args[0] != nil { - arg0 = args[0].([]*biz.WebsiteStatSpider) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_UpsertSpiders_Call) Return(err error) *WebsiteStatRepo_UpsertSpiders_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_UpsertSpiders_Call) RunAndReturn(run func(stats []*biz.WebsiteStatSpider) error) *WebsiteStatRepo_UpsertSpiders_Call { - _c.Call.Return(run) - return _c -} - -// UpsertURIs provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) UpsertURIs(stats []*biz.WebsiteStatURI) error { - ret := _mock.Called(stats) - - if len(ret) == 0 { - panic("no return value specified for UpsertURIs") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func([]*biz.WebsiteStatURI) error); ok { - r0 = returnFunc(stats) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_UpsertURIs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpsertURIs' -type WebsiteStatRepo_UpsertURIs_Call struct { - *mock.Call -} - -// UpsertURIs is a helper method to define mock.On call -// - stats []*biz.WebsiteStatURI -func (_e *WebsiteStatRepo_Expecter) UpsertURIs(stats any) *WebsiteStatRepo_UpsertURIs_Call { - return &WebsiteStatRepo_UpsertURIs_Call{Call: _e.mock.On("UpsertURIs", stats)} -} - -func (_c *WebsiteStatRepo_UpsertURIs_Call) Run(run func(stats []*biz.WebsiteStatURI)) *WebsiteStatRepo_UpsertURIs_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 []*biz.WebsiteStatURI - if args[0] != nil { - arg0 = args[0].([]*biz.WebsiteStatURI) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *WebsiteStatRepo_UpsertURIs_Call) Return(err error) *WebsiteStatRepo_UpsertURIs_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_UpsertURIs_Call) RunAndReturn(run func(stats []*biz.WebsiteStatURI) error) *WebsiteStatRepo_UpsertURIs_Call { - _c.Call.Return(run) - return _c -} - -// VacuumDB provides a mock function for the type WebsiteStatRepo -func (_mock *WebsiteStatRepo) VacuumDB() error { - ret := _mock.Called() - - if len(ret) == 0 { - panic("no return value specified for VacuumDB") - } - - var r0 error - if returnFunc, ok := ret.Get(0).(func() error); ok { - r0 = returnFunc() - } else { - r0 = ret.Error(0) - } - return r0 -} - -// WebsiteStatRepo_VacuumDB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VacuumDB' -type WebsiteStatRepo_VacuumDB_Call struct { - *mock.Call -} - -// VacuumDB is a helper method to define mock.On call -func (_e *WebsiteStatRepo_Expecter) VacuumDB() *WebsiteStatRepo_VacuumDB_Call { - return &WebsiteStatRepo_VacuumDB_Call{Call: _e.mock.On("VacuumDB")} -} - -func (_c *WebsiteStatRepo_VacuumDB_Call) Run(run func()) *WebsiteStatRepo_VacuumDB_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *WebsiteStatRepo_VacuumDB_Call) Return(err error) *WebsiteStatRepo_VacuumDB_Call { - _c.Call.Return(err) - return _c -} - -func (_c *WebsiteStatRepo_VacuumDB_Call) RunAndReturn(run func() error) *WebsiteStatRepo_VacuumDB_Call { - _c.Call.Return(run) - return _c -} diff --git a/pkg/acme/acme.go b/pkg/acme/acme.go index 7830dd195..9009fad12 100644 --- a/pkg/acme/acme.go +++ b/pkg/acme/acme.go @@ -40,10 +40,7 @@ const ( type EAB = acme.EAB func NewRegisterAccount(ctx context.Context, email, ca string, eab *EAB, keyType KeyType, log *slog.Logger) (*Client, error) { - client, err := getClient(ca, log) - if err != nil { - return nil, err - } + client := getClient(ca, log) accountPrivateKey, err := generatePrivateKey(keyType) if err != nil { @@ -70,10 +67,7 @@ func NewRegisterAccount(ctx context.Context, email, ca string, eab *EAB, keyType } func NewPrivateKeyAccount(email string, privateKey string, ca string, eab *EAB, log *slog.Logger) (*Client, error) { - client, err := getClient(ca, log) - if err != nil { - return nil, err - } + client := getClient(ca, log) key, err := cert.ParseKey([]byte(privateKey)) if err != nil { @@ -117,14 +111,12 @@ func generatePrivateKey(keyType KeyType) (crypto.Signer, error) { return nil, errors.New("unsupported key type") } -func getClient(ca string, log *slog.Logger) (acmez.Client, error) { - client := acmez.Client{ +func getClient(ca string, log *slog.Logger) acmez.Client { + return acmez.Client{ Client: &acme.Client{ Directory: ca, HTTPClient: http.DefaultClient, Logger: log, }, } - - return client, nil } diff --git a/pkg/acme/client_test.go b/pkg/acme/client_test.go index 0f38c3931..1a1c49d3f 100644 --- a/pkg/acme/client_test.go +++ b/pkg/acme/client_test.go @@ -5,21 +5,14 @@ import ( "log/slog" "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) -type ClientTestSuite struct { - suite.Suite -} - -func TestClientTestSuite(t *testing.T) { - suite.Run(t, &ClientTestSuite{}) -} - -func (s *ClientTestSuite) TestObtainSSL() { +func TestObtainSSL(t *testing.T) { ctx := context.Background() client, err := NewRegisterAccount(ctx, "ci@haozi.net", CALetsEncryptStaging, nil, KeyEC256, slog.Default()) - s.Nil(err) + must.NoError(t, err) client.UseDns(AliYun, DNSParam{ AK: "123456", @@ -30,13 +23,13 @@ func (s *ClientTestSuite) TestObtainSSL() { resolves, err := client.GetDNSRecords(ctx, []string{"*.haozi.net", "haozi.net"}, KeyEC256) debug.Dump(resolves) - s.Nil(err) - s.NotNil(resolves) + check.Nil(t, err) + check.NotNil(t, resolves) time.Sleep(2 * time.Minute) ssl, err := client.ObtainCertificateManual()*/ ssl, err := client.ObtainCertificate(ctx, []string{"*.haozi.net", "haozi.net"}, KeyEC256) - s.Error(err) - s.NotNil(ssl) + check.Error(t, err) + check.Zero(t, ssl) } diff --git a/pkg/acme/solvers.go b/pkg/acme/solvers.go index b85b52eab..6b462db99 100644 --- a/pkg/acme/solvers.go +++ b/pkg/acme/solvers.go @@ -76,7 +76,7 @@ func (s *panelSolver) Present(_ context.Context, challenge acme.Challenge) error } // 如果 80 端口没有被占用,则使用内置的 HTTP 服务器 - if !pkgos.TCPPortInUse(80) { + if !pkgos.TCPPortInUse(80) { //nolint:contextcheck s.useBuiltin = true return s.startServer() } @@ -93,7 +93,10 @@ func (s *panelSolver) Present(_ context.Context, challenge acme.Challenge) error func (s *panelSolver) startServer() error { s.server = &http.Server{ - Addr: ":80", + Addr: ":80", + ReadHeaderTimeout: 10 * time.Second, + ReadTimeout: 30 * time.Second, + WriteTimeout: 30 * time.Second, Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { token, ok := s.tokens[r.URL.Path] if !ok { diff --git a/pkg/api/api_test.go b/pkg/api/api_test.go index 5c5f45c95..676722116 100644 --- a/pkg/api/api_test.go +++ b/pkg/api/api_test.go @@ -3,61 +3,60 @@ package api import ( "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) -type APITestSuite struct { - suite.Suite - api *API +func newTestAPI() *API { + return NewAPI("3.0.0", "en") } -func TestAPITestSuite(t *testing.T) { - suite.Run(t, &APITestSuite{ - api: NewAPI("3.0.0", "en"), - }) +func TestGetLatestVersion(t *testing.T) { + version, err := newTestAPI().LatestVersion("stable") + must.NoError(t, err) + check.NotEmpty(t, version.Version) } -func (s *APITestSuite) TestGetLatestVersion() { - _, err := s.api.LatestVersion("stable") - s.NoError(err) +func TestGetIntermediateVersions(t *testing.T) { + // 已是最新版时列表为空是正常的,只能校验不报错 + _, err := newTestAPI().IntermediateVersions("stable") + check.NoError(t, err) } -func (s *APITestSuite) TestGetIntermediateVersions() { - _, err := s.api.IntermediateVersions("stable") - s.NoError(err) +func TestGetCategories(t *testing.T) { + categories, err := newTestAPI().Categories() + must.NoError(t, err) + check.NotEmpty(t, *categories) } -func (s *APITestSuite) TestGetCategories() { - _, err := s.api.Categories() - s.NoError(err) +func TestGetApps(t *testing.T) { + apps, err := newTestAPI().Apps() + must.NoError(t, err) + check.NotEmpty(t, *apps) } -func (s *APITestSuite) TestGetApps() { - _, err := s.api.Apps() - s.NoError(err) +func TestGetAppBySlug(t *testing.T) { + app, err := newTestAPI().AppBySlug("nginx") + must.NoError(t, err) + check.Equal(t, app.Slug, "nginx") } -func (s *APITestSuite) TestGetAppBySlug() { - _, err := s.api.AppBySlug("nginx") - s.NoError(err) +func TestAppCallback(t *testing.T) { + check.NoError(t, newTestAPI().AppCallback("nginx")) } -func (s *APITestSuite) TestAppCallback() { - err := s.api.AppCallback("nginx") - s.NoError(err) +func TestGetTemplates(t *testing.T) { + templates, err := newTestAPI().Templates() + must.NoError(t, err) + check.NotEmpty(t, *templates) } -func (s *APITestSuite) TestGetTemplates() { - _, err := s.api.Templates() - s.NoError(err) +func TestGetTemplateBySlug(t *testing.T) { + template, err := newTestAPI().TemplateBySlug("nginx") + must.NoError(t, err) + check.Equal(t, template.Slug, "nginx") } -func (s *APITestSuite) TestGetTemplateBySlug() { - _, err := s.api.TemplateBySlug("nginx") - s.NoError(err) -} - -func (s *APITestSuite) TestTemplateCallback() { - err := s.api.TemplateCallback("nginx") - s.NoError(err) +func TestTemplateCallback(t *testing.T) { + check.NoError(t, newTestAPI().TemplateCallback("nginx")) } diff --git a/pkg/apploader/apploader.go b/pkg/apploader/apploader.go index 216fa8b7d..0322a4d63 100644 --- a/pkg/apploader/apploader.go +++ b/pkg/apploader/apploader.go @@ -60,8 +60,11 @@ func (r *Loader) Add(app ...types.App) { func (r *Loader) Register(mux chi.Router) { apps.Range(func(key, value any) bool { - app := value.(types.App) - mux.Route("/"+key.(string), app.Route) + slug, ok1 := key.(string) + app, ok2 := value.(types.App) + if ok1 && ok2 { + mux.Route("/"+slug, app.Route) + } return true }) } @@ -71,13 +74,16 @@ func (r *Loader) Get(slug string) (types.App, bool) { if !ok { return nil, false } - return v.(types.App), true + app, ok := v.(types.App) + return app, ok } func Slugs() []string { var slugs []string apps.Range(func(key, value any) bool { - slugs = append(slugs, key.(string)) + if slug, ok := key.(string); ok { + slugs = append(slugs, slug) + } return true }) return slugs diff --git a/pkg/cert/cert.go b/pkg/cert/cert.go index 408ec80cf..98d18bbcf 100644 --- a/pkg/cert/cert.go +++ b/pkg/cert/cert.go @@ -46,11 +46,15 @@ func ParseKey(key []byte) (crypto.Signer, error) { } if parse, err := x509.ParsePKCS8PrivateKey(keyBlockDER.Bytes); err == nil { - switch parse.(type) { - case *rsa.PrivateKey, *ecdsa.PrivateKey, ed25519.PrivateKey: - return parse.(crypto.Signer), nil + switch parsed := parse.(type) { + case *rsa.PrivateKey: + return parsed, nil + case *ecdsa.PrivateKey: + return parsed, nil + case ed25519.PrivateKey: + return parsed, nil default: - return nil, fmt.Errorf("found unknown private key type in PKCS#8 wrapping: %T", key) + return nil, fmt.Errorf("found unknown private key type in PKCS#8 wrapping: %T", parse) } } diff --git a/pkg/cert/cert_test.go b/pkg/cert/cert_test.go index 4b16c5b4f..73fdb06a0 100644 --- a/pkg/cert/cert_test.go +++ b/pkg/cert/cert_test.go @@ -1,29 +1,40 @@ package cert import ( + "crypto/x509" + "encoding/pem" "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) -type CertTestSuite struct { - suite.Suite -} +func TestGenerateSelfSigned(t *testing.T) { + tests := []struct { + name string + gen func([]string) ([]byte, []byte, error) + keyBlock string + }{ + {name: "ecdsa", gen: GenerateSelfSigned, keyBlock: "PRIVATE KEY"}, + {name: "rsa", gen: GenerateSelfSignedRSA, keyBlock: "RSA PRIVATE KEY"}, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + certPEM, keyPEM, err := test.gen([]string{"haozi.dev"}) + must.NoError(t, err) -func TestCertTestSuite(t *testing.T) { - suite.Run(t, &CertTestSuite{}) -} + block, _ := pem.Decode(certPEM) + must.NotNil(t, block) + check.Equal(t, block.Type, "CERTIFICATE") -func (s *CertTestSuite) TestGenerateSelfSigned() { - pem, key, err := GenerateSelfSigned([]string{"haozi.dev"}) - s.Nil(err) - s.NotNil(pem) - s.NotNil(key) -} + parsed, err := x509.ParseCertificate(block.Bytes) + must.NoError(t, err) + check.DeepEqual(t, parsed.DNSNames, []string{"haozi.dev"}) + check.Equal(t, parsed.Subject.CommonName, "AcePanel") -func (s *CertTestSuite) TestGenerateSelfSignedRSA() { - pem, key, err := GenerateSelfSignedRSA([]string{"haozi.dev"}) - s.Nil(err) - s.NotNil(pem) - s.NotNil(key) + keyDecoded, _ := pem.Decode(keyPEM) + must.NotNil(t, keyDecoded) + check.Equal(t, keyDecoded.Type, test.keyBlock) + }) + } } diff --git a/pkg/chattr/chattr.go b/pkg/chattr/chattr.go index 363eb2d51..c01fd4dd3 100644 --- a/pkg/chattr/chattr.go +++ b/pkg/chattr/chattr.go @@ -65,7 +65,7 @@ const ( ) func ioctl(f *os.File, request uintptr, attrp *uint32) error { - argp := uintptr(unsafe.Pointer(attrp)) + argp := uintptr(unsafe.Pointer(attrp)) //nolint:gosec _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), request, argp) if errno != 0 { return os.NewSyscallError("ioctl", errno) diff --git a/pkg/db/clickhouse.go b/pkg/db/clickhouse.go index 353e9dce6..8e261d1ea 100644 --- a/pkg/db/clickhouse.go +++ b/pkg/db/clickhouse.go @@ -110,7 +110,7 @@ func (r *ClickHouse) DatabaseSize(name string) (int64, error) { } var size int64 if _, err = fmt.Sscanf(strings.TrimSpace(result), "%d", &size); err != nil { - return 0, nil + return 0, nil //nolint:nilerr } return size, nil } diff --git a/pkg/db/mysql.go b/pkg/db/mysql.go index 19c6daba6..56ee34168 100644 --- a/pkg/db/mysql.go +++ b/pkg/db/mysql.go @@ -45,23 +45,23 @@ func (r *MySQL) Close() { } func (r *MySQL) Ping() error { - return r.db.Ping() + return r.db.PingContext(context.Background()) } func (r *MySQL) Query(query string, args ...any) (*sql.Rows, error) { - return r.db.Query(query, args...) + return r.db.QueryContext(context.Background(), query, args...) } func (r *MySQL) QueryRow(query string, args ...any) *sql.Row { - return r.db.QueryRow(query, args...) + return r.db.QueryRowContext(context.Background(), query, args...) } func (r *MySQL) Exec(query string, args ...any) (sql.Result, error) { - return r.db.Exec(query, args...) + return r.db.ExecContext(context.Background(), query, args...) } func (r *MySQL) Prepare(query string) (*sql.Stmt, error) { - return r.db.Prepare(query) + return r.db.PrepareContext(context.Background(), query) } func (r *MySQL) DatabaseCreate(name string) error { @@ -94,7 +94,7 @@ func (r *MySQL) DatabaseExists(name string) (bool, error) { return true, nil } } - return false, nil + return false, rows.Err() } func (r *MySQL) DatabaseSize(name string) (int64, error) { @@ -212,7 +212,7 @@ func (r *MySQL) Users() ([]User, error) { }) } - return users, nil + return users, rows.Err() } func (r *MySQL) Databases() ([]Database, error) { @@ -262,7 +262,7 @@ func (r *MySQL) userGrants(user, host string) ([]string, error) { } grants = append(grants, grant) } - return grants, nil + return grants, rows.Err() } func (r *MySQL) flushPrivileges() { diff --git a/pkg/db/postgres.go b/pkg/db/postgres.go index b26fb25dc..0f5404dac 100644 --- a/pkg/db/postgres.go +++ b/pkg/db/postgres.go @@ -55,23 +55,23 @@ func (r *Postgres) Close() { } func (r *Postgres) Ping() error { - return r.db.Ping() + return r.db.PingContext(context.Background()) } func (r *Postgres) Query(query string, args ...any) (*sql.Rows, error) { - return r.db.Query(query, args...) + return r.db.QueryContext(context.Background(), query, args...) } func (r *Postgres) QueryRow(query string, args ...any) *sql.Row { - return r.db.QueryRow(query, args...) + return r.db.QueryRowContext(context.Background(), query, args...) } func (r *Postgres) Exec(query string, args ...any) (sql.Result, error) { - return r.db.Exec(query, args...) + return r.db.ExecContext(context.Background(), query, args...) } func (r *Postgres) Prepare(query string) (*sql.Stmt, error) { - return r.db.Prepare(query) + return r.db.PrepareContext(context.Background(), query) } func (r *Postgres) DatabaseCreate(name string) error { @@ -285,5 +285,5 @@ func (r *Postgres) Databases() ([]Database, error) { databases = append(databases, db) } - return databases, nil + return databases, rows.Err() } diff --git a/pkg/db/redis.go b/pkg/db/redis.go index 854adc895..60acfbeb8 100644 --- a/pkg/db/redis.go +++ b/pkg/db/redis.go @@ -68,7 +68,7 @@ func (r *Redis) Database() (int, error) { } var count int if _, err = fmt.Sscanf(values[1], "%d", &count); err != nil { - return 16, nil + return 16, nil //nolint:nilerr } return count, nil } @@ -123,7 +123,7 @@ func (r *Redis) Search(pattern string, page, pageSize int) ([]RedisKV, int, erro func (r *Redis) Get(key string) (*RedisKV, error) { keyType, err := redis.String(r.conn.Do("TYPE", key)) if err != nil { - return nil, fmt.Errorf("key not found: %v", err) + return nil, fmt.Errorf("key not found: %w", err) } if keyType == "none" { return nil, errors.New("key not found") @@ -170,7 +170,7 @@ func (r *Redis) SetKey(key, value, keyType string, ttl int64) error { case "list": var items []string if err := json.Unmarshal([]byte(value), &items); err != nil { - return fmt.Errorf("list value must be JSON array: %v", err) + return fmt.Errorf("list value must be JSON array: %w", err) } _, _ = r.conn.Do("DEL", key) for _, item := range items { @@ -181,7 +181,7 @@ func (r *Redis) SetKey(key, value, keyType string, ttl int64) error { case "set": var items []string if err := json.Unmarshal([]byte(value), &items); err != nil { - return fmt.Errorf("set value must be JSON array: %v", err) + return fmt.Errorf("set value must be JSON array: %w", err) } _, _ = r.conn.Do("DEL", key) for _, item := range items { @@ -192,7 +192,7 @@ func (r *Redis) SetKey(key, value, keyType string, ttl int64) error { case "zset": var members map[string]string if err := json.Unmarshal([]byte(value), &members); err != nil { - return fmt.Errorf("zset value must be JSON object {member: score}: %v", err) + return fmt.Errorf("zset value must be JSON object {member: score}: %w", err) } _, _ = r.conn.Do("DEL", key) for member, score := range members { @@ -203,7 +203,7 @@ func (r *Redis) SetKey(key, value, keyType string, ttl int64) error { case "hash": var fields map[string]string if err := json.Unmarshal([]byte(value), &fields); err != nil { - return fmt.Errorf("hash value must be JSON object: %v", err) + return fmt.Errorf("hash value must be JSON object: %w", err) } _, _ = r.conn.Do("DEL", key) for field, val := range fields { @@ -241,11 +241,11 @@ func (r *Redis) scanKeys(pattern string) ([]string, error) { args[0] = cursor values, err := redis.Values(r.conn.Do("SCAN", args...)) if err != nil { - return nil, fmt.Errorf("failed to SCAN: %v", err) + return nil, fmt.Errorf("failed to SCAN: %w", err) } var batch []string if _, err = redis.Scan(values, &cursor, &batch); err != nil { - return nil, fmt.Errorf("failed to parse SCAN result: %v", err) + return nil, fmt.Errorf("failed to parse SCAN result: %w", err) } keys = append(keys, batch...) if cursor == 0 { @@ -261,8 +261,10 @@ func (r *Redis) fillKeyValue(kv *RedisKV) error { var err error switch kv.Type { case "string": - if value, err = redis.String(r.conn.Do("GET", kv.Key)); err == nil { - kv.Length = int64(len(value.(string))) + var str string + if str, err = redis.String(r.conn.Do("GET", kv.Key)); err == nil { + value = str + kv.Length = int64(len(str)) } case "list": if value, err = redis.Strings(r.conn.Do("LRANGE", kv.Key, 0, -1)); err == nil { diff --git a/pkg/db/sqlite.go b/pkg/db/sqlite.go index 684dc83c6..d3146f70b 100644 --- a/pkg/db/sqlite.go +++ b/pkg/db/sqlite.go @@ -1,6 +1,7 @@ package db import ( + "context" "database/sql" "fmt" @@ -19,7 +20,7 @@ func NewSQLite(path string) (*SQLite, error) { if err != nil { return nil, fmt.Errorf("open sqlite failed: %w", err) } - if err = db.Ping(); err != nil { + if err = db.PingContext(context.Background()); err != nil { return nil, fmt.Errorf("connect to sqlite failed: %w", err) } return &SQLite{db: db, path: path}, nil @@ -30,12 +31,12 @@ func (r *SQLite) Close() { } func (r *SQLite) Ping() error { - return r.db.Ping() + return r.db.PingContext(context.Background()) } // Tables 获取所有表 func (r *SQLite) Tables() ([]string, error) { - rows, err := r.db.Query("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name") + rows, err := r.db.QueryContext(context.Background(), "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name") if err != nil { return nil, err } @@ -64,7 +65,7 @@ type SQLiteColumn struct { // TableInfo 获取表结构 func (r *SQLite) TableInfo(name string) ([]SQLiteColumn, error) { - rows, err := r.db.Query(fmt.Sprintf("PRAGMA table_info('%s')", name)) + rows, err := r.db.QueryContext(context.Background(), fmt.Sprintf("PRAGMA table_info('%s')", name)) if err != nil { return nil, err } diff --git a/pkg/fastcgi/fastcgi.go b/pkg/fastcgi/fastcgi.go index 4c33b3f5e..3363475a4 100644 --- a/pkg/fastcgi/fastcgi.go +++ b/pkg/fastcgi/fastcgi.go @@ -32,22 +32,21 @@ func Request(ctx context.Context, network, address string, params map[string]str _ = conn.SetDeadline(deadline) } - const requestID = 1 // BEGIN_REQUEST:responder 角色,连接不复用 - if err = writeRecord(conn, typeBeginRequest, requestID, []byte{0, roleResponder, 0, 0, 0, 0, 0, 0}); err != nil { + if err = writeRecord(conn, typeBeginRequest, []byte{0, roleResponder, 0, 0, 0, 0, 0, 0}); err != nil { return nil, err } var buf bytes.Buffer for name, value := range params { encodeNameValue(&buf, name, value) } - if err = writeRecord(conn, typeParams, requestID, buf.Bytes()); err != nil { + if err = writeRecord(conn, typeParams, buf.Bytes()); err != nil { return nil, err } - if err = writeRecord(conn, typeParams, requestID, nil); err != nil { + if err = writeRecord(conn, typeParams, nil); err != nil { return nil, err } - if err = writeRecord(conn, typeStdin, requestID, nil); err != nil { + if err = writeRecord(conn, typeStdin, nil); err != nil { return nil, err } @@ -81,10 +80,10 @@ func Request(ctx context.Context, network, address string, params map[string]str } // writeRecord 写入一条 FastCGI 记录 -func writeRecord(w io.Writer, typ byte, requestID uint16, content []byte) error { +func writeRecord(w io.Writer, typ byte, content []byte) error { header := [8]byte{1, typ} - binary.BigEndian.PutUint16(header[2:4], requestID) - binary.BigEndian.PutUint16(header[4:6], uint16(len(content))) //nolint:gosec // params 由面板构造,长度远小于 64KB + binary.BigEndian.PutUint16(header[2:4], 1) + binary.BigEndian.PutUint16(header[4:6], uint16(len(content))) //nolint:gosec if _, err := w.Write(header[:]); err != nil { return err } @@ -100,11 +99,11 @@ func writeRecord(w io.Writer, typ byte, requestID uint16, content []byte) error func encodeNameValue(buf *bytes.Buffer, name, value string) { writeLength := func(n int) { if n < 128 { - buf.WriteByte(byte(n)) + buf.WriteByte(byte(n)) //nolint:gosec return } var b [4]byte - binary.BigEndian.PutUint32(b[:], uint32(n)|1<<31) //nolint:gosec // 长度非负 + binary.BigEndian.PutUint32(b[:], uint32(n)|1<<31) //nolint:gosec buf.Write(b[:]) } writeLength(len(name)) diff --git a/pkg/firewall/firewall_test.go b/pkg/firewall/firewall_test.go index 0cbf62772..48488f5cd 100644 --- a/pkg/firewall/firewall_test.go +++ b/pkg/firewall/firewall_test.go @@ -3,478 +3,369 @@ package firewall import ( "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) -type FirewalldSuite struct { - suite.Suite - fw *firewalld -} - -func (s *FirewalldSuite) SetupTest() { - s.fw = newFirewalld() -} - -// --- parseRichRule --- - -func (s *FirewalldSuite) TestParseRichRule_AcceptSourcePort() { - info, err := s.fw.parseRichRule(`rule family="ipv4" source address="192.168.1.100" port port="8080" protocol="tcp" accept`) - s.NoError(err) - s.Equal("ipv4", info.Family) - s.Equal("192.168.1.100", info.Address) - s.Equal(uint(8080), info.PortStart) - s.Equal(uint(8080), info.PortEnd) - s.Equal(ProtocolTCP, info.Protocol) - s.Equal(StrategyAccept, info.Strategy) - s.Equal(Direction("in"), info.Direction) - s.Equal(TypeRich, info.Type) -} - -func (s *FirewalldSuite) TestParseRichRule_DropSourcePortRange() { - info, err := s.fw.parseRichRule(`rule family="ipv4" source address="10.0.0.0/8" port port="3000-4000" protocol="tcp" drop`) - s.NoError(err) - s.Equal("10.0.0.0/8", info.Address) - s.Equal(uint(3000), info.PortStart) - s.Equal(uint(4000), info.PortEnd) - s.Equal(ProtocolTCP, info.Protocol) - s.Equal(StrategyDrop, info.Strategy) - s.Equal(Direction("in"), info.Direction) -} - -func (s *FirewalldSuite) TestParseRichRule_RejectDestination() { - info, err := s.fw.parseRichRule(`rule family="ipv4" destination address="203.0.113.0/24" port port="443" protocol="tcp" reject`) - s.NoError(err) - s.Equal("203.0.113.0/24", info.Address) - s.Equal(Direction("out"), info.Direction) - s.Equal(StrategyReject, info.Strategy) -} - -func (s *FirewalldSuite) TestParseRichRule_IPv6() { - info, err := s.fw.parseRichRule(`rule family="ipv6" source address="::1" port port="22" protocol="tcp" accept`) - s.NoError(err) - s.Equal("ipv6", info.Family) - s.Equal("::1", info.Address) - s.Equal(uint(22), info.PortStart) -} - -func (s *FirewalldSuite) TestParseRichRule_NoPort_IPOnly() { - // IP 规则无端口,解析为 1-65535 - info, err := s.fw.parseRichRule(`rule family="ipv4" source address="8.8.8.8" protocol value="tcp" accept`) - s.NoError(err) - s.Equal("8.8.8.8", info.Address) - s.Equal(uint(1), info.PortStart) - s.Equal(uint(65535), info.PortEnd) - s.Equal(ProtocolTCP, info.Protocol) -} - -func (s *FirewalldSuite) TestParseRichRule_NoPort_NoProtocol() { - // 无端口无协议规则 - info, err := s.fw.parseRichRule(`rule family="ipv4" source address="1.2.3.4" drop`) - s.NoError(err) - s.Equal("1.2.3.4", info.Address) - s.Equal(ProtocolTCPUDP, info.Protocol) // 默认 tcp/udp - s.Equal(uint(1), info.PortStart) - s.Equal(uint(65535), info.PortEnd) -} - -func (s *FirewalldSuite) TestParseRichRule_UDPProtocol() { - info, err := s.fw.parseRichRule(`rule family="ipv4" port port="53" protocol="udp" accept`) - s.NoError(err) - s.Equal(ProtocolUDP, info.Protocol) - s.Equal(uint(53), info.PortStart) - s.Equal(uint(53), info.PortEnd) - s.Empty(info.Address) -} - -func (s *FirewalldSuite) TestParseRichRule_MarkStrategy() { - info, err := s.fw.parseRichRule(`rule family="ipv4" source address="10.0.0.1" port port="80" protocol="tcp" mark set="1"`) - s.NoError(err) - s.Equal(Strategy("mark"), info.Strategy) -} - -func (s *FirewalldSuite) TestParseRichRule_InvalidFormat() { - _, err := s.fw.parseRichRule(`this is not a valid rule`) - s.Error(err) -} - -func (s *FirewalldSuite) TestParseRichRule_EmptyString() { - _, err := s.fw.parseRichRule(``) - s.Error(err) -} - -// --- forward 正则 --- - -func (s *FirewalldSuite) TestForwardRegex_Standard() { - line := "port=8080:proto=tcp:toport=80:toaddr=192.168.1.100" - s.True(s.fw.forwardListRegex.MatchString(line)) - match := s.fw.forwardListRegex.FindStringSubmatch(line) - s.Equal("8080", match[1]) - s.Equal("tcp", match[2]) - s.Equal("80", match[3]) - s.Equal("192.168.1.100", match[4]) -} - -func (s *FirewalldSuite) TestForwardRegex_NoAddr() { - line := "port=3000:proto=udp:toport=4000:toaddr=" - s.True(s.fw.forwardListRegex.MatchString(line)) - match := s.fw.forwardListRegex.FindStringSubmatch(line) - s.Equal("3000", match[1]) - s.Equal("udp", match[2]) - s.Equal("4000", match[3]) - s.Equal("", match[4]) -} - -func (s *FirewalldSuite) TestForwardRegex_IPv6Addr() { - line := "port=443:proto=tcp:toport=8443:toaddr=::1" - s.True(s.fw.forwardListRegex.MatchString(line)) - match := s.fw.forwardListRegex.FindStringSubmatch(line) - s.Equal("::1", match[4]) -} - -func TestFirewalldSuite(t *testing.T) { - suite.Run(t, new(FirewalldSuite)) -} - -// ===================== UFW 解析器测试 ===================== - -type UFWSuite struct { - suite.Suite - fw *ufw -} - -func (s *UFWSuite) SetupTest() { - s.fw = newUFW() -} - -// --- stripProtocolSuffix --- - -func (s *UFWSuite) TestStrip_IPWithTCP() { - addr, proto := stripProtocolSuffix("8.8.8.8/tcp") - s.Equal("8.8.8.8", addr) - s.Equal("tcp", proto) -} - -func (s *UFWSuite) TestStrip_IPWithUDP() { - addr, proto := stripProtocolSuffix("1.1.1.1/udp") - s.Equal("1.1.1.1", addr) - s.Equal("udp", proto) -} - -func (s *UFWSuite) TestStrip_CIDR_NotStripped() { - addr, proto := stripProtocolSuffix("192.168.1.0/24") - s.Equal("192.168.1.0/24", addr) - s.Equal("", proto) -} - -func (s *UFWSuite) TestStrip_CIDR8_NotStripped() { - addr, proto := stripProtocolSuffix("10.0.0.0/8") - s.Equal("10.0.0.0/8", addr) - s.Equal("", proto) -} - -func (s *UFWSuite) TestStrip_NoSlash() { - addr, proto := stripProtocolSuffix("Anywhere") - s.Equal("Anywhere", addr) - s.Equal("", proto) -} - -func (s *UFWSuite) TestStrip_PlainIP() { - addr, proto := stripProtocolSuffix("1.2.3.4") - s.Equal("1.2.3.4", addr) - s.Equal("", proto) -} - -// --- parseRule 端口规则 --- - -func (s *UFWSuite) TestParseRule_SimpleTCP() { - info := s.fw.parseRule("22/tcp", "ALLOW", "IN", "Anywhere") - s.Equal(uint(22), info.PortStart) - s.Equal(uint(22), info.PortEnd) - s.Equal(ProtocolTCP, info.Protocol) - s.Equal(StrategyAccept, info.Strategy) - s.Equal(Direction("in"), info.Direction) - s.Equal("ipv4", info.Family) - s.Equal(TypeNormal, info.Type) - s.Empty(info.Address) -} - -func (s *UFWSuite) TestParseRule_SimpleUDP() { - info := s.fw.parseRule("53/udp", "ALLOW", "IN", "Anywhere") - s.Equal(ProtocolUDP, info.Protocol) - s.Equal(uint(53), info.PortStart) -} - -func (s *UFWSuite) TestParseRule_NoProtocol() { - // ufw allow 8888 → "8888" 无协议 - info := s.fw.parseRule("8888", "ALLOW", "IN", "Anywhere") - s.Equal(uint(8888), info.PortStart) - s.Equal(uint(8888), info.PortEnd) - s.Equal(ProtocolTCPUDP, info.Protocol) - s.Equal(TypeNormal, info.Type) -} - -func (s *UFWSuite) TestParseRule_PortRange() { - info := s.fw.parseRule("80:443/tcp", "ALLOW", "IN", "Anywhere") - s.Equal(uint(80), info.PortStart) - s.Equal(uint(443), info.PortEnd) - s.Equal(ProtocolTCP, info.Protocol) -} - -func (s *UFWSuite) TestParseRule_DenyStrategy() { - info := s.fw.parseRule("3306/tcp", "DENY", "IN", "Anywhere") - s.Equal(StrategyDrop, info.Strategy) -} - -func (s *UFWSuite) TestParseRule_RejectStrategy() { - info := s.fw.parseRule("25/tcp", "REJECT", "IN", "Anywhere") - s.Equal(StrategyReject, info.Strategy) -} - -func (s *UFWSuite) TestParseRule_LimitStrategy() { - info := s.fw.parseRule("22/tcp", "LIMIT", "IN", "Anywhere") - s.Equal(StrategyAccept, info.Strategy) -} - -func (s *UFWSuite) TestParseRule_OutDirection() { - info := s.fw.parseRule("443/tcp", "ALLOW", "OUT", "Anywhere") - s.Equal(Direction("out"), info.Direction) -} - -// --- parseRule 带地址的端口规则 --- - -func (s *UFWSuite) TestParseRule_PortWithAddress() { - // [ 6] 80/tcp ALLOW IN 1.1.1.1 - info := s.fw.parseRule("80/tcp", "ALLOW", "IN", "1.1.1.1") - s.Equal(uint(80), info.PortStart) - s.Equal(uint(80), info.PortEnd) - s.Equal(ProtocolTCP, info.Protocol) // 必须是 tcp,不是 tcp/udp - s.Equal("1.1.1.1", info.Address) - s.Equal(TypeRich, info.Type) // 有地址 → rich -} - -func (s *UFWSuite) TestParseRule_PortWithCIDR() { - // 80/tcp ALLOW IN 192.168.1.0/24 - info := s.fw.parseRule("80/tcp", "ALLOW", "IN", "192.168.1.0/24") - s.Equal(ProtocolTCP, info.Protocol) - s.Equal("192.168.1.0/24", info.Address) // CIDR 保持不变 - s.Equal(uint(80), info.PortStart) -} - -func (s *UFWSuite) TestParseRule_PortUDPWithAddress() { - // 80/udp ALLOW IN 2.2.2.2 - info := s.fw.parseRule("80/udp", "ALLOW", "IN", "2.2.2.2") - s.Equal(ProtocolUDP, info.Protocol) - s.Equal("2.2.2.2", info.Address) -} - -// --- parseRule 纯 IP 规则 --- - -func (s *UFWSuite) TestParseRule_IPWithProtoSuffix() { - // [ 9] Anywhere ALLOW IN 8.8.8.8/tcp - info := s.fw.parseRule("Anywhere", "ALLOW", "IN", "8.8.8.8/tcp") - s.Equal("8.8.8.8", info.Address) - s.Equal(Protocol("tcp"), info.Protocol) - s.Equal(uint(1), info.PortStart) - s.Equal(uint(65535), info.PortEnd) - s.Equal(TypeRich, info.Type) -} - -func (s *UFWSuite) TestParseRule_IPWithoutProto() { - // Anywhere ALLOW IN 5.5.5.5 - info := s.fw.parseRule("Anywhere", "ALLOW", "IN", "5.5.5.5") - s.Equal("5.5.5.5", info.Address) - s.Equal(ProtocolTCPUDP, info.Protocol) - s.Equal(uint(1), info.PortStart) - s.Equal(uint(65535), info.PortEnd) -} - -func (s *UFWSuite) TestParseRule_IPDeny() { - info := s.fw.parseRule("Anywhere", "DENY", "IN", "10.0.0.1/tcp") - s.Equal("10.0.0.1", info.Address) - s.Equal(StrategyDrop, info.Strategy) - s.Equal(Protocol("tcp"), info.Protocol) -} - -func (s *UFWSuite) TestParseRule_IPWithComment() { - // Anywhere REJECT IN 195.178.110.231 # by Fail2Ban after 5 attempts against sshd - info := s.fw.parseRule("Anywhere", "REJECT", "IN", "195.178.110.231 # by Fail2Ban after 5 attempts against sshd") - s.Equal("195.178.110.231", info.Address) - s.Equal(StrategyReject, info.Strategy) - s.Equal(ProtocolTCPUDP, info.Protocol) - s.Equal(uint(1), info.PortStart) - s.Equal(uint(65535), info.PortEnd) - s.Equal(TypeRich, info.Type) -} - -func (s *UFWSuite) TestParseRule_PortWithComment() { - // 22/tcp ALLOW IN Anywhere # SSH - info := s.fw.parseRule("22/tcp", "ALLOW", "IN", "Anywhere # SSH") - s.Empty(info.Address) - s.Equal(uint(22), info.PortStart) - s.Equal(ProtocolTCP, info.Protocol) -} - -// --- parseRule IPv6 --- - -func (s *UFWSuite) TestParseRule_IPv6Port() { - // 22/tcp (v6) ALLOW IN Anywhere (v6) - info := s.fw.parseRule("22/tcp (v6)", "ALLOW", "IN", "Anywhere (v6)") - s.Equal("ipv6", info.Family) - s.Equal(uint(22), info.PortStart) - s.Equal(ProtocolTCP, info.Protocol) - s.Empty(info.Address) -} - -func (s *UFWSuite) TestParseRule_IPv6NoProto() { - // 8888 (v6) ALLOW IN Anywhere (v6) - info := s.fw.parseRule("8888 (v6)", "ALLOW", "IN", "Anywhere (v6)") - s.Equal("ipv6", info.Family) - s.Equal(uint(8888), info.PortStart) - s.Equal(ProtocolTCPUDP, info.Protocol) -} - -func (s *UFWSuite) TestParseRule_IPv6PortRange() { - info := s.fw.parseRule("80:443/tcp (v6)", "ALLOW", "IN", "Anywhere (v6)") - s.Equal("ipv6", info.Family) - s.Equal(uint(80), info.PortStart) - s.Equal(uint(443), info.PortEnd) - s.Equal(ProtocolTCP, info.Protocol) -} - -// --- mergeRules --- - -func (s *UFWSuite) TestMergeRules_TCPAndUDP() { - rules := []FireInfo{ - {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: "in"}, - {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: "in"}, +func TestFirewalldParseRichRule(t *testing.T) { + fw := newFirewalld() + tests := []struct { + name string + rule string + want FireInfo + }{ + { + name: "源地址单端口 accept", + rule: `rule family="ipv4" source address="192.168.1.100" port port="8080" protocol="tcp" accept`, + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "192.168.1.100", PortStart: 8080, PortEnd: 8080, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "源地址端口范围 drop", + rule: `rule family="ipv4" source address="10.0.0.0/8" port port="3000-4000" protocol="tcp" drop`, + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "10.0.0.0/8", PortStart: 3000, PortEnd: 4000, Protocol: ProtocolTCP, Strategy: StrategyDrop, Direction: DirectionIn}, + }, + { + name: "目标地址算出站", + rule: `rule family="ipv4" destination address="203.0.113.0/24" port port="443" protocol="tcp" reject`, + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "203.0.113.0/24", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyReject, Direction: DirectionOut}, + }, + { + name: "ipv6", + rule: `rule family="ipv6" source address="::1" port port="22" protocol="tcp" accept`, + want: FireInfo{Type: TypeRich, Family: "ipv6", Address: "::1", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "IP 规则无端口,放开全部端口", + rule: `rule family="ipv4" source address="8.8.8.8" protocol value="tcp" accept`, + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "8.8.8.8", PortStart: 1, PortEnd: 65535, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "无端口无协议默认 tcp/udp", + rule: `rule family="ipv4" source address="1.2.3.4" drop`, + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "1.2.3.4", PortStart: 1, PortEnd: 65535, Protocol: ProtocolTCPUDP, Strategy: StrategyDrop, Direction: DirectionIn}, + }, + { + name: "udp 且无地址", + rule: `rule family="ipv4" port port="53" protocol="udp" accept`, + want: FireInfo{Type: TypeRich, Family: "ipv4", PortStart: 53, PortEnd: 53, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "mark 策略", + rule: `rule family="ipv4" source address="10.0.0.1" port port="80" protocol="tcp" mark set="1"`, + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "10.0.0.1", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyMark, Direction: DirectionIn}, + }, } - merged := mergeRules(rules) - s.Len(merged, 1) - s.Equal(ProtocolTCPUDP, merged[0].Protocol) -} - -func (s *UFWSuite) TestMergeRules_DifferentPorts_NoMerge() { - rules := []FireInfo{ - {Type: TypeNormal, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: "in"}, - {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: "in"}, + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + info, err := fw.parseRichRule(tt.rule) + must.NoError(t, err) + check.DeepEqual(t, info, tt.want) + }) } - merged := mergeRules(rules) - s.Len(merged, 2) } -func (s *UFWSuite) TestMergeRules_DifferentAddresses_NoMerge() { - rules := []FireInfo{ - {Type: TypeRich, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: "in", Address: "1.1.1.1"}, - {Type: TypeRich, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: "in", Address: "2.2.2.2"}, +func TestFirewalldParseRichRuleInvalid(t *testing.T) { + fw := newFirewalld() + tests := []struct { + name string + rule string + }{ + {"非规则文本", `this is not a valid rule`}, + {"空字符串", ``}, } - merged := mergeRules(rules) - s.Len(merged, 2) -} - -func (s *UFWSuite) TestMergeRules_SameAddress_Merge() { - rules := []FireInfo{ - {Type: TypeRich, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: "in", Address: "2.2.2.2"}, - {Type: TypeRich, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: "in", Address: "2.2.2.2"}, + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := fw.parseRichRule(tt.rule) + check.Error(t, err) + }) } - merged := mergeRules(rules) - s.Len(merged, 1) - s.Equal(ProtocolTCPUDP, merged[0].Protocol) - s.Equal("2.2.2.2", merged[0].Address) } -func (s *UFWSuite) TestMergeRules_IPv4AndIPv6_NoMerge() { - rules := []FireInfo{ - {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: "in"}, - {Type: TypeNormal, Family: "ipv6", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: "in"}, +func TestFirewalldForwardRegex(t *testing.T) { + fw := newFirewalld() + tests := []struct { + name string + line string + want []string // port、proto、toport、toaddr + }{ + {"标准", "port=8080:proto=tcp:toport=80:toaddr=192.168.1.100", []string{"8080", "tcp", "80", "192.168.1.100"}}, + {"无目标地址", "port=3000:proto=udp:toport=4000:toaddr=", []string{"3000", "udp", "4000", ""}}, + {"ipv6 目标地址", "port=443:proto=tcp:toport=8443:toaddr=::1", []string{"443", "tcp", "8443", "::1"}}, } - merged := mergeRules(rules) - s.Len(merged, 2) -} - -func (s *UFWSuite) TestMergeRules_DifferentStrategy_NoMerge() { - rules := []FireInfo{ - {Type: TypeNormal, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: "in"}, - {Type: TypeNormal, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolUDP, Strategy: StrategyDrop, Direction: "in"}, + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + match := fw.forwardListRegex.FindStringSubmatch(tt.line) + must.Len(t, match, 5, must.Msgf("未匹配: %s", tt.line)) + check.DeepEqual(t, match[1:], tt.want) + }) } - merged := mergeRules(rules) - s.Len(merged, 2) } -func (s *UFWSuite) TestMergeRules_SingleRule_NoChange() { - rules := []FireInfo{ - {Type: TypeNormal, Family: "ipv4", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: "in"}, +func TestUFWStripProtocolSuffix(t *testing.T) { + tests := []struct { + name string + in string + wantAddr string + wantProto string + }{ + {"IP 带 tcp 后缀", "8.8.8.8/tcp", "8.8.8.8", "tcp"}, + {"IP 带 udp 后缀", "1.1.1.1/udp", "1.1.1.1", "udp"}, + {"CIDR /24 不剥离", "192.168.1.0/24", "192.168.1.0/24", ""}, + {"CIDR /8 不剥离", "10.0.0.0/8", "10.0.0.0/8", ""}, + {"无斜杠", "Anywhere", "Anywhere", ""}, + {"纯 IP", "1.2.3.4", "1.2.3.4", ""}, } - merged := mergeRules(rules) - s.Len(merged, 1) - s.Equal(ProtocolTCP, merged[0].Protocol) -} - -func (s *UFWSuite) TestMergeRules_AlreadyTCPUDP_NoChange() { - rules := []FireInfo{ - {Type: TypeNormal, Family: "ipv4", PortStart: 8888, PortEnd: 8888, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: "in"}, + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + addr, proto := stripProtocolSuffix(tt.in) + check.Equal(t, addr, tt.wantAddr) + check.Equal(t, proto, tt.wantProto) + }) } - merged := mergeRules(rules) - s.Len(merged, 1) - s.Equal(ProtocolTCPUDP, merged[0].Protocol) } -func (s *UFWSuite) TestMergeRules_IPRules_TCPAndUDP() { - rules := []FireInfo{ - {Type: TypeRich, Family: "ipv4", PortStart: 1, PortEnd: 65535, Protocol: Protocol("tcp"), Strategy: StrategyAccept, Direction: "in", Address: "6.6.6.6"}, - {Type: TypeRich, Family: "ipv4", PortStart: 1, PortEnd: 65535, Protocol: Protocol("udp"), Strategy: StrategyAccept, Direction: "in", Address: "6.6.6.6"}, +// 入参对应 ufw status numbered 输出的一行四列 +func TestUFWParseRule(t *testing.T) { + fw := newUFW() + tests := []struct { + name string + target string + action string + direction string + source string + want FireInfo + }{ + { + name: "tcp 端口", target: "22/tcp", action: "ALLOW", direction: "IN", source: "Anywhere", + want: FireInfo{Type: TypeNormal, Family: "ipv4", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "udp 端口", target: "53/udp", action: "ALLOW", direction: "IN", source: "Anywhere", + want: FireInfo{Type: TypeNormal, Family: "ipv4", PortStart: 53, PortEnd: 53, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + // ufw allow 8888 → "8888" 无协议 + name: "无协议端口默认 tcp/udp", target: "8888", action: "ALLOW", direction: "IN", source: "Anywhere", + want: FireInfo{Type: TypeNormal, Family: "ipv4", PortStart: 8888, PortEnd: 8888, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "端口范围", target: "80:443/tcp", action: "ALLOW", direction: "IN", source: "Anywhere", + want: FireInfo{Type: TypeNormal, Family: "ipv4", PortStart: 80, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "DENY 转 drop", target: "3306/tcp", action: "DENY", direction: "IN", source: "Anywhere", + want: FireInfo{Type: TypeNormal, Family: "ipv4", PortStart: 3306, PortEnd: 3306, Protocol: ProtocolTCP, Strategy: StrategyDrop, Direction: DirectionIn}, + }, + { + name: "REJECT 转 reject", target: "25/tcp", action: "REJECT", direction: "IN", source: "Anywhere", + want: FireInfo{Type: TypeNormal, Family: "ipv4", PortStart: 25, PortEnd: 25, Protocol: ProtocolTCP, Strategy: StrategyReject, Direction: DirectionIn}, + }, + { + name: "LIMIT 转 accept", target: "22/tcp", action: "LIMIT", direction: "IN", source: "Anywhere", + want: FireInfo{Type: TypeNormal, Family: "ipv4", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "出站方向", target: "443/tcp", action: "ALLOW", direction: "OUT", source: "Anywhere", + want: FireInfo{Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionOut}, + }, + { + // 带地址时协议取具体值而非 tcp/udp,且归为 rich + name: "端口带地址", target: "80/tcp", action: "ALLOW", direction: "IN", source: "1.1.1.1", + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "1.1.1.1", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "端口带 CIDR", target: "80/tcp", action: "ALLOW", direction: "IN", source: "192.168.1.0/24", + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "192.168.1.0/24", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "udp 端口带地址", target: "80/udp", action: "ALLOW", direction: "IN", source: "2.2.2.2", + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "2.2.2.2", PortStart: 80, PortEnd: 80, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + // [ 9] Anywhere ALLOW IN 8.8.8.8/tcp + name: "IP 带协议后缀", target: "Anywhere", action: "ALLOW", direction: "IN", source: "8.8.8.8/tcp", + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "8.8.8.8", PortStart: 1, PortEnd: 65535, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "IP 不带协议后缀", target: "Anywhere", action: "ALLOW", direction: "IN", source: "5.5.5.5", + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "5.5.5.5", PortStart: 1, PortEnd: 65535, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "IP 规则 DENY", target: "Anywhere", action: "DENY", direction: "IN", source: "10.0.0.1/tcp", + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "10.0.0.1", PortStart: 1, PortEnd: 65535, Protocol: ProtocolTCP, Strategy: StrategyDrop, Direction: DirectionIn}, + }, + { + name: "IP 规则带行尾注释", target: "Anywhere", action: "REJECT", direction: "IN", source: "195.178.110.231 # by Fail2Ban after 5 attempts against sshd", + want: FireInfo{Type: TypeRich, Family: "ipv4", Address: "195.178.110.231", PortStart: 1, PortEnd: 65535, Protocol: ProtocolTCPUDP, Strategy: StrategyReject, Direction: DirectionIn}, + }, + { + name: "端口规则带行尾注释", target: "22/tcp", action: "ALLOW", direction: "IN", source: "Anywhere # SSH", + want: FireInfo{Type: TypeNormal, Family: "ipv4", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "ipv6 端口", target: "22/tcp (v6)", action: "ALLOW", direction: "IN", source: "Anywhere (v6)", + want: FireInfo{Type: TypeNormal, Family: "ipv6", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "ipv6 无协议端口", target: "8888 (v6)", action: "ALLOW", direction: "IN", source: "Anywhere (v6)", + want: FireInfo{Type: TypeNormal, Family: "ipv6", PortStart: 8888, PortEnd: 8888, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + { + name: "ipv6 端口范围", target: "80:443/tcp (v6)", action: "ALLOW", direction: "IN", source: "Anywhere (v6)", + want: FireInfo{Type: TypeNormal, Family: "ipv6", PortStart: 80, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, } - merged := mergeRules(rules) - s.Len(merged, 1) - s.Equal(ProtocolTCPUDP, merged[0].Protocol) - s.Equal("6.6.6.6", merged[0].Address) -} - -func (s *UFWSuite) TestMergeRules_PreservesOrder() { - rules := []FireInfo{ - {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: "in"}, - {Type: TypeNormal, Family: "ipv4", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: "in"}, - {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: "in"}, + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + check.DeepEqual(t, fw.parseRule(tt.target, tt.action, tt.direction, tt.source), &tt.want) + }) } - merged := mergeRules(rules) - s.Len(merged, 2) - s.Equal(uint(443), merged[0].PortStart) - s.Equal(ProtocolTCPUDP, merged[0].Protocol) - s.Equal(uint(22), merged[1].PortStart) - s.Equal(ProtocolTCP, merged[1].Protocol) } -// --- NAT 正则 --- - -func (s *UFWSuite) TestNATRegex_Standard() { - line := "-A PREROUTING -p tcp --dport 8080 -j DNAT --to-destination 192.168.1.100:80" - s.True(s.fw.natRegex.MatchString(line)) - match := s.fw.natRegex.FindStringSubmatch(line) - s.Equal("tcp", match[1]) - s.Equal("8080", match[2]) - s.Equal("192.168.1.100", match[3]) - s.Equal("80", match[4]) +func TestUFWMergeRules(t *testing.T) { + tests := []struct { + name string + rules []FireInfo + want []FireInfo + }{ + { + name: "同端口 tcp+udp 合并", + rules: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + want: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + }, + { + name: "端口不同不合并", + rules: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + want: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + }, + { + name: "地址不同不合并", + rules: []FireInfo{ + {Type: TypeRich, Family: "ipv4", Address: "1.1.1.1", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeRich, Family: "ipv4", Address: "2.2.2.2", PortStart: 80, PortEnd: 80, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + want: []FireInfo{ + {Type: TypeRich, Family: "ipv4", Address: "1.1.1.1", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeRich, Family: "ipv4", Address: "2.2.2.2", PortStart: 80, PortEnd: 80, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + }, + { + name: "地址相同合并", + rules: []FireInfo{ + {Type: TypeRich, Family: "ipv4", Address: "2.2.2.2", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeRich, Family: "ipv4", Address: "2.2.2.2", PortStart: 80, PortEnd: 80, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + want: []FireInfo{ + {Type: TypeRich, Family: "ipv4", Address: "2.2.2.2", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + }, + { + name: "ipv4 与 ipv6 不合并", + rules: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv6", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + want: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv6", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + }, + { + name: "策略不同不合并", + rules: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolUDP, Strategy: StrategyDrop, Direction: DirectionIn}, + }, + want: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolUDP, Strategy: StrategyDrop, Direction: DirectionIn}, + }, + }, + { + name: "单条规则原样返回", + rules: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + want: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + }, + { + name: "已是 tcp/udp 不变", + rules: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 8888, PortEnd: 8888, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + want: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 8888, PortEnd: 8888, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + }, + { + name: "IP 规则 tcp+udp 合并", + rules: []FireInfo{ + {Type: TypeRich, Family: "ipv4", Address: "6.6.6.6", PortStart: 1, PortEnd: 65535, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeRich, Family: "ipv4", Address: "6.6.6.6", PortStart: 1, PortEnd: 65535, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + want: []FireInfo{ + {Type: TypeRich, Family: "ipv4", Address: "6.6.6.6", PortStart: 1, PortEnd: 65535, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + }, + { + name: "保持首次出现顺序", + rules: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv4", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + want: []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv4", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + check.DeepEqual(t, mergeRules(tt.rules), tt.want) + }) + } } -func (s *UFWSuite) TestNATRegex_UDP() { - line := "-A PREROUTING -p udp --dport 53 -j DNAT --to-destination 10.0.0.1:5353" - s.True(s.fw.natRegex.MatchString(line)) - match := s.fw.natRegex.FindStringSubmatch(line) - s.Equal("udp", match[1]) - s.Equal("53", match[2]) - s.Equal("10.0.0.1", match[3]) - s.Equal("5353", match[4]) +func TestUFWNATRegex(t *testing.T) { + fw := newUFW() + tests := []struct { + name string + line string + want []string // proto、dport、目标地址、目标端口;nil 表示不应匹配 + }{ + {"tcp", "-A PREROUTING -p tcp --dport 8080 -j DNAT --to-destination 192.168.1.100:80", []string{"tcp", "8080", "192.168.1.100", "80"}}, + {"udp", "-A PREROUTING -p udp --dport 53 -j DNAT --to-destination 10.0.0.1:5353", []string{"udp", "53", "10.0.0.1", "5353"}}, + {"POSTROUTING 不匹配", "-A POSTROUTING -d 192.168.1.100 -p tcp --dport 80 -j MASQUERADE", nil}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + match := fw.natRegex.FindStringSubmatch(tt.line) + if tt.want == nil { + check.Empty(t, match, check.Msgf("不应匹配: %s", tt.line)) + return + } + must.Len(t, match, 5, must.Msgf("未匹配: %s", tt.line)) + check.DeepEqual(t, match[1:], tt.want) + }) + } } -func (s *UFWSuite) TestNATRegex_NoMatch() { - line := "-A POSTROUTING -d 192.168.1.100 -p tcp --dport 80 -j MASQUERADE" - s.False(s.fw.natRegex.MatchString(line)) -} - -// --- 完整 UFW 输出集成测试 --- - -func (s *UFWSuite) TestParseRule_FullOutput() { - // 模拟用户提供的完整输出 +func TestUFWParseRuleFullOutput(t *testing.T) { + fw := newUFW() lines := []struct { target string action string @@ -501,96 +392,44 @@ func (s *UFWSuite) TestParseRule_FullOutput() { var rules []FireInfo for _, l := range lines { - info := s.fw.parseRule(l.target, l.action, l.direction, l.source) - s.NotNil(info) + info := fw.parseRule(l.target, l.action, l.direction, l.source) + must.NotNil(t, info) rules = append(rules, *info) } - merged := mergeRules(rules) - - // 构建查找辅助 - find := func(port uint, family string, addr string) *FireInfo { - for i := range merged { - r := &merged[i] - if r.PortStart == port && r.Family == family && r.Address == addr { - return r - } - } - return nil - } - findIP := func(addr string, family string) *FireInfo { - for i := range merged { - r := &merged[i] - if r.Address == addr && r.Family == family && r.PortStart == 1 && r.PortEnd == 65535 { - return r - } - } - return nil - } - - // 22/tcp ipv4 - r := find(22, "ipv4", "") - s.NotNil(r) - s.Equal(ProtocolTCP, r.Protocol) - - // 443 ipv4 → tcp + udp 合并 - r = find(443, "ipv4", "") - s.NotNil(r) - s.Equal(ProtocolTCPUDP, r.Protocol) - - // 8888 ipv4 → 原生 tcp/udp - r = find(8888, "ipv4", "") - s.NotNil(r) - s.Equal(ProtocolTCPUDP, r.Protocol) - - // 80/tcp from 1.1.1.1 → 仅 tcp - r = find(80, "ipv4", "1.1.1.1") - s.NotNil(r) - s.Equal(ProtocolTCP, r.Protocol) - - // 80/tcp+udp from 2.2.2.2 → 合并 - r = find(80, "ipv4", "2.2.2.2") - s.NotNil(r) - s.Equal(ProtocolTCPUDP, r.Protocol) - - // IP rule 8.8.8.8/tcp → tcp - r = findIP("8.8.8.8", "ipv4") - s.NotNil(r) - s.Equal(Protocol("tcp"), r.Protocol) - - // IP rule 6.6.6.6 tcp+udp → 合并 - r = findIP("6.6.6.6", "ipv4") - s.NotNil(r) - s.Equal(ProtocolTCPUDP, r.Protocol) - - // 443 ipv6 → tcp + udp 合并 - r = find(443, "ipv6", "") - s.NotNil(r) - s.Equal(ProtocolTCPUDP, r.Protocol) - - // 8888 ipv6 → 原生 tcp/udp - r = find(8888, "ipv6", "") - s.NotNil(r) - s.Equal(ProtocolTCPUDP, r.Protocol) - - // 22/tcp ipv6 - r = find(22, "ipv6", "") - s.NotNil(r) - s.Equal(ProtocolTCP, r.Protocol) + // 同端口的 tcp 与 udp 合并为 tcp/udp,其余按首次出现顺序保留 + check.DeepEqual(t, mergeRules(rules), []FireInfo{ + {Type: TypeNormal, Family: "ipv4", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv4", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv4", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv4", PortStart: 8888, PortEnd: 8888, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeRich, Family: "ipv4", Address: "1.1.1.1", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeRich, Family: "ipv4", Address: "2.2.2.2", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeRich, Family: "ipv4", Address: "8.8.8.8", PortStart: 1, PortEnd: 65535, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeRich, Family: "ipv4", Address: "6.6.6.6", PortStart: 1, PortEnd: 65535, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv6", PortStart: 22, PortEnd: 22, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv6", PortStart: 80, PortEnd: 80, Protocol: ProtocolTCP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv6", PortStart: 443, PortEnd: 443, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + {Type: TypeNormal, Family: "ipv6", PortStart: 8888, PortEnd: 8888, Protocol: ProtocolTCPUDP, Strategy: StrategyAccept, Direction: DirectionIn}, + }) } -func TestUFWSuite(t *testing.T) { - suite.Run(t, new(UFWSuite)) -} - -// ===================== isLocalAddress 测试 ===================== - func TestIsLocalAddress(t *testing.T) { - assert.True(t, isLocalAddress("127.0.0.1")) - assert.True(t, isLocalAddress("::1")) - assert.True(t, isLocalAddress("0.0.0.0")) - assert.False(t, isLocalAddress("192.168.1.1")) - assert.False(t, isLocalAddress("8.8.8.8")) - assert.False(t, isLocalAddress("localhost")) // net.ParseIP returns nil - assert.False(t, isLocalAddress("not-an-ip")) + tests := []struct { + ip string + want bool + }{ + {"127.0.0.1", true}, + {"::1", true}, + {"0.0.0.0", true}, + {"192.168.1.1", false}, + {"8.8.8.8", false}, + {"localhost", false}, // net.ParseIP 返回 nil + {"not-an-ip", false}, + } + for _, tt := range tests { + t.Run(tt.ip, func(t *testing.T) { + check.Equal(t, isLocalAddress(tt.ip), tt.want) + }) + } } diff --git a/pkg/firewall/firewalld.go b/pkg/firewall/firewalld.go index 11bffecc8..790f8fb23 100644 --- a/pkg/firewall/firewalld.go +++ b/pkg/firewall/firewalld.go @@ -298,7 +298,7 @@ func (r *firewalld) Forward(rule Forward, operation Operation) error { func (r *firewalld) PingStatus() (bool, error) { out, err := shell.Execf("firewall-cmd --zone=public --list-rich-rules") if err != nil { // 可能防火墙已关闭等 - return true, nil + return true, nil //nolint:nilerr } if !strings.Contains(out, `rule protocol value="icmp" drop`) { @@ -373,12 +373,12 @@ func (r *firewalld) enableForward() error { if out == "no" { out, err = shell.Execf("firewall-cmd --zone=public --add-masquerade --permanent") if err != nil { - return fmt.Errorf("%v: %s", err, out) + return fmt.Errorf("%w: %s", err, out) } _, err = shell.Execf("firewall-cmd --reload") return err } - return fmt.Errorf("%v: %s", err, out) + return fmt.Errorf("%w: %s", err, out) } return nil diff --git a/pkg/firewall/scan/scanner_linux.go b/pkg/firewall/scan/scanner_linux.go index 356a5a1b9..8950fa30c 100644 --- a/pkg/firewall/scan/scanner_linux.go +++ b/pkg/firewall/scan/scanner_linux.go @@ -188,9 +188,9 @@ func buildDetector(events, ports *ebpf.Map) (*ebpf.Program, error) { // IPv6 扩展头解析步骤(R4=当前头指针,R8=NextHeader) ipv6ExtStep := func(sym, next, dispatch string) asm.Instructions { - generic := fmt.Sprintf("%s_generic", sym) - fragment := fmt.Sprintf("%s_fragment", sym) - ah := fmt.Sprintf("%s_ah", sym) + generic := sym + "_generic" + fragment := sym + "_fragment" + ah := sym + "_ah" return asm.Instructions{ asm.Mov.Reg(asm.R2, asm.R8).WithSymbol(sym), diff --git a/pkg/firewall/scan/scanner_linux_test.go b/pkg/firewall/scan/scanner_linux_test.go index c51087458..681b50544 100644 --- a/pkg/firewall/scan/scanner_linux_test.go +++ b/pkg/firewall/scan/scanner_linux_test.go @@ -3,13 +3,11 @@ package scan import ( - "io" "log/slog" "os" "testing" ) -// TestSupportedAndAttach 验证检测程序可通过 verifier 且 TCX 可挂载 func TestSupportedAndAttach(t *testing.T) { if os.Geteuid() != 0 { t.Skip("需要 root") @@ -18,7 +16,7 @@ func TestSupportedAndAttach(t *testing.T) { t.Skip("内核不支持 eBPF 扫描检测(TCX 需 6.6+)") } - s, err := New([]string{"lo"}, slog.New(slog.NewTextHandler(io.Discard, nil))) + s, err := New([]string{"lo"}, slog.New(slog.DiscardHandler)) if err != nil { t.Fatal(err) } diff --git a/pkg/firewall/ufw.go b/pkg/firewall/ufw.go index 15ee80444..5f2bbf868 100644 --- a/pkg/firewall/ufw.go +++ b/pkg/firewall/ufw.go @@ -400,7 +400,7 @@ const natMarker = "# acepanel-forward" func (r *ufw) ListForward() ([]FireForwardInfo, error) { content, err := os.ReadFile(beforeRulesPath) if err != nil { - return nil, nil // before.rules 不存在时返回空 + return nil, nil //nolint:nilerr } var data []FireForwardInfo @@ -462,7 +462,7 @@ func (r *ufw) addForward(rule Forward) error { content, err := os.ReadFile(beforeRulesPath) if err != nil { - return fmt.Errorf("failed to read %s: %v", beforeRulesPath, err) + return fmt.Errorf("failed to read %s: %w", beforeRulesPath, err) } text := string(content) @@ -505,7 +505,7 @@ func (r *ufw) addForward(rule Forward) error { func (r *ufw) removeForward(rule Forward) error { content, err := os.ReadFile(beforeRulesPath) if err != nil { - return nil + return nil //nolint:nilerr } lines := strings.Split(string(content), "\n") @@ -568,7 +568,7 @@ func (r *ufw) findNatCommit(text string) int { func (r *ufw) PingStatus() (bool, error) { content, err := os.ReadFile(beforeRulesPath) if err != nil { - return true, nil + return true, nil //nolint:nilerr } // 检查 icmp echo-request 规则 @@ -584,7 +584,7 @@ func (r *ufw) PingStatus() (bool, error) { func (r *ufw) UpdatePingStatus(status bool) error { content, err := os.ReadFile(beforeRulesPath) if err != nil { - return fmt.Errorf("failed to read %s: %v", beforeRulesPath, err) + return fmt.Errorf("failed to read %s: %w", beforeRulesPath, err) } text := string(content) diff --git a/pkg/geoip/geoip_test.go b/pkg/geoip/geoip_test.go index f8891ca5e..eccb7aa26 100644 --- a/pkg/geoip/geoip_test.go +++ b/pkg/geoip/geoip_test.go @@ -1,73 +1,60 @@ package geoip import ( + "io/fs" "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) const testDBPath = "ipipfree.ipdb" -type GeoIPSuite struct { - suite.Suite - g *GeoIP -} - -func (s *GeoIPSuite) SetupSuite() { +func newTestGeoIP(t *testing.T) *GeoIP { + t.Helper() g, err := NewGeoIP(testDBPath) - s.Require().NoError(err) - s.Require().NotNil(g) - s.g = g + must.NoError(t, err) + t.Cleanup(func() { + check.NoError(t, g.Close()) + }) + return g } -func (s *GeoIPSuite) TearDownSuite() { - s.Require().NoError(s.g.Close()) -} - -func TestGeoIPSuite(t *testing.T) { - suite.Run(t, new(GeoIPSuite)) -} - -// ========== NewGeoIP ========== - -func (s *GeoIPSuite) TestNewGeoIP_InvalidPath() { +func TestNewGeoIP_InvalidPath(t *testing.T) { _, err := NewGeoIP("/nonexistent/path.ipdb") - s.Error(err) + check.ErrorIs(t, err, fs.ErrNotExist) } -// ========== Lookup ========== - -func (s *GeoIPSuite) TestLookup_ChinaIP() { - r := s.g.Lookup("114.114.114.114") - s.NotEmpty(r.Country) - s.T().Logf("114.114.114.114 -> %s(%s) %s %s ISP=%s", r.Country, r.CountryCode, r.Region, r.City, r.ISP) +func TestLookup_KnownIP(t *testing.T) { + g := newTestGeoIP(t) + // 具体归属地随库更新变化,只断言解析出了国家 + for _, ip := range []string{"114.114.114.114", "8.8.8.8"} { + t.Run(ip, func(t *testing.T) { + r := g.Lookup(ip) + check.NotEmpty(t, r.Country, check.Msgf("%s -> %+v", ip, r)) + }) + } } -func (s *GeoIPSuite) TestLookup_ForeignIP() { - r := s.g.Lookup("8.8.8.8") - s.NotEmpty(r.Country) - s.T().Logf("8.8.8.8 -> %s(%s) %s %s ISP=%s", r.Country, r.CountryCode, r.Region, r.City, r.ISP) +func TestLookup_PrivateIP(t *testing.T) { + // 是否有记录取决于库内容,只要求不 panic + r := newTestGeoIP(t).Lookup("192.168.1.1") + t.Logf("192.168.1.1 -> %+v", r) } -func (s *GeoIPSuite) TestLookup_PrivateIP() { - // 内网 IP,不应 panic - r := s.g.Lookup("192.168.1.1") - s.T().Logf("192.168.1.1 -> %s(%s) %s %s ISP=%s", r.Country, r.CountryCode, r.Region, r.City, r.ISP) +func TestLookup_InvalidIP(t *testing.T) { + // 查不到时返回整个零值结果,而不是只有国家为空 + r := newTestGeoIP(t).Lookup("not-an-ip") + check.Equal(t, r, GeoResult{}) } -func (s *GeoIPSuite) TestLookup_InvalidIP() { - r := s.g.Lookup("not-an-ip") - s.Empty(r.Country) -} - -func (s *GeoIPSuite) TestLookup_NilReceiver() { +func TestLookup_NilReceiver(t *testing.T) { var g *GeoIP r := g.Lookup("8.8.8.8") - s.Equal(GeoResult{}, r) + check.Equal(t, r, GeoResult{}) } -func (s *GeoIPSuite) TestLookup_IPv6() { - // IPv6 地址,数据库可能不支持,不应 panic - r := s.g.Lookup("2001:4860:4860::8888") - s.T().Logf("2001:4860:4860::8888 -> %s(%s) %s %s ISP=%s", r.Country, r.CountryCode, r.Region, r.City, r.ISP) +func TestLookup_IPv6(t *testing.T) { + r := newTestGeoIP(t).Lookup("2001:4860:4860::8888") + t.Logf("2001:4860:4860::8888 -> %+v", r) } diff --git a/pkg/io/compress.go b/pkg/io/compress.go index 74f2fefa1..404402361 100644 --- a/pkg/io/compress.go +++ b/pkg/io/compress.go @@ -244,8 +244,9 @@ func compressorByFormat(format FormatArchive) string { return "xz" case Zst: return "zstd" + default: + return "" } - return "" } // formatArchiveByPath 根据文件后缀获取压缩格式 diff --git a/pkg/io/io_test.go b/pkg/io/io_test.go index 832d20051..1107e4bd7 100644 --- a/pkg/io/io_test.go +++ b/pkg/io/io_test.go @@ -6,220 +6,227 @@ import ( "strings" "testing" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" "github.com/libtnb/utils/env" - "github.com/stretchr/testify/suite" ) -type IOTestSuite struct { - suite.Suite +func dirExists(path string) bool { + info, err := os.Stat(path) + return err == nil && info.IsDir() } -func TestIOTestSuite(t *testing.T) { - suite.Run(t, &IOTestSuite{}) +func fileExists(path string) bool { + info, err := os.Stat(path) + return err == nil && !info.IsDir() } -func (s *IOTestSuite) SetupTest() { - if _, err := os.Stat("testdata"); os.IsNotExist(err) { - s.NoError(os.MkdirAll("testdata", 0755)) - } -} - -func (s *IOTestSuite) TearDownTest() { - s.NoError(os.RemoveAll("testdata")) -} - -func (s *IOTestSuite) TestWriteCreatesFileWithCorrectContent() { - path := "testdata/write_test.txt" +func TestWriteCreatesFileWithCorrectContent(t *testing.T) { + path := filepath.Join(t.TempDir(), "write_test.txt") data := "Hello, World!" permission := os.FileMode(0644) - s.NoError(Write(path, data, permission)) + must.NoError(t, Write(path, data, permission)) content, err := Read(path) - s.NoError(err) - s.Equal(data, content) + check.NoError(t, err) + check.Equal(t, content, data) } -func (s *IOTestSuite) TestWriteAppendAppendsToFile() { - path := "testdata/append_test.txt" +func TestWriteAppendAppendsToFile(t *testing.T) { + path := filepath.Join(t.TempDir(), "append_test.txt") initialData := "Hello" appendData := ", World!" - s.NoError(Write(path, initialData, 0644)) - s.NoError(WriteAppend(path, appendData, 0644)) + must.NoError(t, Write(path, initialData, 0644)) + must.NoError(t, WriteAppend(path, appendData, 0644)) content, err := Read(path) - s.NoError(err) - s.Equal("Hello, World!", content) + check.NoError(t, err) + check.Equal(t, content, "Hello, World!") } -// archiveExts 归档格式,支持多文件压缩 +// archiveExts 归档格式,支持多文件 var archiveExts = []string{".zip", ".tar", ".tar.gz", ".tgz", ".tar.bz2", ".tar.xz", ".tar.zst", ".7z"} -// singleExts 单文件压缩格式,仅支持压缩单个文件 +// singleExts 只能压缩单个文件的格式 var singleExts = []string{".gz", ".bz2", ".xz", ".zst"} -func (s *IOTestSuite) TestCompress() { - abs, err := filepath.Abs("testdata") - s.NoError(err) +func TestCompress(t *testing.T) { + abs := t.TempDir() src := []string{"compress_test1.txt", "compress_test2.txt"} - s.NoError(Write(filepath.Join(abs, src[0]), "File 1", 0644)) - s.NoError(Write(filepath.Join(abs, src[1]), "File 2", 0644)) + must.NoError(t, Write(filepath.Join(abs, src[0]), "File 1", 0644)) + must.NoError(t, Write(filepath.Join(abs, src[1]), "File 2", 0644)) for _, ext := range archiveExts { - s.NoError(Compress(abs, src, filepath.Join(abs, "compress_test"+ext)), ext) + t.Run(ext, func(t *testing.T) { + check.NoError(t, Compress(abs, src, filepath.Join(abs, "compress_test"+ext))) + }) } for _, ext := range singleExts { - s.NoError(Compress(abs, src[:1], filepath.Join(abs, "compress_single"+ext)), ext) - s.Error(Compress(abs, src, filepath.Join(abs, "compress_multi"+ext)), ext) + t.Run(ext, func(t *testing.T) { + check.NoError(t, Compress(abs, src[:1], filepath.Join(abs, "compress_single"+ext))) + // 单文件格式装不下多个文件 + check.Error(t, Compress(abs, src, filepath.Join(abs, "compress_multi"+ext))) + }) } } -func (s *IOTestSuite) TestUnCompress() { - abs, err := filepath.Abs("testdata") - s.NoError(err) +func TestUnCompress(t *testing.T) { + abs := t.TempDir() src := []string{"uncompress_test1.txt", "uncompress_test2.txt"} - s.NoError(Write(filepath.Join(abs, src[0]), "File 1", 0644)) - s.NoError(Write(filepath.Join(abs, src[1]), "File 2", 0644)) + must.NoError(t, Write(filepath.Join(abs, src[0]), "File 1", 0644)) + must.NoError(t, Write(filepath.Join(abs, src[1]), "File 2", 0644)) for _, ext := range archiveExts { - dst := filepath.Join(abs, "uncompressed"+strings.ReplaceAll(ext, ".", "_")) - s.NoError(Compress(abs, src, filepath.Join(abs, "uncompress_test"+ext)), ext) - s.NoError(UnCompress(filepath.Join(abs, "uncompress_test"+ext), dst), ext) - data, err := Read(filepath.Join(dst, src[0])) - s.NoError(err, ext) - s.Equal("File 1", data, ext) - data, err = Read(filepath.Join(dst, src[1])) - s.NoError(err, ext) - s.Equal("File 2", data, ext) + t.Run(ext, func(t *testing.T) { + dst := filepath.Join(abs, "uncompressed"+strings.ReplaceAll(ext, ".", "_")) + must.NoError(t, Compress(abs, src, filepath.Join(abs, "uncompress_test"+ext))) + must.NoError(t, UnCompress(filepath.Join(abs, "uncompress_test"+ext), dst)) + + data, err := Read(filepath.Join(dst, src[0])) + check.NoError(t, err) + check.Equal(t, data, "File 1") + data, err = Read(filepath.Join(dst, src[1])) + check.NoError(t, err) + check.Equal(t, data, "File 2") + }) } // 单文件压缩格式解压后去掉压缩后缀恢复原文件名 for _, ext := range singleExts { - dst := filepath.Join(abs, "uncompressed_single"+strings.ReplaceAll(ext, ".", "_")) - s.NoError(Compress(abs, src[:1], filepath.Join(abs, src[0]+ext)), ext) - s.NoError(UnCompress(filepath.Join(abs, src[0]+ext), dst), ext) - data, err := Read(filepath.Join(dst, src[0])) - s.NoError(err, ext) - s.Equal("File 1", data, ext) + t.Run(ext, func(t *testing.T) { + dst := filepath.Join(abs, "uncompressed_single"+strings.ReplaceAll(ext, ".", "_")) + must.NoError(t, Compress(abs, src[:1], filepath.Join(abs, src[0]+ext))) + must.NoError(t, UnCompress(filepath.Join(abs, src[0]+ext), dst)) + + data, err := Read(filepath.Join(dst, src[0])) + check.NoError(t, err) + check.Equal(t, data, "File 1") + }) } } -func (s *IOTestSuite) TestListCompress() { - abs, err := filepath.Abs("testdata") - s.NoError(err) +func TestListCompress(t *testing.T) { + abs := t.TempDir() src := []string{"list_archive_test1.txt", "list_archive_test2.txt"} - s.NoError(Write(filepath.Join(abs, src[0]), "File 1", 0644)) - s.NoError(Write(filepath.Join(abs, src[1]), "File 2", 0644)) + must.NoError(t, Write(filepath.Join(abs, src[0]), "File 1", 0644)) + must.NoError(t, Write(filepath.Join(abs, src[1]), "File 2", 0644)) for _, ext := range archiveExts { - s.NoError(Compress(abs, src, filepath.Join(abs, "list_archive_test"+ext)), ext) - list, err := ListCompress(filepath.Join(abs, "list_archive_test"+ext)) - s.NoError(err, ext) - s.Len(list, 2, ext) + t.Run(ext, func(t *testing.T) { + must.NoError(t, Compress(abs, src, filepath.Join(abs, "list_archive_test"+ext))) + list, err := ListCompress(filepath.Join(abs, "list_archive_test"+ext)) + check.NoError(t, err) + check.Len(t, list, 2) + }) } - // 单文件压缩格式返回去掉压缩后缀的文件名 for _, ext := range singleExts { - s.NoError(Compress(abs, src[:1], filepath.Join(abs, src[0]+ext)), ext) - list, err := ListCompress(filepath.Join(abs, src[0]+ext)) - s.NoError(err, ext) - s.Equal([]string{src[0]}, list, ext) + t.Run(ext, func(t *testing.T) { + must.NoError(t, Compress(abs, src[:1], filepath.Join(abs, src[0]+ext))) + list, err := ListCompress(filepath.Join(abs, src[0]+ext)) + check.NoError(t, err) + check.DeepEqual(t, list, []string{src[0]}) + }) } } -func (s *IOTestSuite) TestRemoveDeletesFileOrDirectory() { - path := "testdata/remove_test" - s.NoError(os.MkdirAll(path, 0755)) - s.DirExists(path) +func TestRemoveDeletesFileOrDirectory(t *testing.T) { + path := filepath.Join(t.TempDir(), "remove_test") + must.NoError(t, os.MkdirAll(path, 0755)) + must.True(t, dirExists(path), must.Msgf("前置目录未建成: %s", path)) - s.NoError(Remove(path)) - s.NoDirExists(path) + check.NoError(t, Remove(path)) + check.False(t, dirExists(path), check.Msgf("目录应已删除: %s", path)) } -func (s *IOTestSuite) TestChmodChangesPermissions() { +func TestChmodChangesPermissions(t *testing.T) { if env.IsWindows() { - s.T().Skip("Skipping on Windows") + t.Skip("Skipping on Windows") } - path := "testdata/chmod_test.txt" - s.NoError(Write(path, "test", 0644)) + path := filepath.Join(t.TempDir(), "chmod_test.txt") + must.NoError(t, Write(path, "test", 0644)) - s.NoError(Chmod(path, 0755)) + check.NoError(t, Chmod(path, 0755)) info, err := os.Stat(path) - s.NoError(err) - s.Equal(os.FileMode(0755), info.Mode().Perm()) + must.NoError(t, err) + check.Equal(t, info.Mode().Perm(), os.FileMode(0755)) } -func (s *IOTestSuite) TestChownChangesOwner() { +func TestChownChangesOwner(t *testing.T) { if env.IsWindows() { - s.T().Skip("Skipping on Windows") + t.Skip("Skipping on Windows") } - path := "testdata/chown_test.txt" - s.NoError(Write(path, "test", 0644)) + path := filepath.Join(t.TempDir(), "chown_test.txt") + must.NoError(t, Write(path, "test", 0644)) - s.NoError(Chown(path, "root", "root")) + // 校验属主是否真的变了需要 root,这里只能确认命令执行成功 + check.NoError(t, Chown(path, "root", "root")) } -func (s *IOTestSuite) TestExistsReturnsTrueForExistingPath() { - path := "testdata/exists_test.txt" - s.NoError(Write(path, "test", 0644)) - s.True(Exists(path)) +func TestExistsReturnsTrueForExistingPath(t *testing.T) { + path := filepath.Join(t.TempDir(), "exists_test.txt") + must.NoError(t, Write(path, "test", 0644)) + check.True(t, Exists(path), check.Msgf("路径应存在: %s", path)) } -func (s *IOTestSuite) TestExistsReturnsFalseForNonExistingPath() { - path := "testdata/nonexistent.txt" - s.False(Exists(path)) +func TestExistsReturnsFalseForNonExistingPath(t *testing.T) { + path := filepath.Join(t.TempDir(), "nonexistent.txt") + check.False(t, Exists(path), check.Msgf("路径不应存在: %s", path)) } -func (s *IOTestSuite) TestEmptyReturnsTrueForEmptyDirectory() { - path := "testdata/empty_test" - s.NoError(os.MkdirAll(path, 0755)) - s.True(Empty(path)) +func TestEmptyReturnsTrueForEmptyDirectory(t *testing.T) { + path := filepath.Join(t.TempDir(), "empty_test") + must.NoError(t, os.MkdirAll(path, 0755)) + check.True(t, Empty(path), check.Msgf("目录应为空: %s", path)) } -func (s *IOTestSuite) TestEmptyReturnsFalseForNonEmptyDirectory() { - path := "testdata/nonempty_test" - s.NoError(os.MkdirAll(path, 0755)) - s.NoError(Write(filepath.Join(path, "file.txt"), "test", 0644)) - s.False(Empty(path)) +func TestEmptyReturnsFalseForNonEmptyDirectory(t *testing.T) { + path := filepath.Join(t.TempDir(), "nonempty_test") + must.NoError(t, os.MkdirAll(path, 0755)) + must.NoError(t, Write(filepath.Join(path, "file.txt"), "test", 0644)) + check.False(t, Empty(path), check.Msgf("目录不应为空: %s", path)) } -func (s *IOTestSuite) TestMvMovesFile() { - src := "testdata/mv_src.txt" - dst := "testdata/mv_dst.txt" - s.NoError(Write(src, "test", 0644)) +func TestMvMovesFile(t *testing.T) { + dir := t.TempDir() + src := filepath.Join(dir, "mv_src.txt") + dst := filepath.Join(dir, "mv_dst.txt") + must.NoError(t, Write(src, "test", 0644)) - s.NoError(Mv(src, dst)) - s.FileExists(dst) - s.NoFileExists(src) + check.NoError(t, Mv(src, dst)) + check.True(t, fileExists(dst), check.Msgf("目标文件应存在: %s", dst)) + check.False(t, fileExists(src), check.Msgf("源文件应已移走: %s", src)) } -func (s *IOTestSuite) TestCpCopiesFile() { - src := "testdata/cp_src.txt" - dst := "testdata/cp_dst.txt" - s.NoError(Write(src, "test", 0644)) +func TestCpCopiesFile(t *testing.T) { + dir := t.TempDir() + src := filepath.Join(dir, "cp_src.txt") + dst := filepath.Join(dir, "cp_dst.txt") + must.NoError(t, Write(src, "test", 0644)) - s.NoError(Cp(src, dst)) - s.FileExists(dst) - s.FileExists(src) + check.NoError(t, Cp(src, dst)) + check.True(t, fileExists(dst), check.Msgf("目标文件应存在: %s", dst)) + check.True(t, fileExists(src), check.Msgf("源文件应保留: %s", src)) } -func (s *IOTestSuite) TestSizeReturnsCorrectSize() { - path := "testdata/size_test.txt" +func TestSizeReturnsCorrectSize(t *testing.T) { + path := filepath.Join(t.TempDir(), "size_test.txt") data := "12345" - s.NoError(Write(path, data, 0644)) + must.NoError(t, Write(path, data, 0644)) size, err := Size(path) - s.NoError(err) - s.Equal(int64(len(data)), size) + check.NoError(t, err) + check.Equal(t, size, int64(len(data))) } -func (s *IOTestSuite) TestIsDirReturnsTrueForDirectory() { - path := "testdata/isdir_test" - s.NoError(os.MkdirAll(path, 0755)) - s.True(IsDir(path)) +func TestIsDirReturnsTrueForDirectory(t *testing.T) { + path := filepath.Join(t.TempDir(), "isdir_test") + must.NoError(t, os.MkdirAll(path, 0755)) + check.True(t, IsDir(path), check.Msgf("应识别为目录: %s", path)) } -func (s *IOTestSuite) TestIsDirReturnsFalseForFile() { - path := "testdata/isfile_test.txt" - s.NoError(Write(path, "test", 0644)) - s.False(IsDir(path)) +func TestIsDirReturnsFalseForFile(t *testing.T) { + path := filepath.Join(t.TempDir(), "isfile_test.txt") + must.NoError(t, Write(path, "test", 0644)) + check.False(t, IsDir(path), check.Msgf("不应识别为目录: %s", path)) } diff --git a/pkg/io/path.go b/pkg/io/path.go index 53e4aa15c..e5e2928ed 100644 --- a/pkg/io/path.go +++ b/pkg/io/path.go @@ -54,11 +54,11 @@ func unlockAttr(path string) []lockedFile { var locked []lockedFile _ = filepath.WalkDir(path, func(p string, d os.DirEntry, err error) error { if err != nil || d.IsDir() { - return nil + return nil //nolint:nilerr } - file, err := os.OpenFile(p, os.O_RDONLY, 0) + file, err := os.OpenFile(p, os.O_RDONLY, 0) //nolint:gosec if err != nil { - return nil + return nil //nolint:nilerr } var attrs uint32 if ok, _ := chattr.IsAttr(file, chattr.FS_IMMUTABLE_FL); ok { diff --git a/pkg/io/path_test.go b/pkg/io/path_test.go index 953e3514c..9a4de0445 100644 --- a/pkg/io/path_test.go +++ b/pkg/io/path_test.go @@ -5,13 +5,13 @@ import ( "path/filepath" "testing" - "github.com/stretchr/testify/assert" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" "github.com/acepanel/panel/v3/pkg/chattr" ) -// setImmutable 尝试为文件设置 immutable 属性,返回是否设置成功 -// 需要 root 权限且文件系统支持,否则返回 false 用于跳过测试 +// setImmutable 设置 immutable,需 root 且文件系统支持,失败返回 false 用于跳过用例 func setImmutable(path string) bool { file, err := os.OpenFile(path, os.O_RDONLY, 0) if err != nil { @@ -25,7 +25,6 @@ func setImmutable(path string) bool { return ok } -// isImmutable 判断文件是否设置了 immutable 属性 func isImmutable(path string) bool { file, err := os.OpenFile(path, os.O_RDONLY, 0) if err != nil { @@ -36,73 +35,60 @@ func isImmutable(path string) bool { return ok } -// TestChmodNormalDir 无锁定文件时 Chmod 应递归生效,验证 withUnlock 正常路径不影响行为 func TestChmodNormalDir(t *testing.T) { - tmpDir, err := os.MkdirTemp("", "test_chmod_normal") - assert.NoError(t, err) - defer func() { _ = os.RemoveAll(tmpDir) }() + tmpDir := t.TempDir() sub := filepath.Join(tmpDir, "sub") - assert.NoError(t, os.Mkdir(sub, 0755)) + must.NoError(t, os.Mkdir(sub, 0755)) file := filepath.Join(sub, "f.txt") - assert.NoError(t, Write(file, "x", 0644)) + must.NoError(t, Write(file, "x", 0644)) - assert.NoError(t, Chmod(tmpDir, 0700)) + check.NoError(t, Chmod(tmpDir, 0700)) - // 递归应作用到子目录下的文件 info, err := os.Stat(file) - assert.NoError(t, err) - assert.Equal(t, os.FileMode(0700), info.Mode().Perm()) + must.NoError(t, err) + check.Equal(t, info.Mode().Perm(), os.FileMode(0700)) } -// TestUnlockRelockAttr 解锁应仅记录被锁定的文件,且能原样恢复 func TestUnlockRelockAttr(t *testing.T) { - tmpDir, err := os.MkdirTemp("", "test_unlock_attr") - assert.NoError(t, err) - defer func() { _ = os.RemoveAll(tmpDir) }() + tmpDir := t.TempDir() locked := filepath.Join(tmpDir, "locked.txt") normal := filepath.Join(tmpDir, "normal.txt") - assert.NoError(t, Write(locked, "a", 0644)) - assert.NoError(t, Write(normal, "b", 0644)) + must.NoError(t, Write(locked, "a", 0644)) + must.NoError(t, Write(normal, "b", 0644)) if !setImmutable(locked) { t.Skip("当前环境不支持设置 immutable 属性(需 root 与支持的文件系统)") } defer unlockAttr(tmpDir) // 确保用例结束后目录可被清理 - // 解锁后只应记录被锁定文件,且属性已解除 files := unlockAttr(tmpDir) - assert.Len(t, files, 1) - assert.Equal(t, locked, files[0].path) - assert.False(t, isImmutable(locked)) + must.Len(t, files, 1) + check.Equal(t, files[0].path, locked) + check.False(t, isImmutable(locked), check.Msgf("应已解除 immutable: %s", locked)) - // 恢复后被锁定文件应重新带上 immutable relockAttr(files) - assert.True(t, isImmutable(locked)) + check.True(t, isImmutable(locked), check.Msgf("应已恢复 immutable: %s", locked)) } -// TestChmodWithImmutable 目录下存在 immutable 文件时 Chmod 仍应成功,并在完成后恢复锁定 func TestChmodWithImmutable(t *testing.T) { - tmpDir, err := os.MkdirTemp("", "test_chmod_immutable") - assert.NoError(t, err) - defer func() { _ = os.RemoveAll(tmpDir) }() + tmpDir := t.TempDir() userIni := filepath.Join(tmpDir, ".user.ini") - assert.NoError(t, Write(userIni, "open_basedir=/tmp/", 0644)) + must.NoError(t, Write(userIni, "open_basedir=/tmp/", 0644)) if !setImmutable(userIni) { t.Skip("当前环境不支持设置 immutable 属性(需 root 与支持的文件系统)") } defer unlockAttr(tmpDir) - // 递归 chmod 会被 immutable 文件阻挡,withUnlock 应解锁重试并成功 - assert.NoError(t, Chmod(tmpDir, 0700)) + // 递归 chmod 会被 immutable 阻挡,withUnlock 应解锁重试 + check.NoError(t, Chmod(tmpDir, 0700)) info, err := os.Stat(tmpDir) - assert.NoError(t, err) - assert.Equal(t, os.FileMode(0700), info.Mode().Perm()) + must.NoError(t, err) + check.Equal(t, info.Mode().Perm(), os.FileMode(0700)) - // immutable 保护应已恢复 - assert.True(t, isImmutable(userIni)) + check.True(t, isImmutable(userIni), check.Msgf("应已恢复 immutable: %s", userIni)) } diff --git a/pkg/io/search_test.go b/pkg/io/search_test.go index 20ba104c8..3470e8437 100644 --- a/pkg/io/search_test.go +++ b/pkg/io/search_test.go @@ -3,33 +3,17 @@ package io import ( "os" "path/filepath" + "slices" "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) -type SearchTestSuite struct { - suite.Suite -} - -func TestSearchTestSuite(t *testing.T) { - suite.Run(t, &SearchTestSuite{}) -} - -func (s *SearchTestSuite) SetupTest() { - if _, err := os.Stat("testdata"); os.IsNotExist(err) { - s.NoError(os.MkdirAll("testdata", 0755)) - } -} - -func (s *SearchTestSuite) TearDownTest() { - s.NoError(os.RemoveAll("testdata")) -} - -func (s *SearchTestSuite) TestSearchX() { - testDir := "testdata/search_test" - s.NoError(os.MkdirAll(testDir, 0755)) - s.NoError(os.MkdirAll(filepath.Join(testDir, "subdir"), 0755)) +func TestSearchX(t *testing.T) { + testDir := filepath.Join(t.TempDir(), "search_test") + must.NoError(t, os.MkdirAll(testDir, 0755)) + must.NoError(t, os.MkdirAll(filepath.Join(testDir, "subdir"), 0755)) testFiles := map[string]string{ "test_file1.txt": "内容1", @@ -40,39 +24,35 @@ func (s *SearchTestSuite) TestSearchX() { } for path, content := range testFiles { - s.NoError(Write(filepath.Join(testDir, path), content, 0644)) + must.NoError(t, Write(filepath.Join(testDir, path), content, 0644)) } - s.Run("正常搜索", func() { + t.Run("正常搜索", func(t *testing.T) { entries, err := SearchX(testDir, "test", false) - s.NoError(err) + must.NoError(t, err) - names := make(map[string]bool) + names := make([]string, 0, len(entries)) for _, entry := range entries { - names[entry.Name()] = true - s.NotEmpty(entry.Name()) + names = append(names, entry.Name()) info, err := entry.Info() - s.NoError(err) - s.NotNil(info) - s.Equal(entry.Type(), info.Mode().Type()) - s.Equal(entry.IsDir(), info.IsDir()) + must.NoError(t, err) + check.Equal(t, info.Mode().Type(), entry.Type()) + check.Equal(t, info.IsDir(), entry.IsDir()) } + slices.Sort(names) - s.True(names["test_file1.txt"]) - s.True(names["test_file2.log"]) - s.True(names["another_test.txt"]) - s.False(names["nested_test.txt"]) // 不应该找到子目录中的文件 - s.False(names["unrelated.dat"]) // 不应该找到不匹配的文件 + // 子目录里的 nested_test.txt 与不匹配的 unrelated.dat 都不该出现 + check.DeepEqual(t, names, []string{"another_test.txt", "test_file1.txt", "test_file2.log"}) }) - s.Run("无匹配结果", func() { + t.Run("无匹配结果", func(t *testing.T) { entries, err := SearchX(testDir, "nonexistent", false) - s.NoError(err) - s.Empty(entries) + check.NoError(t, err) + check.Empty(t, entries) }) - s.Run("路径不存在", func() { + t.Run("路径不存在", func(t *testing.T) { _, err := SearchX("/path/does/not/exist", "test", false) - s.Error(err) + check.Error(t, err) }) } diff --git a/pkg/ipdb/reader.go b/pkg/ipdb/reader.go index 82c1568e2..dc11e2391 100644 --- a/pkg/ipdb/reader.go +++ b/pkg/ipdb/reader.go @@ -120,7 +120,7 @@ func (r *Reader) search(ip []byte, bitCount int) (int, error) { node = r.v4offset } - for i := 0; i < bitCount; i++ { + for i := range bitCount { if node > r.nodeCount { break } diff --git a/pkg/ipdb/reader_test.go b/pkg/ipdb/reader_test.go index 2c5ed3b06..0d4e2ecd5 100644 --- a/pkg/ipdb/reader_test.go +++ b/pkg/ipdb/reader_test.go @@ -1,128 +1,107 @@ package ipdb import ( + "io/fs" "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) const testDBPath = "../geoip/ipipfree.ipdb" -type ReaderSuite struct { - suite.Suite - r *Reader -} - -func (s *ReaderSuite) SetupSuite() { +func newReader(t *testing.T) *Reader { + t.Helper() r, err := Open(testDBPath) - s.Require().NoError(err) - s.Require().NotNil(r) - s.r = r + must.NoError(t, err) + t.Cleanup(func() { check.NoError(t, r.Close()) }) + return r } -func (s *ReaderSuite) TearDownSuite() { - s.Require().NoError(s.r.Close()) +// mustFind 查询并校验返回值个数与字段数一致——库内容会变,只有这个数量关系恒定 +func mustFind(t *testing.T, r *Reader, ip string) []string { + t.Helper() + result, err := r.Find(ip, "CN") + must.NoError(t, err) + must.Len(t, result, len(r.Fields())) + return result } -func TestReaderSuite(t *testing.T) { - suite.Run(t, new(ReaderSuite)) -} - -// ========== Open ========== - -func (s *ReaderSuite) TestOpen_InvalidPath() { +func TestOpen_InvalidPath(t *testing.T) { _, err := Open("/nonexistent/path.ipdb") - s.Error(err) + check.ErrorIs(t, err, fs.ErrNotExist) } -// ========== Fields ========== - -func (s *ReaderSuite) TestFields() { - fields := s.r.Fields() - s.NotEmpty(fields) - s.T().Logf("fields: %v", fields) +func TestFields(t *testing.T) { + fields := newReader(t).Fields() + check.NotEmpty(t, fields) + t.Logf("fields: %v", fields) } -// ========== Find ========== - -func (s *ReaderSuite) TestFind_IPv4() { - result, err := s.r.Find("114.114.114.114", "CN") - s.NoError(err) - s.NotEmpty(result) - s.T().Logf("114.114.114.114 -> %v", result) +func TestFind_IPv4(t *testing.T) { + r := newReader(t) + for _, ip := range []string{"114.114.114.114", "8.8.8.8"} { + t.Run(ip, func(t *testing.T) { + result := mustFind(t, r, ip) + check.NotEmpty(t, result[0], check.Msgf("%s -> %v", ip, result)) + }) + } } -func (s *ReaderSuite) TestFind_IPv4_Foreign() { - result, err := s.r.Find("8.8.8.8", "CN") - s.NoError(err) - s.NotEmpty(result) - s.T().Logf("8.8.8.8 -> %v", result) +func TestFind_IPv6(t *testing.T) { + r := newReader(t) + // 库可能不含 IPv6 数据,允许返回错误,但不能 panic + check.NotPanics(t, func() { _, _ = r.Find("2001:4860:4860::8888", "CN") }) } -func (s *ReaderSuite) TestFind_IPv6() { - // IPv6 查找,可能不支持但不应 panic - _, _ = s.r.Find("2001:4860:4860::8888", "CN") +func TestFind_InvalidIP(t *testing.T) { + _, err := newReader(t).Find("not-an-ip", "CN") + check.ErrorIs(t, err, ErrInvalidIP) } -func (s *ReaderSuite) TestFind_InvalidIP() { - _, err := s.r.Find("not-an-ip", "CN") - s.ErrorIs(err, ErrInvalidIP) +func TestFind_InvalidLanguage(t *testing.T) { + _, err := newReader(t).Find("8.8.8.8", "INVALID") + check.ErrorIs(t, err, ErrNoLanguage) } -func (s *ReaderSuite) TestFind_InvalidLanguage() { - _, err := s.r.Find("8.8.8.8", "INVALID") - s.ErrorIs(err, ErrNoLanguage) +func TestReload(t *testing.T) { + r := newReader(t) + must.NoError(t, r.Reload(testDBPath)) + + check.NotEmpty(t, mustFind(t, r, "114.114.114.114")[0]) } -// ========== Reload ========== - -func (s *ReaderSuite) TestReload() { - err := s.r.Reload(testDBPath) - s.NoError(err) - - // reload 后查询仍正常 - result, err := s.r.Find("114.114.114.114", "CN") - s.NoError(err) - s.NotEmpty(result) -} - -func (s *ReaderSuite) TestReload_InvalidPath() { - err := s.r.Reload("/nonexistent/path.ipdb") - s.Error(err) +func TestReload_InvalidPath(t *testing.T) { + r := newReader(t) + check.ErrorIs(t, r.Reload("/nonexistent/path.ipdb"), fs.ErrNotExist) // 失败后原数据仍可用 - result, err := s.r.Find("114.114.114.114", "CN") - s.NoError(err) - s.NotEmpty(result) + check.NotEmpty(t, mustFind(t, r, "114.114.114.114")[0]) } -// ========== Close ========== - -func (s *ReaderSuite) TestClose_UseAfterClose() { +func TestClose_UseAfterClose(t *testing.T) { r, err := Open(testDBPath) - s.Require().NoError(err) + must.NoError(t, err) - s.NoError(r.Close()) + check.NoError(t, r.Close()) _, err = r.Find("8.8.8.8", "CN") - s.ErrorIs(err, ErrClosed) + check.ErrorIs(t, err, ErrClosed) } -func (s *ReaderSuite) TestClose_DoubleClose() { +func TestClose_DoubleClose(t *testing.T) { r, err := Open(testDBPath) - s.Require().NoError(err) + must.NoError(t, err) - s.NoError(r.Close()) - s.NoError(r.Close()) + check.NoError(t, r.Close()) + check.NoError(t, r.Close()) } -func (s *ReaderSuite) TestClose_NilReceiver() { +func TestClose_NilReceiver(t *testing.T) { var r *Reader - s.NoError(r.Close()) + check.NoError(t, r.Close()) } -// ========== Benchmark ========== - func BenchmarkFind(b *testing.B) { r, err := Open(testDBPath) if err != nil { diff --git a/pkg/network/network_test.go b/pkg/network/network_test.go index 0f91e54f4..de7a3e2db 100644 --- a/pkg/network/network_test.go +++ b/pkg/network/network_test.go @@ -3,8 +3,8 @@ package network import ( "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) func TestValidate(t *testing.T) { @@ -26,12 +26,12 @@ func TestValidate(t *testing.T) { {name: "both disabled", change: func(config *Config) { config.IPv4 = FamilyConfig{Mode: ModeDisabled} }}, {name: "invalid MTU", change: func(config *Config) { config.MTU = 67 }}, } - require.NoError(t, Validate(valid)) + must.NoError(t, Validate(valid)) for _, test := range tests { t.Run(test.name, func(t *testing.T) { config := valid test.change(&config) - assert.Error(t, Validate(config)) + check.ErrorIs(t, Validate(config), ErrValidation) }) } } @@ -46,7 +46,17 @@ iface eth0 inet dhcp iface eth0 inet6 static address 2001:db8::10/64 `) - require.Len(t, file.stanzas, 2) - assert.Equal(t, ModeAuto, backend.family(file.stanzas, "inet").Mode) - assert.Equal(t, []string{"2001:db8::10/64"}, backend.family(file.stanzas, "inet6").Addresses) + must.Len(t, file.stanzas, 2) + check.DeepEqual(t, backend.family(file.stanzas, "inet"), FamilyConfig{ + Mode: ModeAuto, + Addresses: []string{}, + AutoDNS: true, + DNS: []string{"1.1.1.1"}, + }) + check.DeepEqual(t, backend.family(file.stanzas, "inet6"), FamilyConfig{ + Mode: ModeManual, + Addresses: []string{"2001:db8::10/64"}, + AutoDNS: true, + DNS: []string{}, + }) } diff --git a/pkg/notify/smtp.go b/pkg/notify/smtp.go index f747b9c96..259a2038b 100644 --- a/pkg/notify/smtp.go +++ b/pkg/notify/smtp.go @@ -78,7 +78,7 @@ func (s *smtpNotifier) Send(ctx context.Context, msg *Message) error { mail.WithTimeout(30 * time.Second), mail.WithTLSConfig(&tls.Config{ ServerName: s.conf.Host, - InsecureSkipVerify: s.conf.SkipVerify, // nolint:gosec + InsecureSkipVerify: s.conf.SkipVerify, //nolint:gosec MinVersion: tls.VersionTLS11, }), } diff --git a/pkg/ntp/ntp.go b/pkg/ntp/ntp.go index 9e4ee48e6..7666d28c7 100644 --- a/pkg/ntp/ntp.go +++ b/pkg/ntp/ntp.go @@ -34,7 +34,7 @@ func GetBuiltinServers() []string { func Now(address ...string) (time.Time, error) { if len(address) > 0 && address[0] != "" { if now, err := ntp.Time(address[0]); err != nil { - return time.Now(), fmt.Errorf("%w: %s", ErrNotReachable, err) + return time.Now(), fmt.Errorf("%w: %w", ErrNotReachable, err) } else { return now, nil } @@ -47,7 +47,7 @@ func Now(address ...string) (time.Time, error) { now, err := ntp.Time(best) if err != nil { - return time.Now(), fmt.Errorf("%w: %s", ErrNotReachable, err) + return time.Now(), fmt.Errorf("%w: %w", ErrNotReachable, err) } return now, nil diff --git a/pkg/ntp/ntp_test.go b/pkg/ntp/ntp_test.go index 78f971ab7..2ea8d0611 100644 --- a/pkg/ntp/ntp_test.go +++ b/pkg/ntp/ntp_test.go @@ -4,46 +4,44 @@ import ( "testing" "time" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/libtnb/assert/check" "github.com/libtnb/utils/env" - "github.com/stretchr/testify/suite" ) -type NTPTestSuite struct { - suite.Suite +func TestNowWithDefaultAddresses(t *testing.T) { + now, err := Now() + if err != nil { + t.Logf("内置 NTP 服务器不可达,回落本地时间: %v", err) + } + check.DeepEqual(t, now, time.Now(), cmpopts.EquateApproxTime(time.Minute)) } -func TestNTPTestSuite(t *testing.T) { - suite.Run(t, &NTPTestSuite{}) -} - -func (suite *NTPTestSuite) TestNowWithDefaultAddresses() { - now, _ := Now() - suite.WithinDuration(time.Now(), now, time.Minute) -} - -func (suite *NTPTestSuite) TestNowWithCustomAddress() { +func TestNowWithCustomAddress(t *testing.T) { now, err := Now("time.windows.com") - suite.NoError(err) - suite.WithinDuration(time.Now(), now, time.Minute) + check.NoError(t, err) + check.DeepEqual(t, now, time.Now(), cmpopts.EquateApproxTime(time.Minute)) } -func (suite *NTPTestSuite) TestNowWithInvalidAddress() { - _, err := Now("invalid.address") - suite.Error(err) +func TestNowWithInvalidAddress(t *testing.T) { + now, err := Now("invalid.address") + check.ErrorIs(t, err, ErrNotReachable) + // 失败时回落到本地时间,不是零值 + check.DeepEqual(t, now, time.Now(), cmpopts.EquateApproxTime(time.Minute)) } -func (suite *NTPTestSuite) TestUpdateSystemTime() { +func TestUpdateSystemTime(t *testing.T) { if env.IsWindows() { - suite.T().Skip("Skipping on Windows") + t.Skip("Skipping on Windows") } err := UpdateSystemTime(time.Now()) - suite.NoError(err) + check.NoError(t, err) } -func (suite *NTPTestSuite) TestUpdateSystemTimeZone() { +func TestUpdateSystemTimeZone(t *testing.T) { if env.IsWindows() { - suite.T().Skip("Skipping on Windows") + t.Skip("Skipping on Windows") } err := UpdateSystemTimeZone("UTC") - suite.NoError(err) + check.NoError(t, err) } diff --git a/pkg/ntp/system.go b/pkg/ntp/system.go index 0c9ab0df6..b9ebcd47a 100644 --- a/pkg/ntp/system.go +++ b/pkg/ntp/system.go @@ -85,6 +85,7 @@ func GetSystemNTPConfig() (*SystemNTPConfig, error) { return config, err } config.Servers = servers + case NTPServiceUnknown: } return config, nil diff --git a/pkg/os/os.go b/pkg/os/os.go index a27e0939e..51033aa83 100644 --- a/pkg/os/os.go +++ b/pkg/os/os.go @@ -2,6 +2,7 @@ package os import ( "bufio" + "context" "fmt" "net" "os" @@ -54,7 +55,7 @@ func IsRHEL() bool { } // alinux Alibaba Cloud Linux // hce Huawei Cloud EulerOS - // openEuler openEuler + // openEuler 欧拉 id, idLike := osRelease["ID"], osRelease["ID_LIKE"] return id == "rhel" || id == "almalinux" || id == "rocky" || id == "alinux" || id == "tencentos" || id == "opencloudos" || strings.Contains(idLike, "rhel") } @@ -124,8 +125,8 @@ func IsEOL() bool { } func TCPPortInUse(port uint) bool { - addr := fmt.Sprintf(":%d", port) - conn, err := net.Listen("tcp", addr) + var lc net.ListenConfig + conn, err := lc.Listen(context.Background(), "tcp", fmt.Sprintf(":%d", port)) if err != nil { return true } @@ -134,8 +135,8 @@ func TCPPortInUse(port uint) bool { } func UDPPortInUse(port uint) bool { - addr := fmt.Sprintf(":%d", port) - conn, err := net.ListenPacket("udp", addr) + var lc net.ListenConfig + conn, err := lc.ListenPacket(context.Background(), "udp", fmt.Sprintf(":%d", port)) if err != nil { return true } diff --git a/pkg/os/os_test.go b/pkg/os/os_test.go index bab89397c..6e39eb720 100644 --- a/pkg/os/os_test.go +++ b/pkg/os/os_test.go @@ -3,21 +3,13 @@ package os import ( "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" ) -type OSHelperTestSuite struct { - suite.Suite +func TestIsDebian(t *testing.T) { + check.True(t, IsDebian(), check.Msgf("os-release: %v", readOSRelease())) } -func TestOSHelperTestSuite(t *testing.T) { - suite.Run(t, &OSHelperTestSuite{}) -} - -func (s *OSHelperTestSuite) TestIsDebian() { - s.True(IsDebian()) -} - -func (s *OSHelperTestSuite) TestIsRHEL() { - s.False(IsRHEL()) +func TestIsRHEL(t *testing.T) { + check.False(t, IsRHEL(), check.Msgf("os-release: %v", readOSRelease())) } diff --git a/pkg/rsacrypto/rsacrypto.go b/pkg/rsacrypto/rsacrypto.go index 74353d8d7..8bdd95aeb 100644 --- a/pkg/rsacrypto/rsacrypto.go +++ b/pkg/rsacrypto/rsacrypto.go @@ -29,7 +29,7 @@ func EncryptData(publicKey *rsa.PublicKey, data []byte) (string, error) { nil, ) if err != nil { - return "", fmt.Errorf("encryption failed: %v", err) + return "", fmt.Errorf("encryption failed: %w", err) } return base64.StdEncoding.EncodeToString(ciphertext), nil @@ -39,7 +39,7 @@ func EncryptData(publicKey *rsa.PublicKey, data []byte) (string, error) { func DecryptData(privateKey *rsa.PrivateKey, ciphertext string) ([]byte, error) { data, err := base64.StdEncoding.DecodeString(ciphertext) if err != nil { - return nil, fmt.Errorf("failed to decode base64: %v", err) + return nil, fmt.Errorf("failed to decode base64: %w", err) } plaintext, err := rsa.DecryptOAEP( @@ -50,7 +50,7 @@ func DecryptData(privateKey *rsa.PrivateKey, ciphertext string) ([]byte, error) nil, ) if err != nil { - return nil, fmt.Errorf("decryption failed: %v", err) + return nil, fmt.Errorf("decryption failed: %w", err) } return plaintext, nil @@ -72,7 +72,7 @@ func PrivateKeyToString(privateKey *rsa.PrivateKey) (string, error) { func PublicKeyToString(publicKey *rsa.PublicKey) (string, error) { publicKeyBytes, err := x509.MarshalPKIXPublicKey(publicKey) if err != nil { - return "", fmt.Errorf("failed to marshal public key: %v", err) + return "", fmt.Errorf("failed to marshal public key: %w", err) } publicKeyPEM := pem.EncodeToMemory( diff --git a/pkg/rsacrypto/rsacrypto_test.go b/pkg/rsacrypto/rsacrypto_test.go index c56699b71..3216cf446 100644 --- a/pkg/rsacrypto/rsacrypto_test.go +++ b/pkg/rsacrypto/rsacrypto_test.go @@ -3,37 +3,29 @@ package rsacrypto import ( "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) -type RSATestSuite struct { - suite.Suite -} - -func TestRSATestSuite(t *testing.T) { - suite.Run(t, &RSATestSuite{}) -} - -func (suite *RSATestSuite) TestRSA() { - // 生成RSA密钥对 +func TestRSA(t *testing.T) { privateKey, err := GenerateKey() - suite.NoError(err) - suite.NotEmpty(privateKey) - suite.NotEmpty(privateKey.PublicKey) + must.NoError(t, err) + check.Equal(t, privateKey.Size(), keySize/8) - // 提取密钥对 - suite.NotEmpty(PrivateKeyToString(privateKey)) - suite.NotEmpty(PublicKeyToString(&privateKey.PublicKey)) + privateStr, err := PrivateKeyToString(privateKey) + check.NoError(t, err) + check.Contains(t, privateStr, "-----BEGIN RSA PRIVATE KEY-----") + publicStr, err := PublicKeyToString(&privateKey.PublicKey) + check.NoError(t, err) + check.Contains(t, publicStr, "-----BEGIN PUBLIC KEY-----") message := []byte("AcePanel") - // 加密数据 ciphertext, err := EncryptData(&privateKey.PublicKey, message) - suite.NoError(err) - suite.NotEmpty(ciphertext) + must.NoError(t, err) + check.NotEmpty(t, ciphertext) - // 解密数据 decrypted, err := DecryptData(privateKey, ciphertext) - suite.NoError(err) - suite.NotEmpty(decrypted) + must.NoError(t, err) + check.Equal(t, string(decrypted), string(message)) } diff --git a/pkg/shell/exec.go b/pkg/shell/exec.go index fed0c94c3..1534e5059 100644 --- a/pkg/shell/exec.go +++ b/pkg/shell/exec.go @@ -1,3 +1,4 @@ +//nolint:noctx package shell import ( diff --git a/pkg/shell/pty.go b/pkg/shell/pty.go index a21f57cea..911f6fcd9 100644 --- a/pkg/shell/pty.go +++ b/pkg/shell/pty.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io" + "math" "os" "os/exec" "syscall" @@ -107,7 +108,7 @@ func (t *Turn) Handle(ctx context.Context) error { // 判断是否是 resize 消息 if err = json.Unmarshal(data, &resize); err == nil { - if resize.Resize && resize.Columns > 0 && resize.Rows > 0 { + if resize.Resize && resize.Columns > 0 && resize.Rows > 0 && resize.Columns <= math.MaxUint16 && resize.Rows <= math.MaxUint16 { if err = t.Resize(uint16(resize.Rows), uint16(resize.Columns)); err != nil { return fmt.Errorf("failed to resize terminal: %w", err) } diff --git a/pkg/ssh/ssh.go b/pkg/ssh/ssh.go index 8a8ddac8d..81c48c720 100644 --- a/pkg/ssh/ssh.go +++ b/pkg/ssh/ssh.go @@ -33,7 +33,7 @@ func NewSSHClient(conf ClientConfig) (*ssh.Client, error) { config.SetDefaults() config.Timeout = conf.Timeout config.User = conf.User - config.HostKeyCallback = ssh.InsecureIgnoreHostKey() + config.HostKeyCallback = ssh.InsecureIgnoreHostKey() //nolint:gosec switch conf.AuthMethod { case PASSWORD: diff --git a/pkg/ssh/turn.go b/pkg/ssh/turn.go index 47ff8dc53..9114feb90 100644 --- a/pkg/ssh/turn.go +++ b/pkg/ssh/turn.go @@ -83,7 +83,7 @@ func (t *Turn) Handle(ctx context.Context) error { _, data, err := t.ws.Read(ctx) if err != nil { // 通常是客户端关闭连接 - return fmt.Errorf("reading ws message err: %v", err) + return fmt.Errorf("reading ws message err: %w", err) } // 判断是否是 ping 消息 @@ -96,14 +96,14 @@ func (t *Turn) Handle(ctx context.Context) error { if err = json.Unmarshal(data, &resize); err == nil { if resize.Resize && resize.Columns > 0 && resize.Rows > 0 { if err = t.session.WindowChange(resize.Rows, resize.Columns); err != nil { - return fmt.Errorf("change window size err: %v", err) + return fmt.Errorf("change window size err: %w", err) } } continue } if _, err = t.stdin.Write(data); err != nil { - return fmt.Errorf("writing ws message to stdin err: %v", err) + return fmt.Errorf("writing ws message to stdin err: %w", err) } } } diff --git a/pkg/storage/local.go b/pkg/storage/local.go index 811f40600..66867d3e9 100644 --- a/pkg/storage/local.go +++ b/pkg/storage/local.go @@ -134,10 +134,10 @@ func (l *Local) preCheckPath(path string) error { return err } - if uint64(size) > usage.Free { + if size > 0 && uint64(size) > usage.Free { return errors.New("insufficient backup directory space") } - if uint64(files) > usage.InodesFree { + if files > 0 && uint64(files) > usage.InodesFree { return errors.New("insufficient backup directory inode") } diff --git a/pkg/storage/s3sdk/list.go b/pkg/storage/s3sdk/list.go index bc7078c30..86f867d63 100644 --- a/pkg/storage/s3sdk/list.go +++ b/pkg/storage/s3sdk/list.go @@ -62,12 +62,13 @@ func (c *S3) listPage(prefix, delimiter, token string) (listPage, error) { query.Set("continuation-token", token) } - req, err := http.NewRequest(http.MethodGet, c.base+"?"+query.Encode(), nil) + ctx := context.Background() + req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.base+"?"+query.Encode(), nil) if err != nil { return listPage{}, err } - body, _, err := c.do(context.Background(), req, http.StatusOK) + body, _, err := c.do(ctx, req, http.StatusOK) //nolint:bodyclose if err != nil { return listPage{}, err } diff --git a/pkg/storage/s3sdk/object.go b/pkg/storage/s3sdk/object.go index d22fd1dd6..11751396d 100644 --- a/pkg/storage/s3sdk/object.go +++ b/pkg/storage/s3sdk/object.go @@ -3,7 +3,7 @@ package s3sdk import ( "bytes" "context" - "crypto/md5" + "crypto/md5" //nolint:gosec "encoding/base64" "encoding/xml" "fmt" @@ -25,12 +25,13 @@ type ObjectInfo struct { // Stat 通过 HEAD 获取对象元数据;对象不存在时返回的错误可用 IsNotFound 判断 func (c *S3) Stat(key string) (ObjectInfo, error) { - req, err := http.NewRequest(http.MethodHead, c.objectURL(key), nil) + ctx := context.Background() + req, err := http.NewRequestWithContext(ctx, http.MethodHead, c.objectURL(key), nil) if err != nil { return ObjectInfo{}, err } - _, res, err := c.do(context.Background(), req, http.StatusOK) + _, res, err := c.do(ctx, req, http.StatusOK) //nolint:bodyclose if err != nil { return ObjectInfo{}, err } @@ -85,7 +86,8 @@ func (c *S3) deleteBatch(keys []string) error { return err } - req, err := http.NewRequest(http.MethodPost, c.base+"?delete", bytes.NewReader(body)) + ctx := context.Background() + req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.base+"?delete", bytes.NewReader(body)) if err != nil { return err } @@ -93,10 +95,10 @@ func (c *S3) deleteBatch(keys []string) error { req.Header.Set("Content-Type", "application/xml") req.Header.Set("x-amz-content-sha256", sha256Hex(body)) // S3 对 DeleteObjects 强制要求 Content-MD5 - sum := md5.Sum(body) + sum := md5.Sum(body) //nolint:gosec req.Header.Set("Content-MD5", base64.StdEncoding.EncodeToString(sum[:])) - respBody, _, err := c.do(context.Background(), req, http.StatusOK) + respBody, _, err := c.do(ctx, req, http.StatusOK) //nolint:bodyclose if err != nil { return err } diff --git a/pkg/storage/s3sdk/sign.go b/pkg/storage/s3sdk/sign.go index 3aa5bc0f2..d5e273843 100644 --- a/pkg/storage/s3sdk/sign.go +++ b/pkg/storage/s3sdk/sign.go @@ -157,7 +157,7 @@ func canonicalAndSignedHeaders(req *http.Request) (canonical, signed string) { func uriEncode(s string, encodeSlash bool) string { var b strings.Builder b.Grow(len(s)) - for i := 0; i < len(s); i++ { + for i := range len(s) { ch := s[i] switch { case ch >= 'A' && ch <= 'Z', ch >= 'a' && ch <= 'z', ch >= '0' && ch <= '9', diff --git a/pkg/storage/s3sdk/upload.go b/pkg/storage/s3sdk/upload.go index 7a10f3c59..d32690866 100644 --- a/pkg/storage/s3sdk/upload.go +++ b/pkg/storage/s3sdk/upload.go @@ -3,7 +3,7 @@ package s3sdk import ( "bytes" "context" - "crypto/md5" + "crypto/md5" //nolint:gosec "encoding/base64" "encoding/xml" "errors" @@ -35,7 +35,7 @@ func (c *S3) Put(key string, body io.Reader, contentType string) error { // 用动态 buffer 读取首块,避免小对象也分配整个 partSize var first bytes.Buffer n, err := io.CopyN(&first, body, c.partSize) - if err != nil && err != io.EOF { + if err != nil && !errors.Is(err, io.EOF) { return err } if n < c.partSize { @@ -47,7 +47,8 @@ func (c *S3) Put(key string, body io.Reader, contentType string) error { } func (c *S3) putObject(key string, data []byte, contentType string) error { - req, err := http.NewRequest(http.MethodPut, c.objectURL(key), bytes.NewReader(data)) + ctx := context.Background() + req, err := http.NewRequestWithContext(ctx, http.MethodPut, c.objectURL(key), bytes.NewReader(data)) if err != nil { return err } @@ -57,7 +58,7 @@ func (c *S3) putObject(key string, data []byte, contentType string) error { } req.Header.Set("x-amz-content-sha256", sha256Hex(data)) - _, _, err = c.do(context.Background(), req, http.StatusOK) + _, _, err = c.do(ctx, req, http.StatusOK) //nolint:bodyclose return err } @@ -138,14 +139,14 @@ func (c *S3) putPart(ctx context.Context, key, uploadID string, partNum int, chu "partNumber": {strconv.Itoa(partNum)}, "uploadId": {uploadID}, } - req, err := http.NewRequest(http.MethodPut, c.objectURL(key)+"?"+query.Encode(), bytes.NewReader(chunk)) + req, err := http.NewRequestWithContext(ctx, http.MethodPut, c.objectURL(key)+"?"+query.Encode(), bytes.NewReader(chunk)) if err != nil { return "", err } req.ContentLength = int64(len(chunk)) req.Header.Set("x-amz-content-sha256", sha256Hex(chunk)) - _, res, err := c.do(ctx, req, http.StatusOK) + _, res, err := c.do(ctx, req, http.StatusOK) //nolint:bodyclose if err != nil { return "", err } @@ -166,7 +167,8 @@ func isRetryable(err error) bool { } func (c *S3) initiate(key, contentType string) (string, error) { - req, err := http.NewRequest(http.MethodPost, c.objectURL(key)+"?uploads", nil) + ctx := context.Background() + req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.objectURL(key)+"?uploads", nil) if err != nil { return "", err } @@ -174,7 +176,7 @@ func (c *S3) initiate(key, contentType string) (string, error) { req.Header.Set("Content-Type", contentType) } - body, _, err := c.do(context.Background(), req, http.StatusOK) + body, _, err := c.do(ctx, req, http.StatusOK) //nolint:bodyclose if err != nil { return "", err } @@ -203,25 +205,27 @@ func (c *S3) complete(key, uploadID string, parts []completedPart) error { return err } - req, err := http.NewRequest(http.MethodPost, c.objectURL(key)+"?uploadId="+url.QueryEscape(uploadID), bytes.NewReader(body)) + ctx := context.Background() + req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.objectURL(key)+"?uploadId="+url.QueryEscape(uploadID), bytes.NewReader(body)) if err != nil { return err } req.ContentLength = int64(len(body)) req.Header.Set("Content-Type", "application/xml") req.Header.Set("x-amz-content-sha256", sha256Hex(body)) - sum := md5.Sum(body) + sum := md5.Sum(body) //nolint:gosec req.Header.Set("Content-MD5", base64.StdEncoding.EncodeToString(sum[:])) - _, _, err = c.do(context.Background(), req, http.StatusOK) + _, _, err = c.do(ctx, req, http.StatusOK) //nolint:bodyclose return err } func (c *S3) abort(key, uploadID string) error { - req, err := http.NewRequest(http.MethodDelete, c.objectURL(key)+"?uploadId="+url.QueryEscape(uploadID), nil) + ctx := context.Background() + req, err := http.NewRequestWithContext(ctx, http.MethodDelete, c.objectURL(key)+"?uploadId="+url.QueryEscape(uploadID), nil) if err != nil { return err } - _, _, err = c.do(context.Background(), req, http.StatusNoContent) + _, _, err = c.do(ctx, req, http.StatusNoContent) //nolint:bodyclose return err } diff --git a/pkg/storage/sftp.go b/pkg/storage/sftp.go index 965b1a4d8..f000d183d 100644 --- a/pkg/storage/sftp.go +++ b/pkg/storage/sftp.go @@ -64,7 +64,7 @@ func (s *SFTP) connect() (*sftp.Client, func(), error) { User: s.config.Username, Auth: auth, Timeout: s.config.Timeout, - HostKeyCallback: ssh.InsecureIgnoreHostKey(), + HostKeyCallback: ssh.InsecureIgnoreHostKey(), //nolint:gosec } addr := fmt.Sprintf("%s:%d", s.config.Host, s.config.Port) diff --git a/pkg/systemctl/service.go b/pkg/systemctl/service.go index 10249451c..2a363b84e 100644 --- a/pkg/systemctl/service.go +++ b/pkg/systemctl/service.go @@ -48,10 +48,10 @@ func GetServiceInfo(name string) (*ServiceInfo, error) { } if info.PID > 0 { - if proc, err := process.NewProcess(int32(info.PID)); err == nil { + if proc, err := process.NewProcess(int32(info.PID)); err == nil { //nolint:gosec // 获取内存信息 if memInfo, err := proc.MemoryInfo(); err == nil && memInfo != nil { - info.Memory = int64(memInfo.RSS) + info.Memory = int64(memInfo.RSS) //nolint:gosec } // 获取 CPU 使用率 if cpu, err := proc.CPUPercent(); err == nil { diff --git a/pkg/tamper/detect_linux.go b/pkg/tamper/detect_linux.go index 91bb874cc..275309619 100644 --- a/pkg/tamper/detect_linux.go +++ b/pkg/tamper/detect_linux.go @@ -3,6 +3,8 @@ package tamper import ( + "bytes" + "context" "fmt" "os" "os/exec" @@ -26,7 +28,7 @@ func kernelVersion() string { if err := unix.Uname(&uts); err != nil { return "" } - return string(uts.Release[:strings.IndexByte(string(uts.Release[:]), 0)]) + return string(uts.Release[:bytes.IndexByte(uts.Release[:], 0)]) } // kernelAtLeast 判断内核是否 >= major.minor @@ -36,7 +38,7 @@ func kernelAtLeast(major, minor int) bool { if len(parts) < 2 { return false } - maj, err1 := strconv.Atoi(parts[0]) + majNum, err1 := strconv.Atoi(parts[0]) // 次版本号可能带后缀,截断非数字部分 minStr := parts[1] for i, c := range minStr { @@ -45,14 +47,14 @@ func kernelAtLeast(major, minor int) bool { break } } - min, err2 := strconv.Atoi(minStr) + minNum, err2 := strconv.Atoi(minStr) if err1 != nil || err2 != nil { return false } - if maj != major { - return maj > major + if majNum != major { + return majNum > major } - return min >= minor + return minNum >= minor } // activeLSM 读取当前激活的 LSM 列表 @@ -131,27 +133,27 @@ func injectLSMBpf(content, active string) (string, bool) { } // regenerateGrub 重新生成 grub 配置(兼容各发行版路径) -func regenerateGrub() error { +func regenerateGrub(ctx context.Context) error { if _, err := exec.LookPath("update-grub"); err == nil { - update := exec.Command("update-grub") + update := exec.CommandContext(ctx, "update-grub") shell.ApplyEnv(update) return update.Run() } candidates := []string{"/boot/grub2/grub.cfg", "/boot/grub/grub.cfg", "/boot/efi/EFI/centos/grub.cfg", "/boot/efi/EFI/redhat/grub.cfg"} for _, out := range candidates { if _, err := os.Stat(out); err == nil { - mkconfig := exec.Command("grub2-mkconfig", "-o", out) + mkconfig := exec.CommandContext(ctx, "grub2-mkconfig", "-o", out) shell.ApplyEnv(mkconfig) return mkconfig.Run() } } - mkconfig := exec.Command("grub2-mkconfig", "-o", "/boot/grub2/grub.cfg") + mkconfig := exec.CommandContext(ctx, "grub2-mkconfig", "-o", "/boot/grub2/grub.cfg") shell.ApplyEnv(mkconfig) return mkconfig.Run() } // EnableBPFLSMGrub 修改 grub 激活 bpf LSM,需重启系统生效 -func EnableBPFLSMGrub() error { +func EnableBPFLSMGrub(ctx context.Context) error { const grubFile = "/etc/default/grub" data, err := os.ReadFile(grubFile) if err != nil { @@ -165,7 +167,7 @@ func EnableBPFLSMGrub() error { } } - if err = regenerateGrub(); err != nil { + if err = regenerateGrub(ctx); err != nil { return fmt.Errorf("failed to regenerate grub config: %w", err) } return nil diff --git a/pkg/tamper/ebpf_linux.go b/pkg/tamper/ebpf_linux.go index 601580b63..6eb823d00 100644 --- a/pkg/tamper/ebpf_linux.go +++ b/pkg/tamper/ebpf_linux.go @@ -174,6 +174,8 @@ func paramLayout(spec *btf.Spec, hook, param string) (paramIdx, nargs int, err e // eventInsns 入口约定:R9=inode R8=dev,R6 复用为事件指针 // namePtrOff=0 无新名;verdictInR7 时按 R7 标 denied,否则恒 denied +// +//nolint:gosec func eventInsns(op Op, eventsFD int, namePtrOff int16, verdictInR7 bool) asm.Instructions { insns := asm.Instructions{ asm.LoadMapPtr(asm.R1, eventsFD).WithSymbol("hit"), @@ -220,6 +222,8 @@ func eventInsns(op Op, eventsFD int, namePtrOff int16, verdictInR7 bool) asm.Ins } // R6=ctx/事件指针 R7=prev_ret R8=dev R9=ino(R6-R9 跨 helper 保留) +// +//nolint:gosec func buildProg(h hookSpec, offs btfOffsets, paramIdx, paramIdx2, nargs, protectedFD, eventsFD int) asm.Instructions { retOff := int16(nargs * 8) @@ -292,6 +296,8 @@ func buildProg(h hookSpec, offs btfOffsets, paramIdx, paramIdx2, nargs, protecte // R7=prev_ret,透传后复用为本程序返回值(软命中路径改 0 放行) // 栈:FP-16 复合键 / FP-24 dir value 指针 / FP-32 新名 char* / FP-36 新名长度 / FP-64 起 15B 尾部缓冲 +// +//nolint:gosec func buildDirProg(h hookSpec, offs btfOffsets, paramIdx, nameIdx, oldIdx, nargs int, exts []string, dirsFD, eventsFD int, deny bool) asm.Instructions { retOff := int16(nargs * 8) ret := int32(-1) @@ -574,8 +580,9 @@ func newEBPFEngine(log *slog.Logger, blockNew bool, ruleExts []string) (*ebpfEng }) if err != nil { _ = e.Close() + // %+w 保留校验器完整日志 if ve, ok := errors.AsType[*ebpf.VerifierError](err); ok { - return nil, fmt.Errorf("failed to load %s LSM program: %+v", h.hook, ve) + return nil, fmt.Errorf("failed to load %s LSM program: %+w", h.hook, ve) } return nil, fmt.Errorf("failed to load %s LSM program: %w", h.hook, err) } diff --git a/pkg/tamper/manager_linux.go b/pkg/tamper/manager_linux.go index 8fc5acf72..9c4717c2a 100644 --- a/pkg/tamper/manager_linux.go +++ b/pkg/tamper/manager_linux.go @@ -149,11 +149,11 @@ func loadMountDevs() []mountDev { continue } maj, err1 := strconv.ParseUint(majS, 10, 32) - min, err2 := strconv.ParseUint(minS, 10, 32) + minNum, err2 := strconv.ParseUint(minS, 10, 32) if err1 != nil || err2 != nil { continue } - mounts = append(mounts, mountDev{point: mountUnescape.Replace(f[4]), dev: maj<<20 | min&0xfffff}) + mounts = append(mounts, mountDev{point: mountUnescape.Replace(f[4]), dev: maj<<20 | minNum&0xfffff}) } return mounts } @@ -169,7 +169,7 @@ func devOfPath(mounts []mountDev, path string, st *syscall.Stat_t) uint64 { if best >= 0 { return mounts[best].dev } - return uint64(unix.Major(uint64(st.Dev)))<<20 | uint64(unix.Minor(uint64(st.Dev)))&0xfffff + return uint64(unix.Major(st.Dev))<<20 | uint64(unix.Minor(st.Dev))&0xfffff } func statOf(mounts []mountDev, path string) (dev, ino uint64) { @@ -184,7 +184,7 @@ func statOf(mounts []mountDev, path string) (dev, ino uint64) { func walkRule(mounts []mountDev, root string, rule *Rule, emit func(fileEntry)) { _ = filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error { if err != nil { - return nil + return nil //nolint:nilerr } if isExcluded(path, rule.Excludes) { if d.IsDir() { @@ -300,7 +300,7 @@ func (m *Manager) startWatcher() error { for _, root := range rule.Paths { _ = filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error { if err != nil || !d.IsDir() { - return nil + return nil //nolint:nilerr } if isExcluded(path, rule.Excludes) { return filepath.SkipDir diff --git a/pkg/tamper/tamper_linux_test.go b/pkg/tamper/tamper_linux_test.go index 2c051fc81..76a85ed82 100644 --- a/pkg/tamper/tamper_linux_test.go +++ b/pkg/tamper/tamper_linux_test.go @@ -3,7 +3,6 @@ package tamper import ( - "io" "log/slog" "os" "path/filepath" @@ -54,7 +53,7 @@ func chattrSupported(dir string) bool { } func newLogger() *slog.Logger { - return slog.New(slog.NewTextHandler(io.Discard, nil)) + return slog.New(slog.DiscardHandler) } func TestChattrMode(t *testing.T) { diff --git a/pkg/tamper/tamper_other.go b/pkg/tamper/tamper_other.go index af247cf63..b070fccfa 100644 --- a/pkg/tamper/tamper_other.go +++ b/pkg/tamper/tamper_other.go @@ -3,6 +3,7 @@ package tamper import ( + "context" "errors" "log/slog" ) @@ -18,7 +19,7 @@ func DetectEBPF() EBPFStatus { } // EnableBPFLSMGrub 非 Linux 平台不支持 -func EnableBPFLSMGrub() error { +func EnableBPFLSMGrub(_ context.Context) error { return errors.New("only supported on Linux") } diff --git a/pkg/tools/tools.go b/pkg/tools/tools.go index 519dae7cd..3ad01b592 100644 --- a/pkg/tools/tools.go +++ b/pkg/tools/tools.go @@ -209,7 +209,7 @@ func IsChina() bool { client.SetLoggerWarnLevel(true) client.SetTimeout(3 * time.Second) client.SetRetryCount(3) - client.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) + client.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) //nolint:gosec resp, err := client.R().Get("https://perfops.cloudflareperf.com/cdn-cgi/trace") if err != nil || !resp.IsStatusSuccess() { @@ -231,7 +231,7 @@ func GetPublicIPv4() (string, error) { client.SetLoggerWarnLevel(true) client.SetTimeout(3 * time.Second) client.SetRetryCount(3) - client.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) + client.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) //nolint:gosec client.SetTransport(&http.Transport{ DialContext: func(ctx context.Context, network string, addr string) (stdnet.Conn, error) { return (&stdnet.Dialer{}).DialContext(ctx, "tcp4", addr) @@ -254,7 +254,7 @@ func GetPublicIPv6() (string, error) { client.SetLoggerWarnLevel(true) client.SetTimeout(3 * time.Second) client.SetRetryCount(3) - client.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) + client.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) //nolint:gosec client.SetTransport(&http.Transport{ DialContext: func(ctx context.Context, network string, addr string) (stdnet.Conn, error) { return (&stdnet.Dialer{}).DialContext(ctx, "tcp6", addr) @@ -271,25 +271,25 @@ func GetPublicIPv6() (string, error) { // GetLocalIPv4 获取本地IPv4 func GetLocalIPv4() (string, error) { - conn, err := stdnet.Dial("udp", "119.29.29.29:53") - if err != nil { - return "", err - } - defer func(conn stdnet.Conn) { _ = conn.Close() }(conn) - - local := conn.LocalAddr().(*stdnet.UDPAddr) - return local.IP.String(), nil + return localIPOf(context.Background(), "119.29.29.29:53") } // GetLocalIPv6 获取本地IPv6 func GetLocalIPv6() (string, error) { - conn, err := stdnet.Dial("udp", "[2402:4e00::]:53") + return localIPOf(context.Background(), "[2402:4e00::]:53") +} + +func localIPOf(ctx context.Context, addr string) (string, error) { + conn, err := (&stdnet.Dialer{}).DialContext(ctx, "udp", addr) if err != nil { return "", err } defer func(conn stdnet.Conn) { _ = conn.Close() }(conn) - local := conn.LocalAddr().(*stdnet.UDPAddr) + local, ok := conn.LocalAddr().(*stdnet.UDPAddr) + if !ok { + return "", errors.New("failed to get local address") + } return local.IP.String(), nil } diff --git a/pkg/tools/tools_test.go b/pkg/tools/tools_test.go index dc6e40eca..045daafe1 100644 --- a/pkg/tools/tools_test.go +++ b/pkg/tools/tools_test.go @@ -1,55 +1,70 @@ package tools import ( + "net/netip" "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) -type ToolsTestSuite struct { - suite.Suite +func checkIPv4(t *testing.T, ip string) { + t.Helper() + addr, err := netip.ParseAddr(ip) + must.NoError(t, err, must.Msgf("非法地址 %q", ip)) + check.True(t, addr.Is4(), check.Msgf("应为 IPv4,实际 %q", ip)) } -func TestToolsTestSuite(t *testing.T) { - suite.Run(t, &ToolsTestSuite{}) +func TestGetMonitoringInfo(t *testing.T) { + info := CurrentInfo(nil, nil) + must.NotNil(t, info.Host) + check.NotZero(t, info.Host.Hostname) + check.NotNil(t, info.Mem) } -func (s *ToolsTestSuite) TestGetMonitoringInfo() { - s.NotNil(CurrentInfo(nil, nil)) -} - -func (s *ToolsTestSuite) TestGetPublicIPv4() { +func TestGetPublicIPv4(t *testing.T) { ip, err := GetPublicIPv4() - s.NoError(err) - s.NotEmpty(ip) + must.NoError(t, err) + checkIPv4(t, ip) } -func (s *ToolsTestSuite) TestGetPublicIPv6() { +func TestGetPublicIPv6(t *testing.T) { ip, err := GetPublicIPv6() - s.Error(err) - s.Empty(ip) + check.Error(t, err) + check.Empty(t, ip) } -func (s *ToolsTestSuite) TestGetLocalIPv4() { +func TestGetLocalIPv4(t *testing.T) { ip, err := GetLocalIPv4() - s.NoError(err) - s.NotEmpty(ip) + must.NoError(t, err) + checkIPv4(t, ip) } -func (s *ToolsTestSuite) TestGetLocalIPv6() { +func TestGetLocalIPv6(t *testing.T) { ip, err := GetLocalIPv6() - s.Error(err) - s.Empty(ip) + check.Error(t, err) + check.Empty(t, ip) } -func (s *ToolsTestSuite) TestFormatBytes() { - s.Equal("1.00 B", FormatBytes(1)) - s.Equal("1.00 KB", FormatBytes(1024)) - s.Equal("1.00 MB", FormatBytes(1024*1024)) - s.Equal("1.00 GB", FormatBytes(1024*1024*1024)) - s.Equal("1.00 TB", FormatBytes(1024*1024*1024*1024)) - s.Equal("1.00 PB", FormatBytes(1024*1024*1024*1024*1024)) - s.Equal("1.00 EB", FormatBytes(1024*1024*1024*1024*1024*1024)) - s.Equal("1.00 ZB", FormatBytes(1024*1024*1024*1024*1024*1024*1024)) - s.Equal("1.00 YB", FormatBytes(1024*1024*1024*1024*1024*1024*1024*1024)) +func TestFormatBytes(t *testing.T) { + tests := []struct { + name string + size float64 + want string + }{ + {name: "B", size: 1, want: "1.00 B"}, + {name: "KB", size: 1 << 10, want: "1.00 KB"}, + {name: "MB", size: 1 << 20, want: "1.00 MB"}, + {name: "GB", size: 1 << 30, want: "1.00 GB"}, + {name: "TB", size: 1 << 40, want: "1.00 TB"}, + {name: "PB", size: 1 << 50, want: "1.00 PB"}, + {name: "EB", size: 1 << 60, want: "1.00 EB"}, + {name: "ZB", size: 1 << 70, want: "1.00 ZB"}, + {name: "YB", size: 1 << 80, want: "1.00 YB"}, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + check.Equal(t, FormatBytes(test.size), test.want) + }) + } } diff --git a/pkg/webserver/apache/parser_test.go b/pkg/webserver/apache/parser_test.go index 5844285ba..67ed47a46 100644 --- a/pkg/webserver/apache/parser_test.go +++ b/pkg/webserver/apache/parser_test.go @@ -6,39 +6,38 @@ import ( "github.com/acepanel/panel/v3/pkg/webserver/conf" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) func TestParseDirective(t *testing.T) { cfg, err := ParseString("ServerName www.example.com") - require.NoError(t, err) + must.NoError(t, err) d := cfg.Get("ServerName") - require.NotNil(t, d) - assert.Equal(t, "ServerName", d.Name) - assert.Equal(t, []string{"www.example.com"}, d.Values()) + must.NotNil(t, d) + check.Equal(t, d.Name, "ServerName") + check.DeepEqual(t, d.Values(), []string{"www.example.com"}) } func TestParseMultipleArgs(t *testing.T) { cfg, err := ParseString("Listen 192.168.1.100:80") - require.NoError(t, err) - assert.Equal(t, []string{"192.168.1.100:80"}, conf.Values(cfg.Get("Listen").Args)) + must.NoError(t, err) + check.DeepEqual(t, conf.Values(cfg.Get("Listen").Args), []string{"192.168.1.100:80"}) } func TestParseQuotedArgs(t *testing.T) { cfg, err := ParseString(`CustomLog "/var/log/apache2/access.log" combined`) - require.NoError(t, err) + must.NoError(t, err) d := cfg.Get("CustomLog") - require.NotNil(t, d) - // 引号被解析,值不含引号 - assert.Equal(t, "/var/log/apache2/access.log", d.Args[0].Value) - assert.Equal(t, conf.QuoteDouble, d.Args[0].Quote) - assert.Equal(t, "combined", d.Args[1].Value) - assert.Equal(t, conf.QuoteNone, d.Args[1].Quote) - // 导出时引号按原风格还原 - assert.Contains(t, Export(cfg), `CustomLog "/var/log/apache2/access.log" combined`) + must.NotNil(t, d) + // 引号被解析,值不含引号,但引号风格记在 Arg 上 + check.DeepEqual(t, d.Args, []conf.Arg{ + {Value: "/var/log/apache2/access.log", Quote: conf.QuoteDouble}, + {Value: "combined", Quote: conf.QuoteNone}, + }) + check.Contains(t, Export(cfg), `CustomLog "/var/log/apache2/access.log" combined`) } func TestParseVirtualHost(t *testing.T) { @@ -48,16 +47,15 @@ func TestParseVirtualHost(t *testing.T) { ` cfg, err := ParseString(input) - require.NoError(t, err) + must.NoError(t, err) vhosts := cfg.Blocks("VirtualHost") - require.Len(t, vhosts, 1) - assert.Equal(t, []string{"*:80"}, vhosts[0].Values()) - assert.Equal(t, "www.example.com", vhosts[0].Value("ServerName")) - assert.Equal(t, "/var/www/html", vhosts[0].Value("DocumentRoot")) + must.Len(t, vhosts, 1) + check.DeepEqual(t, vhosts[0].Values(), []string{"*:80"}) + check.Equal(t, vhosts[0].Value("ServerName"), "www.example.com") + check.Equal(t, vhosts[0].Value("DocumentRoot"), "/var/www/html") } -// TestNestedBlocksTriple 验证三层嵌套块正确解析 func TestNestedBlocksTriple(t *testing.T) { input := ` @@ -68,16 +66,18 @@ func TestNestedBlocksTriple(t *testing.T) { ` cfg, err := ParseString(input) - require.NoError(t, err) + must.NoError(t, err) - dir := cfg.Blocks("VirtualHost")[0].GetBlock("Directory") - require.NotNil(t, dir) + vhost := cfg.GetBlock("VirtualHost") + must.NotNil(t, vhost) + dir := vhost.GetBlock("Directory") + must.NotNil(t, dir) files := dir.GetBlock("Files") - require.NotNil(t, files) - assert.Equal(t, []string{"all", "granted"}, files.Get("Require").Values()) + must.NotNil(t, files) + check.DeepEqual(t, files.Get("Require").Values(), []string{"all", "granted"}) } -// TestNestedIfModuleNotDropped 验证双层嵌套块不被丢弃(旧实现的头号 bug) +// 双层嵌套块曾被旧实现丢弃 func TestNestedIfModuleNotDropped(t *testing.T) { input := ` @@ -88,15 +88,15 @@ func TestNestedIfModuleNotDropped(t *testing.T) { ` cfg, err := ParseString(input) - require.NoError(t, err) + must.NoError(t, err) members := cfg.Find("IfModule.Proxy.BalancerMember") - require.Len(t, members, 2) - assert.Equal(t, "http://127.0.0.1:8080", members[0].Args[0].Value) - assert.Equal(t, "loadfactor=5", members[0].Args[1].Value) + must.Len(t, members, 2) + check.DeepEqual(t, members[0].Values(), []string{"http://127.0.0.1:8080", "loadfactor=5"}) + check.DeepEqual(t, members[1].Values(), []string{"http://127.0.0.1:8081"}) } -// TestTokenizeSpecialChars 验证特殊字符不被分词器粘连或截断(旧 lexer 的字符白名单 bug) +// 旧 lexer 的字符白名单会把特殊字符粘连或截断 func TestTokenizeSpecialChars(t *testing.T) { cases := []struct { input string @@ -108,72 +108,67 @@ func TestTokenizeSpecialChars(t *testing.T) { {`SetHandler "proxy:unix:/tmp/php-cgi-84.sock|fcgi://localhost/"`, []string{"proxy:unix:/tmp/php-cgi-84.sock|fcgi://localhost/"}}, } for _, c := range cases { - cfg, err := ParseString(c.input) - require.NoError(t, err, c.input) - d, ok := cfg.Nodes[0].(*conf.Directive) - require.True(t, ok, c.input) - assert.Equal(t, c.want, d.Values(), c.input) + t.Run(c.input, func(t *testing.T) { + cfg, err := ParseString(c.input) + must.NoError(t, err) + must.Len(t, cfg.Nodes, 1) + d, ok := cfg.Nodes[0].(*conf.Directive) + must.True(t, ok, must.Msgf("首个节点应为指令,实际是 %T", cfg.Nodes[0])) + check.DeepEqual(t, d.Values(), c.want) + }) } } -// TestLineContinuation 验证续行符合并 func TestLineContinuation(t *testing.T) { cfg, err := ParseString("RewriteCond %{HTTP_HOST} foo \\\n [NC]") - require.NoError(t, err) + must.NoError(t, err) d := cfg.Get("RewriteCond") - require.NotNil(t, d) - assert.Equal(t, []string{"%{HTTP_HOST}", "foo", "[NC]"}, d.Values()) + must.NotNil(t, d) + check.DeepEqual(t, d.Values(), []string{"%{HTTP_HOST}", "foo", "[NC]"}) } -// TestLineContinuationEscapedBackslash 验证偶数反斜杠不触发续行 func TestLineContinuationEscapedBackslash(t *testing.T) { cfg, err := ParseString("ServerName a\\\\\nServerAdmin b") - require.NoError(t, err) - assert.NotNil(t, cfg.Get("ServerName")) - assert.NotNil(t, cfg.Get("ServerAdmin")) + must.NoError(t, err) + check.NotNil(t, cfg.Get("ServerName")) + check.NotNil(t, cfg.Get("ServerAdmin")) } -// TestCommentSemantics 验证注释语义:整行注释 vs 行内 # func TestCommentSemantics(t *testing.T) { cfg, err := ParseString("# a comment\nServerName x") - require.NoError(t, err) + must.NoError(t, err) cmts := collectComments(cfg.Nodes) - require.Len(t, cmts, 1) - assert.Equal(t, " a comment", cmts[0].Text) + must.Len(t, cmts, 1) + check.Equal(t, cmts[0].Text, " a comment") // 行内 # 是参数的一部分,不当注释 cfg2, err := ParseString("Redirect 301 /a /b#frag") - require.NoError(t, err) - d := cfg2.Get("Redirect") - require.NotNil(t, d) - assert.Equal(t, "/b#frag", d.Args[2].Value) + must.NoError(t, err) + check.DeepEqual(t, cfg2.Get("Redirect").Values(), []string{"301", "/a", "/b#frag"}) + check.Empty(t, collectComments(cfg2.Nodes)) } -// TestCommentPreserveLeadingSpace 验证注释首空格不丢失 func TestCommentPreserveLeadingSpace(t *testing.T) { cfg, err := ParseString("# double space") - require.NoError(t, err) - assert.Contains(t, Export(cfg), "# double space") + must.NoError(t, err) + check.Contains(t, Export(cfg), "# double space") } -// TestRoundTripDefaultVhostConf 验证默认模板规范化幂等且 IncludeOptional 在 VirtualHost 前 func TestRoundTripDefaultVhostConf(t *testing.T) { cfg, err := ParseString(DefaultVhostConf) - require.NoError(t, err) + must.NoError(t, err) rendered := Render(cfg) cfg2, err := ParseString(rendered) - require.NoError(t, err) - assert.Equal(t, rendered, Render(cfg2), "规范化导出应幂等") + must.NoError(t, err) + check.Equal(t, Render(cfg2), rendered, check.Msgf("规范化导出应幂等")) - idxInclude := strings.Index(rendered, "IncludeOptional") - idxVhost := strings.Index(rendered, " ServerName x @@ -183,21 +178,23 @@ func TestExportNestedRoundTrip(t *testing.T) { ` cfg, err := ParseString(input) - require.NoError(t, err) + must.NoError(t, err) out := Export(cfg) cfg2, err := ParseString(out) - require.NoError(t, err) - assert.Equal(t, out, Export(cfg2), "保序导出应幂等") - assert.NotNil(t, cfg2.Blocks("VirtualHost")[0].GetBlock("Directory")) + must.NoError(t, err) + check.Equal(t, Export(cfg2), out, check.Msgf("保序导出应幂等")) + vhost := cfg2.GetBlock("VirtualHost") + must.NotNil(t, vhost) + check.NotNil(t, vhost.GetBlock("Directory")) } func TestQueryCaseInsensitive(t *testing.T) { cfg, err := ParseString("ServerName x") - require.NoError(t, err) - assert.NotNil(t, cfg.Get("servername")) - assert.Equal(t, "x", cfg.Value("SERVERNAME")) - assert.True(t, cfg.Has("ServerName")) + must.NoError(t, err) + check.NotNil(t, cfg.Get("servername")) + check.Equal(t, cfg.Value("SERVERNAME"), "x") + check.True(t, cfg.Has("ServerName")) } func TestFindDotPath(t *testing.T) { @@ -209,55 +206,53 @@ func TestFindDotPath(t *testing.T) { ` cfg, err := ParseString(input) - require.NoError(t, err) - assert.Len(t, cfg.Find("IfModule.Proxy.Member"), 2) - assert.Len(t, cfg.FindBlocks("IfModule.Proxy"), 1) - assert.Nil(t, cfg.FindOne("IfModule.Proxy.Missing")) + must.NoError(t, err) + check.Len(t, cfg.Find("IfModule.Proxy.Member"), 2) + check.Len(t, cfg.FindBlocks("IfModule.Proxy"), 1) + check.Nil(t, cfg.FindOne("IfModule.Proxy.Missing")) } -// TestTolerantUnclosedBlock 验证未闭合块在容错模式下不致命 func TestTolerantUnclosedBlock(t *testing.T) { cfg, err := ParseString("\n ServerName x") - require.NoError(t, err) - require.Len(t, cfg.Blocks("VirtualHost"), 1) - assert.Equal(t, "x", cfg.Blocks("VirtualHost")[0].Value("ServerName")) + must.NoError(t, err) + must.Len(t, cfg.Blocks("VirtualHost"), 1) + check.Equal(t, cfg.Blocks("VirtualHost")[0].Value("ServerName"), "x") } -// TestTolerantOrphanCloseTag 验证孤立闭合标签在容错模式下被跳过 func TestTolerantOrphanCloseTag(t *testing.T) { cfg, err := ParseString("\nServerName x") - require.NoError(t, err) - assert.Equal(t, "x", cfg.Value("ServerName")) + must.NoError(t, err) + check.Equal(t, cfg.Value("ServerName"), "x") } func TestParseEmpty(t *testing.T) { cfg, err := ParseString("") - require.NoError(t, err) - assert.Empty(t, cfg.Nodes) + must.NoError(t, err) + check.Empty(t, cfg.Nodes) } func TestSetAndRemove(t *testing.T) { cfg, err := ParseString("ServerName old") - require.NoError(t, err) + must.NoError(t, err) cfg.Set("ServerName", "new") - assert.Equal(t, "new", cfg.Value("ServerName")) + check.Equal(t, cfg.Value("ServerName"), "new") cfg.Add("ServerAlias", "a", "b") - assert.Equal(t, []string{"a", "b"}, cfg.Get("ServerAlias").Values()) + check.DeepEqual(t, cfg.Get("ServerAlias").Values(), []string{"a", "b"}) - assert.Equal(t, 1, cfg.Remove("ServerName")) - assert.False(t, cfg.Has("ServerName")) + check.Equal(t, cfg.Remove("ServerName"), 1) + check.False(t, cfg.Has("ServerName")) } -// TestAddDirectiveAutoQuote 验证 Add 对含空格的参数自动加引号 func TestAddDirectiveAutoQuote(t *testing.T) { cfg := &conf.Config{} cfg.Add("AuthName", "My Realm") - assert.Contains(t, Export(cfg), `AuthName "My Realm"`) + check.Contains(t, Export(cfg), `AuthName "My Realm"`) cfg2 := &conf.Config{} cfg2.Add("DocumentRoot", "/var/www") - assert.Contains(t, Export(cfg2), "DocumentRoot /var/www") - assert.NotContains(t, Export(cfg2), `"`) + out := Export(cfg2) + check.Contains(t, out, "DocumentRoot /var/www") + check.NotContains(t, out, `"`) } diff --git a/pkg/webserver/apache/robustness_test.go b/pkg/webserver/apache/robustness_test.go index 28af3aef3..4bab4f5e6 100644 --- a/pkg/webserver/apache/robustness_test.go +++ b/pkg/webserver/apache/robustness_test.go @@ -6,12 +6,11 @@ import ( "github.com/acepanel/panel/v3/pkg/webserver/conf" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" ) -// realWorldConfig 涵盖真实 apache 配置的全部难点:转义引号、引号路径含空格、 -// 多层嵌套块、正则、 表达式含尖括号、SSLCipherSuite、续行符、SetHandler 管道 +// realWorldConfig 汇集真实 apache 配置里最难解析的语法 const realWorldConfig = `# main config ServerRoot "/etc/httpd" Listen 80 @@ -46,26 +45,21 @@ LoadModule ssl_module modules/mod_ssl.so ` -// TestRoundTripSemantics 验证综合真实配置 round-trip 语义无损 + 幂等 + 深层嵌套保留 func TestRoundTripSemantics(t *testing.T) { cfg, err := ParseString(realWorldConfig) - require.NoError(t, err) + must.NoError(t, err) out := Export(cfg) - // 语义无损:原文与导出的指令/块序列(合并续行、分词去引号后)完全一致 - assert.Equal(t, semanticLines(realWorldConfig), semanticLines(out), "语义无损") - // 幂等 + check.DeepEqual(t, semanticLines(out), semanticLines(realWorldConfig)) cfg2, err := ParseString(out) - require.NoError(t, err) - assert.Equal(t, out, Export(cfg2), "幂等") + must.NoError(t, err) + check.Equal(t, Export(cfg2), out, check.Msgf("幂等")) - // 抽查深层嵌套指令(VirtualHost > Directory > IfModule > RewriteRule)完整保留 rr := cfg.FindOne("VirtualHost.Directory.IfModule.RewriteRule") - require.NotNil(t, rr) - assert.Equal(t, []string{"^(.*)$", "https://new.example.com$1", "[R=301,L]"}, rr.Values()) + must.NotNil(t, rr) + check.DeepEqual(t, rr.Values(), []string{"^(.*)$", "https://new.example.com$1", "[R=301,L]"}) } -// TestRobustnessTrickySyntax 针对真实 apache 配置里最刁钻的语法做精确断言 func TestRobustnessTrickySyntax(t *testing.T) { cases := []struct { name string @@ -112,20 +106,20 @@ func TestRobustnessTrickySyntax(t *testing.T) { } for _, c := range cases { - cfg, err := ParseString(c.input) - require.NoError(t, err, c.name) - d := cfg.Get(c.dir) - require.NotNil(t, d, c.name) - assert.Equal(t, c.wantArgs, d.Values(), c.name) + t.Run(c.name, func(t *testing.T) { + cfg, err := ParseString(c.input) + must.NoError(t, err) + d := cfg.Get(c.dir) + must.NotNil(t, d) + check.DeepEqual(t, d.Values(), c.wantArgs) - // round-trip 后值仍一致 - cfg2, err := ParseString(Export(cfg)) - require.NoError(t, err, c.name+" 重解析") - assert.Equal(t, c.wantArgs, conf.Values(cfg2.Get(c.dir).Args), c.name+" round-trip") + cfg2, err := ParseString(Export(cfg)) + must.NoError(t, err) + check.DeepEqual(t, cfg2.Get(c.dir).Values(), c.wantArgs) + }) } } -// TestRobustnessEdgeCases 构造的边界地狱:专攻解析器最易崩的语法 func TestRobustnessEdgeCases(t *testing.T) { t.Run("六层深嵌套", func(t *testing.T) { input := ` @@ -142,86 +136,94 @@ func TestRobustnessEdgeCases(t *testing.T) { ` cfg, err := ParseString(input) - require.NoError(t, err) - ra := cfg.Blocks("VirtualHost")[0].GetBlock("Directory").GetBlock("Files"). + must.NoError(t, err) + vhost := cfg.GetBlock("VirtualHost") + must.NotNil(t, vhost) + ra := vhost.GetBlock("Directory").GetBlock("Files"). GetBlock("IfModule").GetBlock("Limit").GetBlock("RequireAll") - require.NotNil(t, ra) - assert.Equal(t, []string{"all", "granted"}, ra.Get("Require").Values()) - assert.Equal(t, Export(cfg), Export(mustReparse(t, Export(cfg))), "幂等") + must.NotNil(t, ra) + check.DeepEqual(t, ra.Get("Require").Values(), []string{"all", "granted"}) + out := Export(cfg) + check.Equal(t, Export(mustReparse(t, out)), out, check.Msgf("幂等")) }) t.Run("If表达式含尖括号", func(t *testing.T) { input := "|<)/\">\n Require all denied\n" cfg, err := ParseString(input) - require.NoError(t, err) + must.NoError(t, err) blocks := cfg.FindBlocks("If") - require.Len(t, blocks, 1) - assert.Equal(t, `%{QUERY_STRING} =~ /(>|<)/`, blocks[0].Args[0].Value) - assert.Equal(t, Export(cfg), Export(mustReparse(t, Export(cfg))), "幂等") + must.Len(t, blocks, 1) + check.DeepEqual(t, blocks[0].Values(), []string{`%{QUERY_STRING} =~ /(>|<)/`}) + out := Export(cfg) + check.Equal(t, Export(mustReparse(t, out)), out, check.Msgf("幂等")) }) t.Run("CRLF行尾", func(t *testing.T) { cfg, err := ParseString("\r\n Require all granted\r\n\r\n") - require.NoError(t, err) - assert.Equal(t, []string{"all", "granted"}, cfg.GetBlock("Directory").Get("Require").Values()) + must.NoError(t, err) + check.DeepEqual(t, cfg.GetBlock("Directory").Get("Require").Values(), []string{"all", "granted"}) }) t.Run("未闭合块容错", func(t *testing.T) { cfg, err := ParseString("\n Require all granted") - require.NoError(t, err) - require.NotNil(t, cfg.GetBlock("Directory")) - assert.Equal(t, []string{"all", "granted"}, cfg.GetBlock("Directory").Get("Require").Values()) + must.NoError(t, err) + must.NotNil(t, cfg.GetBlock("Directory")) + check.DeepEqual(t, cfg.GetBlock("Directory").Get("Require").Values(), []string{"all", "granted"}) }) t.Run("闭合标签大小写不匹配", func(t *testing.T) { cfg, err := ParseString("\n Require all granted\n") - require.NoError(t, err) - require.NotNil(t, cfg.GetBlock("directory")) - assert.Equal(t, []string{"all", "granted"}, cfg.GetBlock("directory").Get("Require").Values()) + must.NoError(t, err) + must.NotNil(t, cfg.GetBlock("directory")) + check.DeepEqual(t, cfg.GetBlock("directory").Get("Require").Values(), []string{"all", "granted"}) }) t.Run("空块", func(t *testing.T) { cfg, err := ParseString("\n") - require.NoError(t, err) - require.NotNil(t, cfg.GetBlock("Directory")) - assert.Empty(t, cfg.GetBlock("Directory").Nodes) + must.NoError(t, err) + must.NotNil(t, cfg.GetBlock("Directory")) + check.Empty(t, cfg.GetBlock("Directory").Nodes) }) t.Run("制表符缩进", func(t *testing.T) { cfg, err := ParseString("\n\t\tRequire all granted\n") - require.NoError(t, err) - assert.Equal(t, []string{"all", "granted"}, cfg.GetBlock("Directory").Get("Require").Values()) + must.NoError(t, err) + check.DeepEqual(t, cfg.GetBlock("Directory").Get("Require").Values(), []string{"all", "granted"}) }) t.Run("只有注释", func(t *testing.T) { cfg, err := ParseString("# c1\n# c2\n") - require.NoError(t, err) - assert.Len(t, cfg.Nodes, 2) + must.NoError(t, err) + check.Len(t, cfg.Nodes, 2) + cmts := collectComments(cfg.Nodes) + must.Len(t, cmts, 2) + check.DeepEqual(t, []string{cmts[0].Text, cmts[1].Text}, []string{" c1", " c2"}) }) t.Run("纯空白配置", func(t *testing.T) { cfg, err := ParseString("\n\n \n\t\n") - require.NoError(t, err) - assert.Empty(t, cfg.Nodes) + must.NoError(t, err) + check.Empty(t, cfg.Nodes) }) t.Run("块标签引号路径含空格", func(t *testing.T) { cfg, err := ParseString("\n Require all granted\n") - require.NoError(t, err) + must.NoError(t, err) d := cfg.GetBlock("Directory") - require.NotNil(t, d) - assert.Equal(t, "/var/www/my site", d.Args[0].Value) - assert.Contains(t, Export(cfg), ``) + must.NotNil(t, d) + check.DeepEqual(t, d.Values(), []string{"/var/www/my site"}) + check.Contains(t, Export(cfg), ``) }) } func mustReparse(t *testing.T, s string) *conf.Config { + t.Helper() cfg, err := ParseString(s) - require.NoError(t, err) + must.NoError(t, err) return cfg } -// semanticLines 把配置规范化为指令/块序列(合并续行、分词去引号、去注释空行),用于语义无损对比 +// semanticLines 把配置归一成指令/块序列,用于比对语义是否无损 func semanticLines(src string) []string { var out []string for _, ln := range scanLogicalLines(src) { diff --git a/pkg/webserver/apache/vhost_test.go b/pkg/webserver/apache/vhost_test.go index 515f5870b..0150d8124 100644 --- a/pkg/webserver/apache/vhost_test.go +++ b/pkg/webserver/apache/vhost_test.go @@ -6,117 +6,133 @@ import ( "strings" "testing" - "github.com/stretchr/testify/suite" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" "github.com/acepanel/panel/v3/pkg/webserver/types" ) -type VhostTestSuite struct { - suite.Suite - vhost *PHPVhost - configDir string -} - -func TestVhostTestSuite(t *testing.T) { - suite.Run(t, &VhostTestSuite{}) -} - -func (s *VhostTestSuite) SetupTest() { - // 创建临时配置目录 - configDir, err := os.MkdirTemp("", "apache-test-*") - s.Require().NoError(err) - s.configDir = configDir - - // 创建 site 目录 - err = os.MkdirAll(filepath.Join(configDir, "site"), 0755) - s.Require().NoError(err) +func newPHPVhost(t *testing.T) (*PHPVhost, string) { + t.Helper() + configDir := t.TempDir() + must.NoError(t, os.MkdirAll(filepath.Join(configDir, "site"), 0755)) vhost, err := NewPHPVhost(configDir) - s.Require().NoError(err) - s.Require().NotNil(vhost) - s.vhost = vhost + must.NoError(t, err) + must.NotNil(t, vhost) + return vhost, configDir } -func (s *VhostTestSuite) TearDownTest() { - // 清理临时目录 - if s.configDir != "" { - s.NoError(os.RemoveAll(s.configDir)) +func confFiles(t *testing.T, configDir, scope, prefix, suffix string) []string { + t.Helper() + entries, err := os.ReadDir(filepath.Join(configDir, scope)) + must.NoError(t, err) + + var out []string + for _, entry := range entries { + if strings.HasPrefix(entry.Name(), prefix) && strings.HasSuffix(entry.Name(), suffix) { + out = append(out, entry.Name()) + } } + return out } -func (s *VhostTestSuite) TestNewVhost() { - s.Equal(s.configDir, s.vhost.configDir) - s.NotNil(s.vhost.config) - s.NotNil(s.vhost.vhost) +func newProxyVhost(t *testing.T) (*ProxyVhost, string) { + t.Helper() + configDir := t.TempDir() + must.NoError(t, os.MkdirAll(filepath.Join(configDir, "site"), 0755)) + must.NoError(t, os.MkdirAll(filepath.Join(configDir, "shared"), 0755)) + + vhost, err := NewProxyVhost(configDir) + must.NoError(t, err) + return vhost, configDir } -func (s *VhostTestSuite) TestEnable() { +func TestPHPVhostNew(t *testing.T) { + vhost, configDir := newPHPVhost(t) + + check.Equal(t, vhost.configDir, configDir) + check.NotNil(t, vhost.config) + check.NotNil(t, vhost.vhost) +} + +func TestPHPVhostEnable(t *testing.T) { + vhost, _ := newPHPVhost(t) + // 默认应该是启用状态 - s.True(s.vhost.Enable()) + check.True(t, vhost.Enable()) // 禁用网站 - s.NoError(s.vhost.SetEnable(false)) - s.False(s.vhost.Enable()) + check.NoError(t, vhost.SetEnable(false)) + check.False(t, vhost.Enable()) // 重新启用 - s.NoError(s.vhost.SetEnable(true)) - s.True(s.vhost.Enable()) + check.NoError(t, vhost.SetEnable(true)) + check.True(t, vhost.Enable()) } -func (s *VhostTestSuite) TestServerName() { +func TestPHPVhostServerName(t *testing.T) { + vhost, _ := newPHPVhost(t) + names := []string{"example.com", "www.example.com", "api.example.com"} - s.NoError(s.vhost.SetServerName(names)) - - got := s.vhost.ServerName() - s.Len(got, 3) - s.Equal("example.com", got[0]) - s.Equal("www.example.com", got[1]) - s.Equal("api.example.com", got[2]) + check.NoError(t, vhost.SetServerName(names)) + check.DeepEqual(t, vhost.ServerName(), names) } -func (s *VhostTestSuite) TestServerNameEmpty() { - s.NoError(s.vhost.SetServerName([]string{})) +func TestPHPVhostServerNameEmpty(t *testing.T) { + vhost, _ := newPHPVhost(t) + + // 空输入是空操作,原有域名保持不变 + before := vhost.ServerName() + check.NoError(t, vhost.SetServerName([]string{})) + check.DeepEqual(t, vhost.ServerName(), before) } -func (s *VhostTestSuite) TestRoot() { +func TestPHPVhostRoot(t *testing.T) { + vhost, _ := newPHPVhost(t) + root := "/var/www/html" - s.NoError(s.vhost.SetRoot(root)) - s.Equal(root, s.vhost.Root()) + check.NoError(t, vhost.SetRoot(root)) + check.Equal(t, vhost.Root(), root) } -func (s *VhostTestSuite) TestIndex() { +func TestPHPVhostIndex(t *testing.T) { + vhost, _ := newPHPVhost(t) + index := []string{"index.html", "index.php", "default.html"} - s.NoError(s.vhost.SetIndex(index)) - - got := s.vhost.Index() - s.Len(got, 3) - s.Equal(index, got) + check.NoError(t, vhost.SetIndex(index)) + check.DeepEqual(t, vhost.Index(), index) } -func (s *VhostTestSuite) TestIndexEmpty() { - s.NoError(s.vhost.SetIndex([]string{})) - s.Empty(s.vhost.Index()) +func TestPHPVhostIndexEmpty(t *testing.T) { + vhost, _ := newPHPVhost(t) + + check.NoError(t, vhost.SetIndex([]string{})) + check.Empty(t, vhost.Index()) } -func (s *VhostTestSuite) TestListen() { +func TestPHPVhostListen(t *testing.T) { + vhost, _ := newPHPVhost(t) + listens := []types.Listen{ {Address: "*:80"}, {Address: "*:443"}, } - s.NoError(s.vhost.SetListen(listens)) - - got := s.vhost.Listen() - s.Len(got, 2) - s.Equal("*:80", got[0].Address) - s.Equal("*:443", got[1].Address) + check.NoError(t, vhost.SetListen(listens)) + check.DeepEqual(t, vhost.Listen(), listens, cmpopts.EquateEmpty()) } -func (s *VhostTestSuite) TestSSL() { - s.False(s.vhost.SSL()) - s.Nil(s.vhost.SSLConfig()) +func TestPHPVhostSSL(t *testing.T) { + vhost, _ := newPHPVhost(t) + + check.False(t, vhost.SSL()) + check.Nil(t, vhost.SSLConfig()) } -func (s *VhostTestSuite) TestSetSSLConfig() { +func TestPHPVhostSetSSLConfig(t *testing.T) { + vhost, _ := newPHPVhost(t) + sslConfig := &types.SSLConfig{ Cert: "/etc/ssl/cert.pem", Key: "/etc/ssl/key.pem", @@ -124,38 +140,38 @@ func (s *VhostTestSuite) TestSetSSLConfig() { HSTS: true, OCSP: true, } - s.NoError(s.vhost.SetSSLConfig(sslConfig)) + check.NoError(t, vhost.SetSSLConfig(sslConfig)) - s.True(s.vhost.SSL()) - - got := s.vhost.SSLConfig() - s.NotNil(got) - s.Equal(sslConfig.Cert, got.Cert) - s.Equal(sslConfig.Key, got.Key) - s.True(got.HSTS) - s.True(got.OCSP) + check.True(t, vhost.SSL()) + check.DeepEqual(t, vhost.SSLConfig(), sslConfig) } -func (s *VhostTestSuite) TestSetSSLConfigNil() { - s.Error(s.vhost.SetSSLConfig(nil)) +func TestPHPVhostSetSSLConfigNil(t *testing.T) { + vhost, _ := newPHPVhost(t) + + check.Error(t, vhost.SetSSLConfig(nil)) } -func (s *VhostTestSuite) TestClearSSL() { +func TestPHPVhostClearSSL(t *testing.T) { + vhost, _ := newPHPVhost(t) + sslConfig := &types.SSLConfig{ Cert: "/etc/ssl/cert.pem", Key: "/etc/ssl/key.pem", HSTS: true, } - s.NoError(s.vhost.SetSSLConfig(sslConfig)) - s.True(s.vhost.SSL()) + check.NoError(t, vhost.SetSSLConfig(sslConfig)) + check.True(t, vhost.SSL()) - s.NoError(s.vhost.ClearSSL()) - s.False(s.vhost.SSL()) + check.NoError(t, vhost.ClearSSL()) + check.False(t, vhost.SSL()) } -func (s *VhostTestSuite) TestClearHTTPSPreservesOtherHeaders() { +func TestPHPVhostClearHTTPSPreservesOtherHeaders(t *testing.T) { + vhost, _ := newPHPVhost(t) + // 添加一个非 HSTS 的 Header - s.vhost.vhost.Add("Header", "set", "X-Custom-Header", "value") + vhost.vhost.Add("Header", "set", "X-Custom-Header", "value") // 设置 SSL 和 HSTS sslConfig := &types.SSLConfig{ @@ -163,214 +179,219 @@ func (s *VhostTestSuite) TestClearHTTPSPreservesOtherHeaders() { Key: "/etc/ssl/key.pem", HSTS: true, } - s.NoError(s.vhost.SetSSLConfig(sslConfig)) + check.NoError(t, vhost.SetSSLConfig(sslConfig)) - // 清除 HTTPS - s.NoError(s.vhost.ClearSSL()) + // 清除 HTTPS 只带走 HSTS,自定义 Header 原样保留 + check.NoError(t, vhost.ClearSSL()) - // 检查自定义 Header 是否保留 - headers := s.vhost.vhost.GetAll("Header") - s.NotEmpty(headers) - found := false - for _, h := range headers { - if len(h.Args) >= 2 && h.Args[1].Value == "X-Custom-Header" { - found = true - break - } - } - s.True(found, "自定义 Header 应该被保留") + out := Export(vhost.config) + check.Contains(t, out, "X-Custom-Header") + check.NotContains(t, out, "Strict-Transport-Security") } -func (s *VhostTestSuite) TestPHP() { - s.Equal(uint(0), s.vhost.PHP()) +func TestPHPVhostPHP(t *testing.T) { + vhost, _ := newPHPVhost(t) - s.NoError(s.vhost.SetPHP(84)) - s.NotEqual(uint(0), s.vhost.PHP()) + check.Equal(t, vhost.PHP(), uint(0)) - s.NoError(s.vhost.SetPHP(0)) - s.Equal(uint(0), s.vhost.PHP()) + check.NoError(t, vhost.SetPHP(84)) + check.Equal(t, vhost.PHP(), uint(84)) + + check.NoError(t, vhost.SetPHP(0)) + check.Equal(t, vhost.PHP(), uint(0)) } -func (s *VhostTestSuite) TestAccessLog() { +func TestPHPVhostAccessLog(t *testing.T) { + vhost, _ := newPHPVhost(t) + accessLog := "/var/log/apache/access.log" - s.NoError(s.vhost.SetAccessLog(accessLog)) - s.Equal(accessLog, s.vhost.AccessLog()) + check.NoError(t, vhost.SetAccessLog(accessLog)) + check.Equal(t, vhost.AccessLog(), accessLog) } -func (s *VhostTestSuite) TestErrorLog() { +func TestPHPVhostErrorLog(t *testing.T) { + vhost, _ := newPHPVhost(t) + errorLog := "/var/log/apache/error.log" - s.NoError(s.vhost.SetErrorLog(errorLog)) - s.Equal(errorLog, s.vhost.ErrorLog()) + check.NoError(t, vhost.SetErrorLog(errorLog)) + check.Equal(t, vhost.ErrorLog(), errorLog) } -func (s *VhostTestSuite) TestIncludes() { +func TestPHPVhostIncludes(t *testing.T) { + vhost, _ := newPHPVhost(t) + includes := []types.IncludeFile{ {Path: "/etc/apache/conf.d/ssl.conf"}, {Path: "/etc/apache/conf.d/php.conf"}, } - s.NoError(s.vhost.SetIncludes(includes)) - - got := s.vhost.Includes() - s.Len(got, 2) - s.Equal(includes[0].Path, got[0].Path) - s.Equal(includes[1].Path, got[1].Path) + check.NoError(t, vhost.SetIncludes(includes)) + check.DeepEqual(t, vhost.Includes(), includes) } -func (s *VhostTestSuite) TestBasicAuth() { - s.Nil(s.vhost.BasicAuth()) +func TestPHPVhostBasicAuth(t *testing.T) { + vhost, _ := newPHPVhost(t) + + check.Nil(t, vhost.BasicAuth()) auths := []types.BasicAuth{ {Path: "/", UserFile: "/etc/htpasswd_0"}, {Path: "/admin", UserFile: "/etc/htpasswd_1"}, } - s.NoError(s.vhost.SetBasicAuth(auths)) + check.NoError(t, vhost.SetBasicAuth(auths)) + check.DeepEqual(t, vhost.BasicAuth(), auths) - got := s.vhost.BasicAuth() - s.Len(got, 2) - s.Equal("/", got[0].Path) - s.Equal("/etc/htpasswd_0", got[0].UserFile) - s.Equal("/admin", got[1].Path) - s.Equal("/etc/htpasswd_1", got[1].UserFile) - - s.NoError(s.vhost.ClearBasicAuth()) - s.Nil(s.vhost.BasicAuth()) + check.NoError(t, vhost.ClearBasicAuth()) + check.Nil(t, vhost.BasicAuth()) } -func (s *VhostTestSuite) TestBasicAuthOrder() { +func TestPHPVhostBasicAuthOrder(t *testing.T) { + vhost, _ := newPHPVhost(t) + // Location 后声明者覆盖先声明者,整站规则应排在目录规则之前声明 - auths := []types.BasicAuth{ + check.NoError(t, vhost.SetBasicAuth([]types.BasicAuth{ {Path: "/admin", UserFile: "/etc/htpasswd_0"}, {Path: "/", UserFile: "/etc/htpasswd_1"}, - } - s.NoError(s.vhost.SetBasicAuth(auths)) - - got := s.vhost.BasicAuth() - s.Len(got, 2) - s.Equal("/", got[0].Path) - s.Equal("/admin", got[1].Path) + })) + check.DeepEqual(t, vhost.BasicAuth(), []types.BasicAuth{ + {Path: "/", UserFile: "/etc/htpasswd_1"}, + {Path: "/admin", UserFile: "/etc/htpasswd_0"}, + }) } -func (s *VhostTestSuite) TestBasicAuthLegacy() { +func TestPHPVhostBasicAuthLegacy(t *testing.T) { + vhost, _ := newPHPVhost(t) + // 旧版 vhost 级整站配置应能读出并被清除 - s.vhost.vhost.Set("AuthType", "Basic") - s.vhost.vhost.Set("AuthName", "Restricted") - s.vhost.vhost.Set("AuthUserFile", "/etc/htpasswd") - s.vhost.vhost.Set("Require", "valid-user") + vhost.vhost.Set("AuthType", "Basic") + vhost.vhost.Set("AuthName", "Restricted") + vhost.vhost.Set("AuthUserFile", "/etc/htpasswd") + vhost.vhost.Set("Require", "valid-user") - got := s.vhost.BasicAuth() - s.Len(got, 1) - s.Equal("/", got[0].Path) - s.Equal("/etc/htpasswd", got[0].UserFile) + check.DeepEqual(t, vhost.BasicAuth(), []types.BasicAuth{{Path: "/", UserFile: "/etc/htpasswd"}}) - s.NoError(s.vhost.ClearBasicAuth()) - s.Nil(s.vhost.BasicAuth()) + check.NoError(t, vhost.ClearBasicAuth()) + check.Nil(t, vhost.BasicAuth()) } -func (s *VhostTestSuite) TestRateLimit() { - s.Nil(s.vhost.RateLimit()) +func TestPHPVhostRateLimit(t *testing.T) { + vhost, _ := newPHPVhost(t) + + check.Nil(t, vhost.RateLimit()) limit := &types.RateLimit{ Rate: 512, } - s.NoError(s.vhost.SetRateLimit(limit)) + check.NoError(t, vhost.SetRateLimit(limit)) + check.DeepEqual(t, vhost.RateLimit(), limit) - got := s.vhost.RateLimit() - s.NotNil(got) - s.Equal(512, got.Rate) - - s.NoError(s.vhost.ClearRateLimit()) - s.Nil(s.vhost.RateLimit()) + check.NoError(t, vhost.ClearRateLimit()) + check.Nil(t, vhost.RateLimit()) } -func (s *VhostTestSuite) TestReset() { - s.NoError(s.vhost.SetServerName([]string{"modified.com"})) - s.NoError(s.vhost.SetRoot("/modified/path")) +func TestPHPVhostReset(t *testing.T) { + vhost, _ := newPHPVhost(t) - s.NoError(s.vhost.Reset()) + // 重置后应完全回到初始模板,而不只是丢掉改动值 + names, root := vhost.ServerName(), vhost.Root() + check.NoError(t, vhost.SetServerName([]string{"modified.com"})) + check.NoError(t, vhost.SetRoot("/modified/path")) - names := s.vhost.ServerName() - s.NotContains(names, "modified.com") + check.NoError(t, vhost.Reset()) + check.DeepEqual(t, vhost.ServerName(), names) + check.Equal(t, vhost.Root(), root) } -func (s *VhostTestSuite) TestSave() { - s.NoError(s.vhost.SetServerName([]string{"save-test.com"})) - s.NoError(s.vhost.Save()) +func TestPHPVhostSave(t *testing.T) { + vhost, configDir := newPHPVhost(t) + + check.NoError(t, vhost.SetServerName([]string{"save-test.com"})) + check.NoError(t, vhost.Save()) // 验证配置文件已保存 - configFile := filepath.Join(s.configDir, "apache.conf") + configFile := filepath.Join(configDir, "apache.conf") content, err := os.ReadFile(configFile) - s.NoError(err) - s.Contains(string(content), "save-test.com") + must.NoError(t, err) + check.Contains(t, string(content), "save-test.com") } -func (s *VhostTestSuite) TestExport() { - s.NoError(s.vhost.SetServerName([]string{"export-test.com"})) - s.NoError(s.vhost.SetRoot("/var/www/export-test")) +func TestPHPVhostExport(t *testing.T) { + vhost, _ := newPHPVhost(t) - content := Export(s.vhost.config) - s.NotEmpty(content) - s.Contains(content, "export-test.com") - s.Contains(content, "/var/www/export-test") - s.Contains(content, "") + check.NoError(t, vhost.SetServerName([]string{"export-test.com"})) + check.NoError(t, vhost.SetRoot("/var/www/export-test")) + + content := Export(vhost.config) + check.Contains(t, content, "export-test.com") + check.Contains(t, content, "/var/www/export-test") + check.Contains(t, content, "") } -func (s *VhostTestSuite) TestExportWithSSL() { +func TestPHPVhostExportWithSSL(t *testing.T) { + vhost, _ := newPHPVhost(t) + sslConfig := &types.SSLConfig{ Cert: "/etc/ssl/cert.pem", Key: "/etc/ssl/key.pem", Protocols: []string{"TLSv1.2", "TLSv1.3"}, } - s.NoError(s.vhost.SetSSLConfig(sslConfig)) + check.NoError(t, vhost.SetSSLConfig(sslConfig)) - content := Export(s.vhost.config) - s.Contains(content, "SSLEngine on") - s.Contains(content, "SSLCertificateFile") - s.Contains(content, "SSLCertificateKeyFile") + content := Export(vhost.config) + check.Contains(t, content, "SSLEngine on") + check.Contains(t, content, "SSLCertificateFile") + check.Contains(t, content, "SSLCertificateKeyFile") } -func (s *VhostTestSuite) TestListenProtocolDetection() { +func TestPHPVhostListenProtocolDetection(t *testing.T) { + vhost, _ := newPHPVhost(t) + listens := []types.Listen{ {Address: "*:443"}, } - s.NoError(s.vhost.SetListen(listens)) + check.NoError(t, vhost.SetListen(listens)) sslConfig := &types.SSLConfig{ Cert: "/etc/ssl/cert.pem", Key: "/etc/ssl/key.pem", } - s.NoError(s.vhost.SetSSLConfig(sslConfig)) + check.NoError(t, vhost.SetSSLConfig(sslConfig)) - got := s.vhost.Listen() - s.Len(got, 1) - s.Equal("*:443", got[0].Address) + // 开启 SSL 不应改写监听项 + check.DeepEqual(t, vhost.Listen(), listens, cmpopts.EquateEmpty()) } -func (s *VhostTestSuite) TestDirectoryBlock() { +func TestPHPVhostDirectoryBlock(t *testing.T) { + vhost, _ := newPHPVhost(t) + root := "/var/www/test-dir" - s.NoError(s.vhost.SetRoot(root)) + check.NoError(t, vhost.SetRoot(root)) - content := Export(s.vhost.config) - s.Contains(content, "") - s.Contains(content, "") + content := Export(vhost.config) + check.Contains(t, content, "") + check.Contains(t, content, "") } -func (s *VhostTestSuite) TestPHPFilesMatchBlock() { - s.NoError(s.vhost.SetPHP(84)) +func TestPHPVhostFilesMatchBlock(t *testing.T) { + vhost, _ := newPHPVhost(t) - content := s.vhost.Config("010-php.conf", "site") - s.Contains(content, "proxy:unix:/tmp/php-cgi-84.sock|fcgi://localhost/") + check.NoError(t, vhost.SetPHP(84)) + + content := vhost.Config("010-php.conf", "site") + check.Contains(t, content, "proxy:unix:/tmp/php-cgi-84.sock|fcgi://localhost/") } -func (s *VhostTestSuite) TestDefaultVhostConfIncludesServerD() { +func TestDefaultVhostConfIncludesServerD(t *testing.T) { // 验证默认配置包含 site 的 include - s.Contains(DefaultVhostConf, "site") - s.Contains(DefaultVhostConf, "IncludeOptional") + check.Contains(t, DefaultVhostConf, "site") + check.Contains(t, DefaultVhostConf, "IncludeOptional") } -func (s *VhostTestSuite) TestRedirects() { +func TestPHPVhostRedirects(t *testing.T) { + vhost, configDir := newPHPVhost(t) + // 初始应该没有重定向 - s.Empty(s.vhost.Redirects()) + check.Empty(t, vhost.Redirects()) // 设置重定向 redirects := []types.Redirect{ @@ -388,27 +409,17 @@ func (s *VhostTestSuite) TestRedirects() { StatusCode: 308, }, } - s.NoError(s.vhost.SetRedirects(redirects)) + check.NoError(t, vhost.SetRedirects(redirects)) // 验证重定向文件已创建 - siteDir := filepath.Join(s.configDir, "site") - entries, err := os.ReadDir(siteDir) - s.NoError(err) + check.Len(t, confFiles(t, configDir, "site", "1", "-redirect.conf"), 2) - redirectCount := 0 - for _, entry := range entries { - if strings.HasPrefix(entry.Name(), "1") && strings.HasSuffix(entry.Name(), "-redirect.conf") { - redirectCount++ - } - } - s.Equal(2, redirectCount) - - // 验证可以读取回来 - got := s.vhost.Redirects() - s.Len(got, 2) + check.DeepEqual(t, vhost.Redirects(), redirects) } -func (s *VhostTestSuite) TestRedirectURL() { +func TestPHPVhostRedirectURL(t *testing.T) { + vhost, configDir := newPHPVhost(t) + redirects := []types.Redirect{ { Type: types.RedirectTypeURL, @@ -417,19 +428,21 @@ func (s *VhostTestSuite) TestRedirectURL() { StatusCode: 301, }, } - s.NoError(s.vhost.SetRedirects(redirects)) + check.NoError(t, vhost.SetRedirects(redirects)) // 读取配置文件内容 - siteDir := filepath.Join(s.configDir, "site") + siteDir := filepath.Join(configDir, "site") content, err := os.ReadFile(filepath.Join(siteDir, "100-redirect.conf")) - s.NoError(err) + must.NoError(t, err) - s.Contains(string(content), "Redirect 301") - s.Contains(string(content), "/old-page") - s.Contains(string(content), "/new-page") + check.Contains(t, string(content), "Redirect 301") + check.Contains(t, string(content), "/old-page") + check.Contains(t, string(content), "/new-page") } -func (s *VhostTestSuite) TestRedirectHost() { +func TestPHPVhostRedirectHost(t *testing.T) { + vhost, configDir := newPHPVhost(t) + redirects := []types.Redirect{ { Type: types.RedirectTypeHost, @@ -439,71 +452,44 @@ func (s *VhostTestSuite) TestRedirectHost() { StatusCode: 308, }, } - s.NoError(s.vhost.SetRedirects(redirects)) + check.NoError(t, vhost.SetRedirects(redirects)) // 读取配置文件内容 - siteDir := filepath.Join(s.configDir, "site") + siteDir := filepath.Join(configDir, "site") content, err := os.ReadFile(filepath.Join(siteDir, "100-redirect.conf")) - s.NoError(err) + must.NoError(t, err) - s.Contains(string(content), "RewriteEngine") - s.Contains(string(content), "RewriteCond") - s.Contains(string(content), "old.example.com") - s.Contains(string(content), "R=308") + check.Contains(t, string(content), "RewriteEngine") + check.Contains(t, string(content), "RewriteCond") + check.Contains(t, string(content), "old.example.com") + check.Contains(t, string(content), "R=308") } -func (s *VhostTestSuite) TestRedirect404() { +func TestPHPVhostRedirect404(t *testing.T) { + vhost, configDir := newPHPVhost(t) + redirects := []types.Redirect{ { Type: types.RedirectType404, To: "/custom-404.html", }, } - s.NoError(s.vhost.SetRedirects(redirects)) + check.NoError(t, vhost.SetRedirects(redirects)) // 读取配置文件内容 - siteDir := filepath.Join(s.configDir, "site") + siteDir := filepath.Join(configDir, "site") content, err := os.ReadFile(filepath.Join(siteDir, "100-redirect.conf")) - s.NoError(err) + must.NoError(t, err) - s.Contains(string(content), "ErrorDocument 404") - s.Contains(string(content), "/custom-404.html") + check.Contains(t, string(content), "ErrorDocument 404") + check.Contains(t, string(content), "/custom-404.html") } -// ProxyVhost 测试套件 -type ProxyVhostTestSuite struct { - suite.Suite - vhost *ProxyVhost - configDir string -} +func TestProxyVhostProxies(t *testing.T) { + vhost, configDir := newProxyVhost(t) -func TestProxyVhostTestSuite(t *testing.T) { - suite.Run(t, &ProxyVhostTestSuite{}) -} - -func (s *ProxyVhostTestSuite) SetupTest() { - configDir, err := os.MkdirTemp("", "apache-proxy-test-*") - s.Require().NoError(err) - s.configDir = configDir - - // 创建 site 和 shared 目录 - s.NoError(os.MkdirAll(filepath.Join(configDir, "site"), 0755)) - s.NoError(os.MkdirAll(filepath.Join(configDir, "shared"), 0755)) - - vhost, err := NewProxyVhost(configDir) - s.Require().NoError(err) - s.vhost = vhost -} - -func (s *ProxyVhostTestSuite) TearDownTest() { - if s.configDir != "" { - s.NoError(os.RemoveAll(s.configDir)) - } -} - -func (s *ProxyVhostTestSuite) TestProxies() { // 初始应该没有代理配置 - s.Empty(s.vhost.Proxies()) + check.Empty(t, vhost.Proxies()) // 设置代理配置 proxies := []types.Proxy{ @@ -518,27 +504,17 @@ func (s *ProxyVhostTestSuite) TestProxies() { Buffering: true, }, } - s.NoError(s.vhost.SetProxies(proxies)) + check.NoError(t, vhost.SetProxies(proxies)) // 验证代理文件已创建 - siteDir := filepath.Join(s.configDir, "site") - entries, err := os.ReadDir(siteDir) - s.NoError(err) + check.Len(t, confFiles(t, configDir, "site", "2", "-proxy.conf"), 2) - proxyCount := 0 - for _, entry := range entries { - if strings.HasPrefix(entry.Name(), "2") && strings.HasSuffix(entry.Name(), "-proxy.conf") { - proxyCount++ - } - } - s.Equal(2, proxyCount) - - // 验证可以读取回来 - got := s.vhost.Proxies() - s.Len(got, 2) + check.DeepEqual(t, vhost.Proxies(), proxies, cmpopts.EquateEmpty()) } -func (s *ProxyVhostTestSuite) TestProxyConfig() { +func TestProxyVhostProxyConfig(t *testing.T) { + vhost, configDir := newProxyVhost(t) + proxies := []types.Proxy{ { Location: "/", @@ -547,34 +523,38 @@ func (s *ProxyVhostTestSuite) TestProxyConfig() { Buffering: true, }, } - s.NoError(s.vhost.SetProxies(proxies)) + check.NoError(t, vhost.SetProxies(proxies)) // 读取配置文件内容 - siteDir := filepath.Join(s.configDir, "site") + siteDir := filepath.Join(configDir, "site") content, err := os.ReadFile(filepath.Join(siteDir, "200-proxy.conf")) - s.NoError(err) + must.NoError(t, err) - s.Contains(string(content), "ProxyPass /") - s.Contains(string(content), "ProxyPassReverse") - s.Contains(string(content), "http://backend:8080/") - s.Contains(string(content), "RequestHeader set Host") - s.Contains(string(content), "example.com") + check.Contains(t, string(content), "ProxyPass /") + check.Contains(t, string(content), "ProxyPassReverse") + check.Contains(t, string(content), "http://backend:8080/") + check.Contains(t, string(content), "RequestHeader set Host") + check.Contains(t, string(content), "example.com") } -func (s *ProxyVhostTestSuite) TestClearProxies() { +func TestProxyVhostClearProxies(t *testing.T) { + vhost, _ := newProxyVhost(t) + proxies := []types.Proxy{ {Location: "/", Pass: "http://backend/"}, } - s.NoError(s.vhost.SetProxies(proxies)) - s.Len(s.vhost.Proxies(), 1) + check.NoError(t, vhost.SetProxies(proxies)) + check.Len(t, vhost.Proxies(), 1) - s.NoError(s.vhost.ClearProxies()) - s.Empty(s.vhost.Proxies()) + check.NoError(t, vhost.ClearProxies()) + check.Empty(t, vhost.Proxies()) } -func (s *ProxyVhostTestSuite) TestUpstreams() { +func TestProxyVhostUpstreams(t *testing.T) { + vhost, configDir := newProxyVhost(t) + // 初始应该没有上游服务器配置 - s.Empty(s.vhost.Upstreams()) + check.Empty(t, vhost.Upstreams()) // 设置上游服务器(Apache 使用 balancer) upstreams := []types.Upstream{ @@ -588,21 +568,17 @@ func (s *ProxyVhostTestSuite) TestUpstreams() { Keepalive: 32, }, } - s.NoError(s.vhost.SetUpstreams(upstreams)) + check.NoError(t, vhost.SetUpstreams(upstreams)) // 验证 balancer 文件已创建 - sharedDir := filepath.Join(s.configDir, "shared") - entries, err := os.ReadDir(sharedDir) - s.NoError(err) - s.NotEmpty(entries) + check.NotEmpty(t, confFiles(t, configDir, "shared", "", "")) - // 验证可以读取回来 - got := s.vhost.Upstreams() - s.Len(got, 1) - s.Equal("backend", got[0].Name) + check.DeepEqual(t, vhost.Upstreams(), upstreams, cmpopts.EquateEmpty()) } -func (s *ProxyVhostTestSuite) TestBalancerConfig() { +func TestProxyVhostBalancerConfig(t *testing.T) { + vhost, configDir := newProxyVhost(t) + upstreams := []types.Upstream{ { Name: "mybackend", @@ -613,38 +589,39 @@ func (s *ProxyVhostTestSuite) TestBalancerConfig() { Keepalive: 16, }, } - s.NoError(s.vhost.SetUpstreams(upstreams)) + check.NoError(t, vhost.SetUpstreams(upstreams)) // 读取配置文件内容 - sharedDir := filepath.Join(s.configDir, "shared") - entries, err := os.ReadDir(sharedDir) - s.NoError(err) - s.Require().NotEmpty(entries) + files := confFiles(t, configDir, "shared", "", "") + must.NotEmpty(t, files) + content, err := os.ReadFile(filepath.Join(configDir, "shared", files[0])) + must.NoError(t, err) - content, err := os.ReadFile(filepath.Join(sharedDir, entries[0].Name())) - s.NoError(err) - - s.Contains(string(content), "balancer://mybackend") - s.Contains(string(content), "BalancerMember") - s.Contains(string(content), "http://127.0.0.1:8080") - s.Contains(string(content), "lbmethod=bybusyness") + check.Contains(t, string(content), "balancer://mybackend") + check.Contains(t, string(content), "BalancerMember") + check.Contains(t, string(content), "http://127.0.0.1:8080") + check.Contains(t, string(content), "lbmethod=bybusyness") } -func (s *ProxyVhostTestSuite) TestClearUpstreams() { +func TestProxyVhostClearUpstreams(t *testing.T) { + vhost, _ := newProxyVhost(t) + upstreams := []types.Upstream{ { Name: "backend", Servers: map[string]string{"http://127.0.0.1:8080": ""}, }, } - s.NoError(s.vhost.SetUpstreams(upstreams)) - s.Len(s.vhost.Upstreams(), 1) + check.NoError(t, vhost.SetUpstreams(upstreams)) + check.Len(t, vhost.Upstreams(), 1) - s.NoError(s.vhost.ClearUpstreams()) - s.Empty(s.vhost.Upstreams()) + check.NoError(t, vhost.ClearUpstreams()) + check.Empty(t, vhost.Upstreams()) } -func (s *ProxyVhostTestSuite) TestProxySNI() { +func TestProxyVhostSNI(t *testing.T) { + vhost, configDir := newProxyVhost(t) + // 测试 SNI 配置的写入和解析 proxies := []types.Proxy{ { @@ -653,23 +630,22 @@ func (s *ProxyVhostTestSuite) TestProxySNI() { SNI: "backend.example.com", }, } - s.NoError(s.vhost.SetProxies(proxies)) + check.NoError(t, vhost.SetProxies(proxies)) // 读取配置文件内容,验证 SNI 已写入 - siteDir := filepath.Join(s.configDir, "site") + siteDir := filepath.Join(configDir, "site") content, err := os.ReadFile(filepath.Join(siteDir, "200-proxy.conf")) - s.NoError(err) + must.NoError(t, err) - s.Contains(string(content), "SSLProxyEngine On") - s.Contains(string(content), "# SNI: backend.example.com") + check.Contains(t, string(content), "SSLProxyEngine On") + check.Contains(t, string(content), "# SNI: backend.example.com") - // 验证可以解析回来 - got := s.vhost.Proxies() - s.Require().Len(got, 1) - s.Equal("backend.example.com", got[0].SNI) + check.DeepEqual(t, vhost.Proxies(), proxies, cmpopts.EquateEmpty()) } -func (s *ProxyVhostTestSuite) TestProxySubstitute() { +func TestProxyVhostSubstitute(t *testing.T) { + vhost, configDir := newProxyVhost(t) + // 测试内容替换的写入和解析 proxies := []types.Proxy{ { @@ -681,25 +657,22 @@ func (s *ProxyVhostTestSuite) TestProxySubstitute() { }, }, } - s.NoError(s.vhost.SetProxies(proxies)) + check.NoError(t, vhost.SetProxies(proxies)) // 读取配置文件内容,验证 Substitute 已写入 - siteDir := filepath.Join(s.configDir, "site") + siteDir := filepath.Join(configDir, "site") content, err := os.ReadFile(filepath.Join(siteDir, "200-proxy.conf")) - s.NoError(err) + must.NoError(t, err) - s.Contains(string(content), "mod_substitute") - s.Contains(string(content), "Substitute") + check.Contains(t, string(content), "mod_substitute") + check.Contains(t, string(content), "Substitute") - // 验证可以解析回来 - got := s.vhost.Proxies() - s.Require().Len(got, 1) - s.Require().NotNil(got[0].Replaces) - s.Equal("https://new.example.com", got[0].Replaces["http://old.example.com"]) - s.Equal("bar", got[0].Replaces["foo"]) + check.DeepEqual(t, vhost.Proxies(), proxies, cmpopts.EquateEmpty()) } -func (s *ProxyVhostTestSuite) TestProxySubstituteWithSlash() { +func TestProxyVhostSubstituteWithSlash(t *testing.T) { + vhost, configDir := newProxyVhost(t) + // 测试包含 / 的内容替换 proxies := []types.Proxy{ { @@ -710,24 +683,22 @@ func (s *ProxyVhostTestSuite) TestProxySubstituteWithSlash() { }, }, } - s.NoError(s.vhost.SetProxies(proxies)) + check.NoError(t, vhost.SetProxies(proxies)) // 读取配置文件内容 - siteDir := filepath.Join(s.configDir, "site") + siteDir := filepath.Join(configDir, "site") content, err := os.ReadFile(filepath.Join(siteDir, "200-proxy.conf")) - s.NoError(err) + must.NoError(t, err) // 验证使用 | 作为分隔符 - s.Contains(string(content), "Substitute \"s|http://old.example.com/path/to/resource|https://new.example.com/new/path|n\"") + check.Contains(t, string(content), "Substitute \"s|http://old.example.com/path/to/resource|https://new.example.com/new/path|n\"") - // 验证可以解析回来 - got := s.vhost.Proxies() - s.Require().Len(got, 1) - s.Require().NotNil(got[0].Replaces) - s.Equal("https://new.example.com/new/path", got[0].Replaces["http://old.example.com/path/to/resource"]) + check.DeepEqual(t, vhost.Proxies(), proxies, cmpopts.EquateEmpty()) } -func (s *ProxyVhostTestSuite) TestUpstreamMultipleServers() { +func TestProxyVhostUpstreamMultipleServers(t *testing.T) { + vhost, _ := newProxyVhost(t) + // 测试多个 BalancerMember 的解析 upstreams := []types.Upstream{ { @@ -740,15 +711,7 @@ func (s *ProxyVhostTestSuite) TestUpstreamMultipleServers() { Keepalive: 32, }, } - s.NoError(s.vhost.SetUpstreams(upstreams)) + check.NoError(t, vhost.SetUpstreams(upstreams)) - // 验证可以解析回来 - got := s.vhost.Upstreams() - s.Require().Len(got, 1) - s.Equal("test_upstream", got[0].Name) - s.Len(got[0].Servers, 3) - s.Contains(got[0].Servers, "127.0.0.1:8080") - s.Contains(got[0].Servers, "127.0.0.1:8081") - s.Contains(got[0].Servers, "127.0.0.1:8082") - s.Equal("loadfactor=5", got[0].Servers["127.0.0.1:8082"]) + check.DeepEqual(t, vhost.Upstreams(), upstreams, cmpopts.EquateEmpty()) } diff --git a/pkg/webserver/caddy/parser.go b/pkg/webserver/caddy/parser.go index 3081f9d87..7fb34e320 100644 --- a/pkg/webserver/caddy/parser.go +++ b/pkg/webserver/caddy/parser.go @@ -1,6 +1,7 @@ package caddy import ( + "errors" "fmt" "os" "regexp" @@ -92,7 +93,7 @@ func Parse(content string) (*conf.Config, error) { } if len(stack) != 1 { - return nil, fmt.Errorf("unclosed block") + return nil, errors.New("unclosed block") } return cfg, nil diff --git a/pkg/webserver/caddy/parser_test.go b/pkg/webserver/caddy/parser_test.go index 7085913dc..4d83cc4ad 100644 --- a/pkg/webserver/caddy/parser_test.go +++ b/pkg/webserver/caddy/parser_test.go @@ -4,20 +4,13 @@ import ( "strings" "testing" - "github.com/stretchr/testify/suite" + "github.com/libtnb/assert/check" + "github.com/libtnb/assert/must" "github.com/acepanel/panel/v3/pkg/webserver/conf" ) -type ParserTestSuite struct { - suite.Suite -} - -func TestParserTestSuite(t *testing.T) { - suite.Run(t, &ParserTestSuite{}) -} - -func (s *ParserTestSuite) TestStructure() { +func TestParserStructure(t *testing.T) { cfg, err := Parse(`# header { admin off @@ -41,53 +34,69 @@ https://www.a.com:443 { } } `) - s.Require().NoError(err) - s.Equal([]string{"header"}, cfg.Comments()) + must.NoError(t, err) + check.DeepEqual(t, cfg.Comments(), []string{"header"}) - global := cfg.All()[0] - s.NotNil(global.Block) - s.Equal("", global.Name) - s.Empty(global.Args) - s.Equal("off", global.Get("admin").Arg(0)) - - s.Equal("/etc/caddy/sites/*.conf", cfg.Get("import").Arg(0)) - s.Equal("(snippet)", cfg.All()[2].Name) - s.False(isSite(cfg.All()[2])) - - site := sites(cfg)[0] - s.Require().NotNil(site) - s.Equal([]string{"http://a.com:80", "https://a.com:443", "https://www.a.com:443"}, addresses(site)) - root := site.Get("root") - s.Equal([]string{"*", "/var/www"}, root.Values()) - s.Equal(" trailing", root.Trailing) - s.Equal("/x*", site.Get("@m").Get("path").Arg(0)) - s.Equal([]string{"@m", "hello world", "200"}, site.Get("respond").Values()) - s.Equal([]string{"tls1.2", "tls1.3"}, site.Get("tls").Get("protocols").Values()) -} - -func (s *ParserTestSuite) TestLexer() { - cfg, err := Parse("respond `{\"a\": \"b\"}` 200\nheader X-A \"with \\\"quote\\\"\" \\\n X-B 1\nrespond <Sep 14 10:00:00 ace_stat_demo: {"site":"demo","uri":"/a","status":200,"bytes":10,"ua":"curl","ip":"1.2.3.4","method":"GET","content_type":"text/html","req_length":100,"rt":0.5}`)) - require.Equal(t, "ace_stat_demo", tag) - entry, err := ParseLogEntry(tag, data) - require.NoError(t, err) - require.Equal(t, &LogEntry{Site: "demo", URI: "/a", Status: 200, Bytes: 10, UA: "curl", IP: "1.2.3.4", Method: "GET", ContentType: "text/html", ReqLength: 100, RequestTime: 0.5}, entry) -} - -func TestParseLogEntryCaddy(t *testing.T) { - msg := []byte(`{"level":"info","ts":1789386806.38,"logger":"http.log.access.ace_stat","msg":"handled request","request":{"remote_ip":"::1","remote_port":"49367","client_ip":"::1","proto":"HTTP/2.0","method":"POST","host":"localhost","uri":"/api?x=1","headers":{"User-Agent":["curl/8.7.1"],"Accept":["*/*"]}},"bytes_read":42,"user_id":"","duration":0.0009,"size":11,"status":404,"resp_headers":{"Content-Type":["text/html; charset=utf-8"]},"site":"demo"}`) - tag, data := ParseSyslog(msg) - require.Equal(t, "", tag) - entry, err := ParseLogEntry(tag, data) - require.NoError(t, err) - require.Equal(t, &LogEntry{Site: "demo", URI: "/api?x=1", Status: 404, Bytes: 11, UA: "curl/8.7.1", IP: "::1", Method: "POST", ContentType: "text/html; charset=utf-8", ReqLength: 42, RequestTime: 0.0009}, entry) +func TestParseLogEntry(t *testing.T) { + tests := []struct { + name string + msg string + wantTag string + want *LogEntry + }{ + { + name: "nginx", + msg: `<190>Sep 14 10:00:00 ace_stat_demo: {"site":"demo","uri":"/a","status":200,"bytes":10,"ua":"curl","ip":"1.2.3.4","method":"GET","content_type":"text/html","req_length":100,"rt":0.5}`, + wantTag: "ace_stat_demo", + want: &LogEntry{Site: "demo", URI: "/a", Status: 200, Bytes: 10, UA: "curl", IP: "1.2.3.4", Method: "GET", ContentType: "text/html", ReqLength: 100, RequestTime: 0.5}, + }, + { + name: "caddy", + msg: `{"level":"info","ts":1789386806.38,"logger":"http.log.access.ace_stat","msg":"handled request","request":{"remote_ip":"::1","remote_port":"49367","client_ip":"::1","proto":"HTTP/2.0","method":"POST","host":"localhost","uri":"/api?x=1","headers":{"User-Agent":["curl/8.7.1"],"Accept":["*/*"]}},"bytes_read":42,"user_id":"","duration":0.0009,"size":11,"status":404,"resp_headers":{"Content-Type":["text/html; charset=utf-8"]},"site":"demo"}`, + wantTag: "", + want: &LogEntry{Site: "demo", URI: "/api?x=1", Status: 404, Bytes: 11, UA: "curl/8.7.1", IP: "::1", Method: "POST", ContentType: "text/html; charset=utf-8", ReqLength: 42, RequestTime: 0.0009}, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + tag, data := ParseSyslog([]byte(test.msg)) + must.Equal(t, tag, test.wantTag) + entry, err := ParseLogEntry(tag, data) + must.NoError(t, err) + must.DeepEqual(t, entry, test.want) + }) + } }