e2e: Cover RunnerDeployment (#668)
Previously the E2E test suite covered only RunnerSet. This refactors the existing E2E test code to extract the common test structure into a `env` struct and its methods, and use it to write two very similar tests, one for RunnerSet and another for RunnerDeployment.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/actions-runner-controller/actions-runner-controller/testing/runtime"
|
||||
)
|
||||
|
||||
type ScriptConfig struct {
|
||||
Env []string
|
||||
|
||||
Dir string
|
||||
}
|
||||
|
||||
type Bash struct {
|
||||
runtime.Cmdr
|
||||
}
|
||||
|
||||
func (k *Bash) RunScript(ctx context.Context, path string, cfg ScriptConfig) error {
|
||||
abs, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := k.CombinedOutput(k.bashRunScriptCmd(ctx, abs, cfg)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k *Bash) bashRunScriptCmd(ctx context.Context, path string, cfg ScriptConfig) *exec.Cmd {
|
||||
cmd := exec.CommandContext(ctx, "bash", path)
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = append(cmd.Env, cfg.Env...)
|
||||
cmd.Dir = cfg.Dir
|
||||
|
||||
return cmd
|
||||
}
|
||||
Reference in New Issue
Block a user