mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-06 17:40:58 +00:00
add commands support
Signed-off-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
parent
c44aa2a118
commit
c236395c01
12 changed files with 303 additions and 33 deletions
57
act/runner/command_test.go
Normal file
57
act/runner/command_test.go
Normal file
|
@ -0,0 +1,57 @@
|
|||
package runner
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestSetEnv(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
ctx := context.Background()
|
||||
rc := new(RunContext)
|
||||
handler := rc.commandHandler(ctx)
|
||||
|
||||
handler("::set-env name=x::valz\n")
|
||||
assert.Equal("valz", rc.Env["x"])
|
||||
}
|
||||
|
||||
func TestSetOutput(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
ctx := context.Background()
|
||||
rc := new(RunContext)
|
||||
handler := rc.commandHandler(ctx)
|
||||
|
||||
handler("::set-output name=x::valz\n")
|
||||
assert.Equal("valz", rc.Outputs["x"])
|
||||
}
|
||||
|
||||
func TestAddpath(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
ctx := context.Background()
|
||||
rc := new(RunContext)
|
||||
handler := rc.commandHandler(ctx)
|
||||
|
||||
handler("::add-path::/zoo")
|
||||
assert.Equal("/zoo:", rc.Env["PATH"])
|
||||
|
||||
handler("::add-path::/booo")
|
||||
assert.Equal("/booo:/zoo:", rc.Env["PATH"])
|
||||
}
|
||||
|
||||
func TestStopCommands(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
ctx := context.Background()
|
||||
rc := new(RunContext)
|
||||
handler := rc.commandHandler(ctx)
|
||||
|
||||
handler("::set-env name=x::valz\n")
|
||||
assert.Equal("valz", rc.Env["x"])
|
||||
handler("::stop-commands::my-end-token\n")
|
||||
handler("::set-env name=x::abcd\n")
|
||||
assert.Equal("valz", rc.Env["x"])
|
||||
handler("::my-end-token::\n")
|
||||
handler("::set-env name=x::abcd\n")
|
||||
assert.Equal("abcd", rc.Env["x"])
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue