mirror of
https://github.com/hanzo-git/runner.git
synced 2026-10-30 19:33:27 +00:00
Native runner: module github.com/hanzo-git/runner, wire proto github.com/hanzo-git/actions-proto-go, command git-runner, GIT_* env, git expr context, git_* task-context keys, ghcr.io/hanzoai/runner-ubuntu job images. Derived work — upstream attribution + MIT terms in NOTICE/LICENSE. Co-authored-by: Hanzo Dev <[email protected]>
64 lines
1.5 KiB
Go
64 lines
1.5 KiB
Go
// Copyright 2026 The Git Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package model
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestReadActionDefaultsAndCaseInsensitiveUsing(t *testing.T) {
|
|
action, err := ReadAction(strings.NewReader(`
|
|
name: example
|
|
runs:
|
|
using: NoDe24
|
|
main: dist/index.js
|
|
`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if action.Runs.Using != ActionRunsUsingNode24 {
|
|
t.Fatalf("using = %q, want %q", action.Runs.Using, ActionRunsUsingNode24)
|
|
}
|
|
if action.Runs.PreIf != "always()" {
|
|
t.Fatalf("pre-if = %q, want always()", action.Runs.PreIf)
|
|
}
|
|
if action.Runs.PostIf != "always()" {
|
|
t.Fatalf("post-if = %q, want always()", action.Runs.PostIf)
|
|
}
|
|
}
|
|
|
|
func TestReadActionPreservesExplicitConditions(t *testing.T) {
|
|
action, err := ReadAction(strings.NewReader(`
|
|
runs:
|
|
using: composite
|
|
pre-if: success()
|
|
post-if: failure()
|
|
steps:
|
|
- run: echo hello
|
|
`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if action.Runs.PreIf != "success()" || action.Runs.PostIf != "failure()" {
|
|
t.Fatalf("conditions = %q/%q, want explicit values", action.Runs.PreIf, action.Runs.PostIf)
|
|
}
|
|
if !action.Runs.Using.IsComposite() || action.Runs.Using.IsDocker() || action.Runs.Using.IsNode() {
|
|
t.Fatalf("unexpected using predicates for %q", action.Runs.Using)
|
|
}
|
|
}
|
|
|
|
func TestReadActionRejectsUnknownUsing(t *testing.T) {
|
|
_, err := ReadAction(strings.NewReader(`
|
|
runs:
|
|
using: node99
|
|
`))
|
|
if err == nil {
|
|
t.Fatal("expected unknown runs.using to fail")
|
|
}
|
|
if !strings.Contains(err.Error(), "node99") {
|
|
t.Fatalf("error = %q, want invalid value", err)
|
|
}
|
|
}
|