mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-28 21:38:25 +00:00
* set version in one place * rename ExecutionContext to CommandContext * delete unneeded PullRequestContext since it just duplicated what is in CommandContext * split fields inside CommandContext into Repo, PullRequest, and User models * clean up unused fields * remove base_executor stuff which was trying to do inheritance in go and didn't get us anywhere * clean up unused code and assets * created a locking.Client that creates the Keys that are used on the front-end. This allows the backends to store the locks any way they like as long as they support the interface
68 lines
1.9 KiB
Go
68 lines
1.9 KiB
Go
package server
|
|
|
|
import (
|
|
"github.com/hootsuite/atlantis/logging"
|
|
. "github.com/hootsuite/atlantis/testing_util"
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
var level logging.LogLevel = logging.Info
|
|
var logger = &logging.SimpleLogger{
|
|
Source: "server",
|
|
Log: log.New(os.Stderr, "", log.LstdFlags),
|
|
Level: level,
|
|
}
|
|
|
|
func TestPreRunCreateScript_empty(t *testing.T) {
|
|
scriptName, err := createScript(nil)
|
|
Assert(t, scriptName == "", "there should not be a script name")
|
|
Assert(t, err == nil, "there should not be an error")
|
|
}
|
|
|
|
func TestPreRunCreateScript_valid(t *testing.T) {
|
|
cmds := []string{"echo", "date"}
|
|
scriptName, err := createScript(cmds)
|
|
Assert(t, scriptName != "", "there should be a script name")
|
|
Assert(t, err == nil, "there should not be an error")
|
|
}
|
|
|
|
func TestPreRunExecuteScript_invalid(t *testing.T) {
|
|
cmds := []string{"invalid", "command"}
|
|
scriptName, _ := createScript(cmds)
|
|
_, err := execute(scriptName)
|
|
Assert(t, err != nil, "there should be an error")
|
|
}
|
|
|
|
func TestPreRunExecuteScript_valid(t *testing.T) {
|
|
cmds := []string{"echo", "date"}
|
|
scriptName, _ := createScript(cmds)
|
|
output, err := execute(scriptName)
|
|
Assert(t, err == nil, "there should not be an error")
|
|
Assert(t, output != "", "there should be output")
|
|
}
|
|
|
|
func TestPreRun_valid(t *testing.T) {
|
|
cmds := []string{"echo", "date"}
|
|
prePlan := PrePlan{Commands: cmds}
|
|
preApply := PreApply{Commands: cmds}
|
|
var config Config
|
|
config.PrePlan = prePlan
|
|
config.PreApply = preApply
|
|
config.StashPath = "/some/path"
|
|
err := PreRun(&config, logger, "/some/path", &Command{environment: "staging", commandType: Plan})
|
|
Assert(t, err == nil, "should not error")
|
|
|
|
}
|
|
|
|
func TestPreRun_partial_valid(t *testing.T) {
|
|
cmds := []string{"echo", "date"}
|
|
prePlan := PrePlan{Commands: cmds}
|
|
var config Config
|
|
config.PrePlan = prePlan
|
|
config.StashPath = "/some/path"
|
|
err := PreRun(&config, logger, "/some/path", &Command{environment: "staging", commandType: Plan})
|
|
Assert(t, err == nil, "should not error")
|
|
}
|