Beispiel #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)
}
Beispiel #2
0
func getTestRepoProvider(t *testing.T) repo.IRepoProvider {
	rs := repo.NewInmemRepoService()
	rp := repo.NewRepoProvider(rs, nil, nil)
	tr, err := repo.NewRepo(TestRepoURL, TestRepoCredentialName, TestRepoName, TestRepoFormat, TestRepoType)
	if err != nil {
		t.Fatalf("cannot create test repository: %s", err)
	}

	if err := rs.CreateRepo(tr); err != nil {
		t.Fatalf("cannot initialize repository service: %s", err)
	}

	return rp
}
Beispiel #3
0
	for t, instances := range is {
		for _, instance := range instances {
			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")
	}
}