mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-28 22:28: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
70 lines
1.3 KiB
Go
70 lines
1.3 KiB
Go
package server
|
|
|
|
import (
|
|
. "github.com/hootsuite/atlantis/testing_util"
|
|
"io/ioutil"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
var tempConfigFile = "/tmp/" + AtlantisConfigFile
|
|
|
|
func TestConfigFileExists_invalid_path(t *testing.T) {
|
|
var c Config
|
|
Equals(t, c.Exists("/invalid/path"), false)
|
|
}
|
|
|
|
func TestConfigFileExists_valid_path(t *testing.T) {
|
|
var c Config
|
|
var str = `
|
|
---
|
|
terraform_version: "0.0.1"
|
|
pre_apply:
|
|
commands:
|
|
- "echo"
|
|
- "date"
|
|
pre_plan:
|
|
commands:
|
|
- "echo"
|
|
- "date"
|
|
stash_path: "file/path"
|
|
`
|
|
writeAtlantisConfigFile([]byte(str))
|
|
defer os.Remove(tempConfigFile)
|
|
Equals(t, c.Exists("/tmp"), true)
|
|
}
|
|
|
|
func TestConfigFileRead_invalid_config(t *testing.T) {
|
|
var c Config
|
|
str := []byte(`---invalid`)
|
|
writeAtlantisConfigFile(str)
|
|
defer os.Remove(tempConfigFile)
|
|
err := c.Read("/tmp")
|
|
Assert(t, err != nil, "expect an error")
|
|
}
|
|
|
|
func TestConfigFileRead_valid_config(t *testing.T) {
|
|
var c Config
|
|
var str = `
|
|
---
|
|
terraform_version: "0.0.1"
|
|
pre_apply:
|
|
commands:
|
|
- "echo"
|
|
- "date"
|
|
pre_plan:
|
|
commands:
|
|
- "echo"
|
|
- "date"
|
|
stash_path: "file/path"
|
|
`
|
|
writeAtlantisConfigFile([]byte(str))
|
|
defer os.Remove(tempConfigFile)
|
|
err := c.Read("/tmp")
|
|
Assert(t, err == nil, "should be valid json")
|
|
}
|
|
|
|
func writeAtlantisConfigFile(s []byte) error {
|
|
return ioutil.WriteFile(tempConfigFile, s, 0644)
|
|
}
|