1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-10 18:50:59 +00:00

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.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/900): <!--number 900 --><!--line 0 --><!--description Y2hvcmU6IHJlbW92ZSBUZXN0UnVuQ29udGV4dF9HZXRHaXRIdWJDb250ZXh0-->chore: remove TestRunContext_GetGitHubContext<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/900
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-08-21 11:54:04 +00:00 committed by earl-warren
parent 8a44eb421f
commit 579c5e24fc
No known key found for this signature in database
GPG key ID: F128CBE6AB3A7201

View file

@ -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