|
5 | 5 | "context" |
6 | 6 | "errors" |
7 | 7 | "fmt" |
8 | | - "os" |
9 | 8 | "runtime" |
10 | 9 | "slices" |
11 | 10 | "strings" |
@@ -281,63 +280,6 @@ func TestRunContext_GetBindsAndMounts(t *testing.T) { |
281 | 280 | }) |
282 | 281 | } |
283 | 282 |
|
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 | | - |
341 | 283 | func TestRunContext_GetGithubContextRef(t *testing.T) { |
342 | 284 | table := []struct { |
343 | 285 | event string |
|
0 commit comments