|
|
@ -37,8 +37,7 @@ var resourcesWithFailureState = Configuration{
|
|
|
|
Type: "test",
|
|
|
|
Type: "test",
|
|
|
|
State: &ResourceState{
|
|
|
|
State: &ResourceState{
|
|
|
|
Status: Failed,
|
|
|
|
Status: Failed,
|
|
|
|
Errors:[]string{"test induced error",
|
|
|
|
Errors: []string{"test induced error"},
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}},
|
|
|
|
}},
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -48,24 +47,15 @@ var expandedConfig = ExpandedTemplate{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var deploymentName = "deployment"
|
|
|
|
var deploymentName = "deployment"
|
|
|
|
var deploymentNoManifestName = "deploymentNoManifest"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var manifestName = "manifest-2"
|
|
|
|
var manifestName = "manifest-2"
|
|
|
|
var manifest = Manifest{Name: manifestName, ExpandedConfig: &configuration, Layout: &layout}
|
|
|
|
var manifest = Manifest{Name: manifestName, ExpandedConfig: &configuration, Layout: &layout}
|
|
|
|
var manifestMap = map[string]*Manifest{manifest.Name: &manifest}
|
|
|
|
var manifestMap = map[string]*Manifest{manifest.Name: &manifest}
|
|
|
|
|
|
|
|
|
|
|
|
var deploymentNoManifest = Deployment{
|
|
|
|
|
|
|
|
Name: "test",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var deployment = Deployment{
|
|
|
|
var deployment = Deployment{
|
|
|
|
Name: "test",
|
|
|
|
Name: "test",
|
|
|
|
Manifests: manifestMap,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var deploymentWithConfiguration = Deployment{
|
|
|
|
|
|
|
|
Name: "test",
|
|
|
|
|
|
|
|
Manifests: manifestMap,
|
|
|
|
|
|
|
|
Current: &configuration,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var deploymentList = []Deployment{deployment, {Name: "test2"}}
|
|
|
|
var deploymentList = []Deployment{deployment, {Name: "test2"}}
|
|
|
|
|
|
|
|
|
|
|
|
var typeInstMap = map[string][]string{"test": []string{"test"}}
|
|
|
|
var typeInstMap = map[string][]string{"test": []string{"test"}}
|
|
|
@ -83,10 +73,10 @@ func (expander *expanderStub) ExpandTemplate(t Template) (*ExpandedTemplate, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type deployerStub struct {
|
|
|
|
type deployerStub struct {
|
|
|
|
FailCreate bool
|
|
|
|
FailCreate bool
|
|
|
|
Created []*Configuration
|
|
|
|
Created []*Configuration
|
|
|
|
FailDelete bool
|
|
|
|
FailDelete bool
|
|
|
|
Deleted []*Configuration
|
|
|
|
Deleted []*Configuration
|
|
|
|
FailCreateResource bool
|
|
|
|
FailCreateResource bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -174,16 +164,12 @@ func (repository *repositoryStub) GetDeployment(d string) (*Deployment, error) {
|
|
|
|
return &deployment, nil
|
|
|
|
return &deployment, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if d == deploymentNoManifestName {
|
|
|
|
|
|
|
|
return &deploymentNoManifest, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil, errTest
|
|
|
|
return nil, errTest
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (repository *repositoryStub) GetValidDeployment(d string) (*Deployment, error) {
|
|
|
|
func (repository *repositoryStub) GetValidDeployment(d string) (*Deployment, error) {
|
|
|
|
repository.GetValid = append(repository.GetValid, d)
|
|
|
|
repository.GetValid = append(repository.GetValid, d)
|
|
|
|
return &deploymentWithConfiguration, nil
|
|
|
|
return &deployment, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (repository *repositoryStub) SetDeploymentStatus(name string, status DeploymentStatus) error {
|
|
|
|
func (repository *repositoryStub) SetDeploymentStatus(name string, status DeploymentStatus) error {
|
|
|
@ -193,12 +179,12 @@ func (repository *repositoryStub) SetDeploymentStatus(name string, status Deploy
|
|
|
|
|
|
|
|
|
|
|
|
func (repository *repositoryStub) CreateDeployment(d string) (*Deployment, error) {
|
|
|
|
func (repository *repositoryStub) CreateDeployment(d string) (*Deployment, error) {
|
|
|
|
repository.Created = append(repository.Created, d)
|
|
|
|
repository.Created = append(repository.Created, d)
|
|
|
|
return &deploymentWithConfiguration, nil
|
|
|
|
return &deployment, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (repository *repositoryStub) DeleteDeployment(d string, forget bool) (*Deployment, error) {
|
|
|
|
func (repository *repositoryStub) DeleteDeployment(d string, forget bool) (*Deployment, error) {
|
|
|
|
repository.Deleted = append(repository.Deleted, d)
|
|
|
|
repository.Deleted = append(repository.Deleted, d)
|
|
|
|
return &deploymentWithConfiguration, nil
|
|
|
|
return &deployment, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (repository *repositoryStub) AddManifest(d string, manifest *Manifest) error {
|
|
|
|
func (repository *repositoryStub) AddManifest(d string, manifest *Manifest) error {
|
|
|
@ -206,6 +192,14 @@ func (repository *repositoryStub) AddManifest(d string, manifest *Manifest) erro
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (repository *repositoryStub) GetLatestManifest(d string) (*Manifest, error) {
|
|
|
|
|
|
|
|
if d == deploymentName {
|
|
|
|
|
|
|
|
return repository.ManifestAdd[d], nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil, errTest
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (repository *repositoryStub) ListManifests(d string) (map[string]*Manifest, error) {
|
|
|
|
func (repository *repositoryStub) ListManifests(d string) (map[string]*Manifest, error) {
|
|
|
|
if d == deploymentName {
|
|
|
|
if d == deploymentName {
|
|
|
|
return manifestMap, nil
|
|
|
|
return manifestMap, nil
|
|
|
@ -250,8 +244,12 @@ var testManager = NewManager(testExpander, testDeployer, testRepository)
|
|
|
|
func TestListDeployments(t *testing.T) {
|
|
|
|
func TestListDeployments(t *testing.T) {
|
|
|
|
testRepository.reset()
|
|
|
|
testRepository.reset()
|
|
|
|
d, err := testManager.ListDeployments()
|
|
|
|
d, err := testManager.ListDeployments()
|
|
|
|
if !reflect.DeepEqual(d, deploymentList) || err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.FailNow()
|
|
|
|
t.Fatalf(err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(d, deploymentList) {
|
|
|
|
|
|
|
|
t.Fatalf("invalid deployment list")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -259,40 +257,48 @@ func TestListDeploymentsFail(t *testing.T) {
|
|
|
|
testRepository.reset()
|
|
|
|
testRepository.reset()
|
|
|
|
testRepository.FailListDeployments = true
|
|
|
|
testRepository.FailListDeployments = true
|
|
|
|
d, err := testManager.ListDeployments()
|
|
|
|
d, err := testManager.ListDeployments()
|
|
|
|
if d != nil || err != errTest {
|
|
|
|
if err != errTest {
|
|
|
|
t.FailNow()
|
|
|
|
t.Fatalf(err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if d != nil {
|
|
|
|
|
|
|
|
t.Fatalf("deployment list is not empty")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestGetDeployment(t *testing.T) {
|
|
|
|
func TestGetDeployment(t *testing.T) {
|
|
|
|
testRepository.reset()
|
|
|
|
testRepository.reset()
|
|
|
|
d, err := testManager.GetDeployment(deploymentName)
|
|
|
|
d, err := testManager.GetDeployment(deploymentName)
|
|
|
|
if !reflect.DeepEqual(d, &deploymentWithConfiguration) || err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.FailNow()
|
|
|
|
t.Fatalf(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestGetDeploymentNoManifest(t *testing.T) {
|
|
|
|
if !reflect.DeepEqual(d, &deployment) {
|
|
|
|
testRepository.reset()
|
|
|
|
t.Fatalf("invalid deployment")
|
|
|
|
d, err := testManager.GetDeployment(deploymentNoManifestName)
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(d, &deploymentNoManifest) || err != nil {
|
|
|
|
|
|
|
|
t.FailNow()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestListManifests(t *testing.T) {
|
|
|
|
func TestListManifests(t *testing.T) {
|
|
|
|
testRepository.reset()
|
|
|
|
testRepository.reset()
|
|
|
|
m, err := testManager.ListManifests(deploymentName)
|
|
|
|
m, err := testManager.ListManifests(deploymentName)
|
|
|
|
if !reflect.DeepEqual(m, manifestMap) || err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.FailNow()
|
|
|
|
t.Fatalf(err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(m, manifestMap) {
|
|
|
|
|
|
|
|
t.Fatalf("invalid manifest map")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestGetManifest(t *testing.T) {
|
|
|
|
func TestGetManifest(t *testing.T) {
|
|
|
|
testRepository.reset()
|
|
|
|
testRepository.reset()
|
|
|
|
m, err := testManager.GetManifest(deploymentName, manifestName)
|
|
|
|
m, err := testManager.GetManifest(deploymentName, manifestName)
|
|
|
|
if !reflect.DeepEqual(m, &manifest) || err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.FailNow()
|
|
|
|
t.Fatalf(err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(m, &manifest) {
|
|
|
|
|
|
|
|
t.Fatalf("invalid manifest")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -300,36 +306,36 @@ func TestCreateDeployment(t *testing.T) {
|
|
|
|
testRepository.reset()
|
|
|
|
testRepository.reset()
|
|
|
|
testDeployer.reset()
|
|
|
|
testDeployer.reset()
|
|
|
|
d, err := testManager.CreateDeployment(&template)
|
|
|
|
d, err := testManager.CreateDeployment(&template)
|
|
|
|
if !reflect.DeepEqual(d, &deploymentWithConfiguration) || err != nil {
|
|
|
|
if !reflect.DeepEqual(d, &deployment) || err != nil {
|
|
|
|
t.Errorf("Expected a different set of response values from invoking CreateDeployment."+
|
|
|
|
t.Fatalf("Expected a different set of response values from invoking CreateDeployment."+
|
|
|
|
"Received: %s, %s. Expected: %s, %s.", d, err, &deploymentWithConfiguration, "nil")
|
|
|
|
"Received: %s, %s. Expected: %s, %s.", d, err, &deployment, "nil")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if testRepository.Created[0] != template.Name {
|
|
|
|
if testRepository.Created[0] != template.Name {
|
|
|
|
t.Errorf("Repository CreateDeployment was called with %s but expected %s.",
|
|
|
|
t.Fatalf("Repository CreateDeployment was called with %s but expected %s.",
|
|
|
|
testRepository.Created[0], template.Name)
|
|
|
|
testRepository.Created[0], template.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !strings.HasPrefix(testRepository.ManifestAdd[template.Name].Name, "manifest-") {
|
|
|
|
if !strings.HasPrefix(testRepository.ManifestAdd[template.Name].Name, "manifest-") {
|
|
|
|
t.Errorf("Repository AddManifest was called with %s but expected manifest name"+
|
|
|
|
t.Fatalf("Repository AddManifest was called with %s but expected manifest name"+
|
|
|
|
"to begin with manifest-.", testRepository.ManifestAdd[template.Name].Name)
|
|
|
|
"to begin with manifest-.", testRepository.ManifestAdd[template.Name].Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(*testDeployer.Created[0], configuration) || err != nil {
|
|
|
|
if !reflect.DeepEqual(*testDeployer.Created[0], configuration) || err != nil {
|
|
|
|
t.Errorf("Deployer CreateConfiguration was called with %s but expected %s.",
|
|
|
|
t.Fatalf("Deployer CreateConfiguration was called with %s but expected %s.",
|
|
|
|
testDeployer.Created[0], configuration)
|
|
|
|
testDeployer.Created[0], configuration)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if testRepository.DeploymentStatuses[0] != DeployedStatus {
|
|
|
|
if testRepository.DeploymentStatuses[0] != DeployedStatus {
|
|
|
|
t.Error("CreateDeployment success did not mark deployment as deployed")
|
|
|
|
t.Fatal("CreateDeployment success did not mark deployment as deployed")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !testRepository.TypeInstancesCleared {
|
|
|
|
if !testRepository.TypeInstancesCleared {
|
|
|
|
t.Error("Repository did not clear type instances during creation")
|
|
|
|
t.Fatal("Repository did not clear type instances during creation")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(testRepository.TypeInstances, typeInstMap) {
|
|
|
|
if !reflect.DeepEqual(testRepository.TypeInstances, typeInstMap) {
|
|
|
|
t.Errorf("Unexpected type instances after CreateDeployment: %s", testRepository.TypeInstances)
|
|
|
|
t.Fatalf("Unexpected type instances after CreateDeployment: %s", testRepository.TypeInstances)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -340,26 +346,26 @@ func TestCreateDeploymentCreationFailure(t *testing.T) {
|
|
|
|
d, err := testManager.CreateDeployment(&template)
|
|
|
|
d, err := testManager.CreateDeployment(&template)
|
|
|
|
|
|
|
|
|
|
|
|
if testRepository.Created[0] != template.Name {
|
|
|
|
if testRepository.Created[0] != template.Name {
|
|
|
|
t.Errorf("Repository CreateDeployment was called with %s but expected %s.",
|
|
|
|
t.Fatalf("Repository CreateDeployment was called with %s but expected %s.",
|
|
|
|
testRepository.Created[0], template.Name)
|
|
|
|
testRepository.Created[0], template.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if len(testRepository.Deleted) != 0 {
|
|
|
|
if len(testRepository.Deleted) != 0 {
|
|
|
|
t.Errorf("DeleteDeployment was called with %s but not expected",
|
|
|
|
t.Fatalf("DeleteDeployment was called with %s but not expected",
|
|
|
|
testRepository.Created[0])
|
|
|
|
testRepository.Created[0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if testRepository.DeploymentStatuses[0] != FailedStatus {
|
|
|
|
if testRepository.DeploymentStatuses[0] != FailedStatus {
|
|
|
|
t.Error("CreateDeployment failure did not mark deployment as failed")
|
|
|
|
t.Fatal("CreateDeployment failure did not mark deployment as failed")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err != errTest || d != nil {
|
|
|
|
if err != errTest || d != nil {
|
|
|
|
t.Errorf("Expected a different set of response values from invoking CreateDeployment."+
|
|
|
|
t.Fatalf("Expected a different set of response values from invoking CreateDeployment."+
|
|
|
|
"Received: %s, %s. Expected: %s, %s.", d, err, "nil", errTest)
|
|
|
|
"Received: %s, %s. Expected: %s, %s.", d, err, "nil", errTest)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if testRepository.TypeInstancesCleared {
|
|
|
|
if testRepository.TypeInstancesCleared {
|
|
|
|
t.Error("Unexpected change to type instances during CreateDeployment failure.")
|
|
|
|
t.Fatal("Unexpected change to type instances during CreateDeployment failure.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -370,32 +376,31 @@ func TestCreateDeploymentCreationResourceFailure(t *testing.T) {
|
|
|
|
d, err := testManager.CreateDeployment(&template)
|
|
|
|
d, err := testManager.CreateDeployment(&template)
|
|
|
|
|
|
|
|
|
|
|
|
if testRepository.Created[0] != template.Name {
|
|
|
|
if testRepository.Created[0] != template.Name {
|
|
|
|
t.Errorf("Repository CreateDeployment was called with %s but expected %s.",
|
|
|
|
t.Fatalf("Repository CreateDeployment was called with %s but expected %s.",
|
|
|
|
testRepository.Created[0], template.Name)
|
|
|
|
testRepository.Created[0], template.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if len(testRepository.Deleted) != 0 {
|
|
|
|
if len(testRepository.Deleted) != 0 {
|
|
|
|
t.Errorf("DeleteDeployment was called with %s but not expected",
|
|
|
|
t.Fatalf("DeleteDeployment was called with %s but not expected",
|
|
|
|
testRepository.Created[0])
|
|
|
|
testRepository.Created[0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if testRepository.DeploymentStatuses[0] != FailedStatus {
|
|
|
|
if testRepository.DeploymentStatuses[0] != FailedStatus {
|
|
|
|
t.Error("CreateDeployment failure did not mark deployment as failed")
|
|
|
|
t.Fatal("CreateDeployment failure did not mark deployment as failed")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !strings.HasPrefix(testRepository.ManifestAdd[template.Name].Name, "manifest-") {
|
|
|
|
if !strings.HasPrefix(testRepository.ManifestAdd[template.Name].Name, "manifest-") {
|
|
|
|
t.Errorf("Repository AddManifest was called with %s but expected manifest name"+
|
|
|
|
t.Fatalf("Repository AddManifest was called with %s but expected manifest name"+
|
|
|
|
"to begin with manifest-.", testRepository.ManifestAdd[template.Name].Name)
|
|
|
|
"to begin with manifest-.", testRepository.ManifestAdd[template.Name].Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// if err != errTest || d != nil {
|
|
|
|
if err != nil || !reflect.DeepEqual(d, &deployment) {
|
|
|
|
if d == nil {
|
|
|
|
t.Fatalf("Expected a different set of response values from invoking CreateDeployment.\n"+
|
|
|
|
t.Errorf("Expected a different set of response values from invoking CreateDeployment."+
|
|
|
|
"Received: %v, %v. Expected: %v, %v.", d, err, &deployment, "nil")
|
|
|
|
"Received: %s, %s. Expected: %s, %s.", d, err, "nil", errTest)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !testRepository.TypeInstancesCleared {
|
|
|
|
if !testRepository.TypeInstancesCleared {
|
|
|
|
t.Error("Repository did not clear type instances during creation")
|
|
|
|
t.Fatal("Repository did not clear type instances during creation")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -403,71 +408,69 @@ func TestDeleteDeploymentForget(t *testing.T) {
|
|
|
|
testRepository.reset()
|
|
|
|
testRepository.reset()
|
|
|
|
testDeployer.reset()
|
|
|
|
testDeployer.reset()
|
|
|
|
d, err := testManager.CreateDeployment(&template)
|
|
|
|
d, err := testManager.CreateDeployment(&template)
|
|
|
|
if !reflect.DeepEqual(d, &deploymentWithConfiguration) || err != nil {
|
|
|
|
if !reflect.DeepEqual(d, &deployment) || err != nil {
|
|
|
|
t.Errorf("Expected a different set of response values from invoking CreateDeployment."+
|
|
|
|
t.Fatalf("Expected a different set of response values from invoking CreateDeployment."+
|
|
|
|
"Received: %s, %s. Expected: %s, %s.", d, err, &deploymentWithConfiguration, "nil")
|
|
|
|
"Received: %s, %s. Expected: %s, %s.", d, err, &deployment, "nil")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if testRepository.Created[0] != template.Name {
|
|
|
|
if testRepository.Created[0] != template.Name {
|
|
|
|
t.Errorf("Repository CreateDeployment was called with %s but expected %s.",
|
|
|
|
t.Fatalf("Repository CreateDeployment was called with %s but expected %s.",
|
|
|
|
testRepository.Created[0], template.Name)
|
|
|
|
testRepository.Created[0], template.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !strings.HasPrefix(testRepository.ManifestAdd[template.Name].Name, "manifest-") {
|
|
|
|
if !strings.HasPrefix(testRepository.ManifestAdd[template.Name].Name, "manifest-") {
|
|
|
|
t.Errorf("Repository AddManifest was called with %s but expected manifest name"+
|
|
|
|
t.Fatalf("Repository AddManifest was called with %s but expected manifest name"+
|
|
|
|
"to begin with manifest-.", testRepository.ManifestAdd[template.Name].Name)
|
|
|
|
"to begin with manifest-.", testRepository.ManifestAdd[template.Name].Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(*testDeployer.Created[0], configuration) || err != nil {
|
|
|
|
if !reflect.DeepEqual(*testDeployer.Created[0], configuration) || err != nil {
|
|
|
|
t.Errorf("Deployer CreateConfiguration was called with %s but expected %s.",
|
|
|
|
t.Fatalf("Deployer CreateConfiguration was called with %s but expected %s.",
|
|
|
|
testDeployer.Created[0], configuration)
|
|
|
|
testDeployer.Created[0], configuration)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
oldManifestName := testRepository.ManifestAdd[template.Name].Name
|
|
|
|
d, err = testManager.DeleteDeployment(deploymentName, true)
|
|
|
|
d, err = testManager.DeleteDeployment("test", true)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("DeleteDeployment failed with %v", err)
|
|
|
|
t.Fatalf("DeleteDeployment failed with %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if testRepository.ManifestAdd[template.Name].Name == oldManifestName {
|
|
|
|
|
|
|
|
t.Errorf("New manifest was not created, is still: %s", oldManifestName)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if testRepository.ManifestAdd[template.Name].InputConfig != nil {
|
|
|
|
|
|
|
|
t.Errorf("New manifest has non-nil config, is still: %v", testRepository.ManifestAdd[template.Name].InputConfig)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Make sure the resources were deleted through deployer.
|
|
|
|
// Make sure the resources were deleted through deployer.
|
|
|
|
if !reflect.DeepEqual(*testDeployer.Deleted[0], configuration) || err != nil {
|
|
|
|
if len(testDeployer.Deleted) > 0 {
|
|
|
|
t.Errorf("Deployer DeleteConfiguration was called with %s but expected %s.",
|
|
|
|
c := testDeployer.Deleted[0]
|
|
|
|
testDeployer.Created[0], configuration)
|
|
|
|
if c != nil {
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(*c, configuration) || err != nil {
|
|
|
|
|
|
|
|
t.Fatalf("Deployer DeleteConfiguration was called with %s but expected %s.",
|
|
|
|
|
|
|
|
testDeployer.Created[0], configuration)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !testRepository.TypeInstancesCleared {
|
|
|
|
if !testRepository.TypeInstancesCleared {
|
|
|
|
t.Error("Expected type instances to be cleared during DeleteDeployment.")
|
|
|
|
t.Fatal("Expected type instances to be cleared during DeleteDeployment.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestExpand(t *testing.T) {
|
|
|
|
func TestExpand(t *testing.T) {
|
|
|
|
m, err := testManager.Expand(&template)
|
|
|
|
m, err := testManager.Expand(&template)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Error("Failed to expand template into manifest.")
|
|
|
|
t.Fatal("Failed to expand template into manifest.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if m.Name != "" {
|
|
|
|
if m.Name != "" {
|
|
|
|
t.Errorf("Name was not empty: %v", *m)
|
|
|
|
t.Fatalf("Name was not empty: %v", *m)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if m.Deployment != "" {
|
|
|
|
if m.Deployment != "" {
|
|
|
|
t.Errorf("Deployment was not empty: %v", *m)
|
|
|
|
t.Fatalf("Deployment was not empty: %v", *m)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if m.InputConfig != nil {
|
|
|
|
if m.InputConfig != nil {
|
|
|
|
t.Errorf("Input config not nil: %v", *m)
|
|
|
|
t.Fatalf("Input config not nil: %v", *m)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(*m.ExpandedConfig, configuration) {
|
|
|
|
if !reflect.DeepEqual(*m.ExpandedConfig, configuration) {
|
|
|
|
t.Errorf("Expanded config not correct in output manifest: %v", *m)
|
|
|
|
t.Fatalf("Expanded config not correct in output manifest: %v", *m)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(*m.Layout, layout) {
|
|
|
|
if !reflect.DeepEqual(*m.Layout, layout) {
|
|
|
|
t.Errorf("Layout not correct in output manifest: %v", *m)
|
|
|
|
t.Fatalf("Layout not correct in output manifest: %v", *m)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -477,7 +480,7 @@ func TestListTypes(t *testing.T) {
|
|
|
|
testManager.ListTypes()
|
|
|
|
testManager.ListTypes()
|
|
|
|
|
|
|
|
|
|
|
|
if !testRepository.ListTypesCalled {
|
|
|
|
if !testRepository.ListTypesCalled {
|
|
|
|
t.Error("expected repository ListTypes() call.")
|
|
|
|
t.Fatal("expected repository ListTypes() call.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -487,6 +490,6 @@ func TestListInstances(t *testing.T) {
|
|
|
|
testManager.ListInstances("all")
|
|
|
|
testManager.ListInstances("all")
|
|
|
|
|
|
|
|
|
|
|
|
if !testRepository.GetTypeInstancesCalled {
|
|
|
|
if !testRepository.GetTypeInstancesCalled {
|
|
|
|
t.Error("expected repository GetTypeInstances() call.")
|
|
|
|
t.Fatal("expected repository GetTypeInstances() call.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|