Ejemplo n.º 1
0
func newManager(c *router.Context) manager.Manager {
	cfg := c.Config
	service := repo.NewInmemRepoService()
	cp := c.CredentialProvider
	rp := repo.NewRepoProvider(service, repo.NewGCSRepoProvider(cp), cp)
	expander := manager.NewExpander(cfg.ExpanderPort, cfg.ExpanderURL, rp)
	deployer := manager.NewDeployer(util.GetServiceURLOrDie(cfg.DeployerName, cfg.DeployerPort, cfg.DeployerURL))
	address := strings.TrimPrefix(util.GetServiceURLOrDie(cfg.MongoName, cfg.MongoPort, cfg.MongoAddress), "http://")
	repository := createRepository(address)
	return manager.NewManager(expander, deployer, repository, rp, service, c.CredentialProvider)
}
Ejemplo n.º 2
0
			d := instance.Deployment
			repository.ChartInstances[d] = append(repository.ChartInstances[d], t)
		}
	}

	return nil
}

func (repository *repositoryStub) Close() {}

var testExpander = &expanderStub{}
var testRepository = newRepositoryStub()
var testDeployer = newDeployerStub()
var testRepoService = repo.NewInmemRepoService()
var testCredentialProvider = repo.NewInmemCredentialProvider()
var testProvider = repo.NewRepoProvider(nil, repo.NewGCSRepoProvider(testCredentialProvider), testCredentialProvider)
var testManager = NewManager(testExpander, testDeployer, testRepository, testProvider, testRepoService, testCredentialProvider)

func TestListDeployments(t *testing.T) {
	testRepository.reset()
	d, err := testManager.ListDeployments()
	if err != nil {
		t.Fatalf(err.Error())
	}

	if !reflect.DeepEqual(d, deploymentList) {
		t.Fatalf("invalid deployment list")
	}
}

func TestListDeploymentsFail(t *testing.T) {