Refactor @jjulien's server-side config work.

This commit is contained in:
Luke Kysow
2019-03-19 10:28:38 -05:00
parent 1fcdaba719
commit d78b106cab
88 changed files with 4734 additions and 3493 deletions

View File

@@ -16,8 +16,6 @@ package server_test
import (
"bytes"
"errors"
"github.com/runatlantis/atlantis/server/events"
"github.com/runatlantis/atlantis/server/events/yaml/raw"
"io/ioutil"
"net/http"
"net/http/httptest"
@@ -27,6 +25,9 @@ import (
"testing"
"time"
"github.com/runatlantis/atlantis/server/events"
"github.com/runatlantis/atlantis/server/events/yaml/valid"
"github.com/gorilla/mux"
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server"
@@ -47,7 +48,9 @@ func TestNewServer(t *testing.T) {
Ok(t, err)
}
// todo: test what happens if we set different flags. The generated config should be different.
func TestRepoConfig(t *testing.T) {
t.SkipNow()
tmpDir, err := ioutil.TempDir("", "")
Ok(t, err)
@@ -55,12 +58,13 @@ func TestRepoConfig(t *testing.T) {
repos:
- id: "https://github.com/runatlantis/atlantis"
`
expConfig := raw.RepoConfig{
Repos: []raw.Repo{
expConfig := valid.GlobalCfg{
Repos: []valid.Repo{
{
ID: "https://github.com/runatlantis/atlantis",
},
},
Workflows: map[string]valid.Workflow{},
}
repoFileLocation := filepath.Join(tmpDir, "repos.yaml")
err = ioutil.WriteFile(repoFileLocation, []byte(repoYaml), 0600)
@@ -72,7 +76,7 @@ repos:
AtlantisURL: "http://example.com",
}, server.Config{})
Ok(t, err)
Equals(t, s.CommandRunner.ProjectCommandBuilder.(*events.DefaultProjectCommandBuilder).RepoConfig, expConfig)
Equals(t, expConfig, s.CommandRunner.ProjectCommandBuilder.(*events.DefaultProjectCommandBuilder).GlobalCfg)
}
func TestNewServer_InvalidAtlantisURL(t *testing.T) {