From 579c5e24fc832de24029efa13960a5a131d01070 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 21 Aug 2025 11:54:04 +0000 Subject: [PATCH] chore: remove TestRunContext_GetGitHubContext (#900) It does not assert anything useful and te associated function is otherwise heavily used in many tests. It may benefit from unit testing but this test would need to be done very differently to achieve that. - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/900): chore: remove TestRunContext_GetGitHubContext Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/900 Reviewed-by: Michael Kriese Co-authored-by: Earl Warren Co-committed-by: Earl Warren --- act/runner/run_context_test.go | 58 ---------------------------------- 1 file changed, 58 deletions(-) diff --git a/act/runner/run_context_test.go b/act/runner/run_context_test.go index 7d865777..33f77466 100644 --- a/act/runner/run_context_test.go +++ b/act/runner/run_context_test.go @@ -5,7 +5,6 @@ import ( "context" "errors" "fmt" - "os" "runtime" "slices" "strings" @@ -281,63 +280,6 @@ func TestRunContext_GetBindsAndMounts(t *testing.T) { }) } -func TestRunContext_GetGitHubContext(t *testing.T) { - log.SetLevel(log.DebugLevel) - - cwd, err := os.Getwd() - assert.Nil(t, err) - - rc := &RunContext{ - Config: &Config{ - EventName: "push", - Workdir: cwd, - }, - Run: &model.Run{ - Workflow: &model.Workflow{ - Name: "GitHubContextTest", - }, - }, - Name: "GitHubContextTest", - CurrentStep: "step", - Matrix: map[string]any{}, - Env: map[string]string{}, - ExtraPath: []string{}, - StepResults: map[string]*model.StepResult{}, - OutputMappings: map[MappableOutput]MappableOutput{}, - } - rc.Run.JobID = "job1" - - ghc := rc.getGithubContext(t.Context()) - - log.Debugf("%v", ghc) - - actor := "nektos/act" - if a := os.Getenv("ACT_ACTOR"); a != "" { - actor = a - } - - repo := "forgejo/runner" - if r := os.Getenv("ACT_REPOSITORY"); r != "" { - repo = r - } - - owner := "code.forgejo.org" - if o := os.Getenv("ACT_OWNER"); o != "" { - owner = o - } - - assert.Equal(t, ghc.RunID, "1") - assert.Equal(t, ghc.RunNumber, "1") - assert.Equal(t, ghc.RetentionDays, "0") - assert.Equal(t, ghc.Actor, actor) - assert.True(t, strings.HasSuffix(ghc.Repository, repo)) - assert.Equal(t, ghc.RepositoryOwner, owner) - assert.Equal(t, ghc.RunnerPerflog, "/dev/null") - assert.Equal(t, ghc.Token, rc.Config.Secrets["GITHUB_TOKEN"]) - assert.Equal(t, ghc.Token, rc.Config.Secrets["FORGEJO_TOKEN"]) - assert.Equal(t, ghc.Job, "job1") -} - func TestRunContext_GetGithubContextRef(t *testing.T) { table := []struct { event string