mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-29 16:48:21 +00:00
* Moved CommandContext and CommandResult to models (#193) * Moved CommandContext and CommandResult to models * move from models to command rename CommandContext -> Context rename CommandResult -> Result * moved command related helpers into command package * move ProjectCommandContext and ProjectResult to command/project package * move project command context and project result * revert unrelated code * move tests * fix left over * fix linting * fix tests * remove unused import * fix project context dependencies * fix depenedecies * fix typo
109 lines
1.9 KiB
Go
109 lines
1.9 KiB
Go
package command_test
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/runatlantis/atlantis/server/events/command"
|
|
"github.com/runatlantis/atlantis/server/events/models"
|
|
. "github.com/runatlantis/atlantis/testing"
|
|
)
|
|
|
|
func TestCommandResult_HasErrors(t *testing.T) {
|
|
cases := map[string]struct {
|
|
cr command.Result
|
|
exp bool
|
|
}{
|
|
"error": {
|
|
cr: command.Result{
|
|
Error: errors.New("err"),
|
|
},
|
|
exp: true,
|
|
},
|
|
"failure": {
|
|
cr: command.Result{
|
|
Failure: "failure",
|
|
},
|
|
exp: true,
|
|
},
|
|
"empty results list": {
|
|
cr: command.Result{
|
|
ProjectResults: []command.ProjectResult{},
|
|
},
|
|
exp: false,
|
|
},
|
|
"successful plan": {
|
|
cr: command.Result{
|
|
ProjectResults: []command.ProjectResult{
|
|
{
|
|
PlanSuccess: &models.PlanSuccess{},
|
|
},
|
|
},
|
|
},
|
|
exp: false,
|
|
},
|
|
"successful apply": {
|
|
cr: command.Result{
|
|
ProjectResults: []command.ProjectResult{
|
|
{
|
|
ApplySuccess: "success",
|
|
},
|
|
},
|
|
},
|
|
exp: false,
|
|
},
|
|
"single errored project": {
|
|
cr: command.Result{
|
|
ProjectResults: []command.ProjectResult{
|
|
{
|
|
Error: errors.New("err"),
|
|
},
|
|
},
|
|
},
|
|
exp: true,
|
|
},
|
|
"single failed project": {
|
|
cr: command.Result{
|
|
ProjectResults: []command.ProjectResult{
|
|
{
|
|
Failure: "failure",
|
|
},
|
|
},
|
|
},
|
|
exp: true,
|
|
},
|
|
"two successful projects": {
|
|
cr: command.Result{
|
|
ProjectResults: []command.ProjectResult{
|
|
{
|
|
PlanSuccess: &models.PlanSuccess{},
|
|
},
|
|
{
|
|
ApplySuccess: "success",
|
|
},
|
|
},
|
|
},
|
|
exp: false,
|
|
},
|
|
"one successful, one failed project": {
|
|
cr: command.Result{
|
|
ProjectResults: []command.ProjectResult{
|
|
{
|
|
PlanSuccess: &models.PlanSuccess{},
|
|
},
|
|
{
|
|
Failure: "failed",
|
|
},
|
|
},
|
|
},
|
|
exp: true,
|
|
},
|
|
}
|
|
|
|
for descrip, c := range cases {
|
|
t.Run(descrip, func(t *testing.T) {
|
|
Equals(t, c.exp, c.cr.HasErrors())
|
|
})
|
|
}
|
|
}
|