chore: Add Struct required tags and Server Struct Validator (#5371)

Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
This commit is contained in:
Simon Heather
2025-03-09 11:34:48 +00:00
committed by GitHub
parent 001690e568
commit 4bea4e934a
13 changed files with 122 additions and 105 deletions

View File

@@ -26,6 +26,7 @@ import (
"github.com/gorilla/mux"
. "github.com/petergtz/pegomock/v4"
"github.com/runatlantis/atlantis/cmd"
"github.com/runatlantis/atlantis/server"
"github.com/runatlantis/atlantis/server/controllers/web_templates"
tMocks "github.com/runatlantis/atlantis/server/controllers/web_templates/mocks"
@@ -36,13 +37,28 @@ import (
. "github.com/runatlantis/atlantis/testing"
)
func TestNewServer(t *testing.T) {
const (
testAtlantisVersion = "1.0.0"
testAtlantisUrl = "http://example.com"
testLockingDBType = cmd.DefaultLockingDBType
testGitHubHostName = cmd.DefaultGHHostname
testGitHubUser = "user"
)
func TestNewServer_GitHubUser(t *testing.T) {
t.Log("Run through NewServer constructor")
tmpDir := t.TempDir()
_, err := server.NewServer(server.UserConfig{
DataDir: tmpDir,
AtlantisURL: "http://example.com",
}, server.Config{})
_, err := server.NewServer(
server.UserConfig{
DataDir: tmpDir,
AtlantisURL: testAtlantisUrl,
LockingDBType: testLockingDBType,
GithubHostname: testGitHubHostName,
GithubUser: testGitHubUser,
}, server.Config{
AtlantisVersion: testAtlantisVersion,
},
)
Ok(t, err)
}
@@ -273,12 +289,3 @@ func TestParseAtlantisURL(t *testing.T) {
})
}
}
func TestCommandRunnerVCSClientInitialized(t *testing.T) {
s, _ := server.NewServer(server.UserConfig{
AtlantisURL: "http://example.com",
},
server.Config{},
)
Assert(t, s.CommandRunner.VCSClient != nil, "VCSClient must not be nil.")
}