Skip to content

Commit 579c5e2

Browse files
earl-warrenearl-warren
authored andcommitted
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 <[email protected]> Co-authored-by: Earl Warren <[email protected]> Co-committed-by: Earl Warren <[email protected]>
1 parent 8a44eb4 commit 579c5e2

File tree

1 file changed

+0
-58
lines changed

1 file changed

+0
-58
lines changed

act/runner/run_context_test.go

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"errors"
77
"fmt"
8-
"os"
98
"runtime"
109
"slices"
1110
"strings"
@@ -281,63 +280,6 @@ func TestRunContext_GetBindsAndMounts(t *testing.T) {
281280
})
282281
}
283282

284-
func TestRunContext_GetGitHubContext(t *testing.T) {
285-
log.SetLevel(log.DebugLevel)
286-
287-
cwd, err := os.Getwd()
288-
assert.Nil(t, err)
289-
290-
rc := &RunContext{
291-
Config: &Config{
292-
EventName: "push",
293-
Workdir: cwd,
294-
},
295-
Run: &model.Run{
296-
Workflow: &model.Workflow{
297-
Name: "GitHubContextTest",
298-
},
299-
},
300-
Name: "GitHubContextTest",
301-
CurrentStep: "step",
302-
Matrix: map[string]any{},
303-
Env: map[string]string{},
304-
ExtraPath: []string{},
305-
StepResults: map[string]*model.StepResult{},
306-
OutputMappings: map[MappableOutput]MappableOutput{},
307-
}
308-
rc.Run.JobID = "job1"
309-
310-
ghc := rc.getGithubContext(t.Context())
311-
312-
log.Debugf("%v", ghc)
313-
314-
actor := "nektos/act"
315-
if a := os.Getenv("ACT_ACTOR"); a != "" {
316-
actor = a
317-
}
318-
319-
repo := "forgejo/runner"
320-
if r := os.Getenv("ACT_REPOSITORY"); r != "" {
321-
repo = r
322-
}
323-
324-
owner := "code.forgejo.org"
325-
if o := os.Getenv("ACT_OWNER"); o != "" {
326-
owner = o
327-
}
328-
329-
assert.Equal(t, ghc.RunID, "1")
330-
assert.Equal(t, ghc.RunNumber, "1")
331-
assert.Equal(t, ghc.RetentionDays, "0")
332-
assert.Equal(t, ghc.Actor, actor)
333-
assert.True(t, strings.HasSuffix(ghc.Repository, repo))
334-
assert.Equal(t, ghc.RepositoryOwner, owner)
335-
assert.Equal(t, ghc.RunnerPerflog, "/dev/null")
336-
assert.Equal(t, ghc.Token, rc.Config.Secrets["GITHUB_TOKEN"])
337-
assert.Equal(t, ghc.Token, rc.Config.Secrets["FORGEJO_TOKEN"])
338-
assert.Equal(t, ghc.Job, "job1")
339-
}
340-
341283
func TestRunContext_GetGithubContextRef(t *testing.T) {
342284
table := []struct {
343285
event string

0 commit comments

Comments
 (0)