From a6fa98926cad65ff8c6b5f551891ac2f992136cd Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 29 Jul 2025 13:34:04 +0000 Subject: [PATCH] chore: a single testutils for both act and the runner (#759) keep it DRY - other - [PR](https://code.forgejo.org/forgejo/runner//pulls/759): chore: a single testutils for both act and the runner Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/759 Reviewed-by: fnetX Co-authored-by: Earl Warren Co-committed-by: Earl Warren --- act/runner/run_context_test.go | 2 +- internal/pkg/report/reporter_test.go | 2 +- internal/pkg/testutils/mockvariable.go | 10 ---------- {act/testutils => testutils}/mockvariable.go | 0 4 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 internal/pkg/testutils/mockvariable.go rename {act/testutils => testutils}/mockvariable.go (100%) diff --git a/act/runner/run_context_test.go b/act/runner/run_context_test.go index 1f443953..df53f93a 100644 --- a/act/runner/run_context_test.go +++ b/act/runner/run_context_test.go @@ -13,7 +13,7 @@ import ( "code.forgejo.org/forgejo/runner/act/container" "code.forgejo.org/forgejo/runner/act/exprparser" "code.forgejo.org/forgejo/runner/act/model" - "code.forgejo.org/forgejo/runner/act/testutils" + "code.forgejo.org/forgejo/runner/testutils" "github.com/docker/go-connections/nat" log "github.com/sirupsen/logrus" diff --git a/internal/pkg/report/reporter_test.go b/internal/pkg/report/reporter_test.go index 4f110ce1..5a7563c8 100644 --- a/internal/pkg/report/reporter_test.go +++ b/internal/pkg/report/reporter_test.go @@ -21,7 +21,7 @@ import ( "google.golang.org/protobuf/types/known/structpb" "code.forgejo.org/forgejo/runner/internal/pkg/client/mocks" - "code.forgejo.org/forgejo/runner/internal/pkg/testutils" + "code.forgejo.org/forgejo/runner/testutils" ) func rowsToString(rows []*runnerv1.LogRow) string { diff --git a/internal/pkg/testutils/mockvariable.go b/internal/pkg/testutils/mockvariable.go deleted file mode 100644 index 3307b89e..00000000 --- a/internal/pkg/testutils/mockvariable.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2025 The Forgejo Authors. All rights reserved. -// SPDX-License-Identifier: MIT - -package testutils - -func MockVariable[T any](p *T, v T) (reset func()) { - old := *p - *p = v - return func() { *p = old } -} diff --git a/act/testutils/mockvariable.go b/testutils/mockvariable.go similarity index 100% rename from act/testutils/mockvariable.go rename to testutils/mockvariable.go