func TestShortGithubUrl(t *testing.T) { finalImports := []*common.ImportFile{ &common.ImportFile{ Name: "github.com/kubernetes/application-dm-templates/common/replicatedservice:v1", Path: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Content: "my-content"}, &common.ImportFile{ Name: "github.com/kubernetes/application-dm-templates/common/replicatedservice:v2", Path: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Content: "my-content-2"}, } responses := map[string]responseAndError{ "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py": responseAndError{nil, http.StatusOK, "my-content"}, "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py.schema": responseAndError{nil, http.StatusNotFound, ""}, "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py": responseAndError{nil, http.StatusOK, "my-content-2"}, "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py.schema": responseAndError{nil, http.StatusNotFound, ""}, } githubUrlMaps := map[registry.Type]registry.TestURLAndError{ registry.NewTypeOrDie("common", "replicatedservice", "v1"): registry.TestURLAndError{"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", nil}, registry.NewTypeOrDie("common", "replicatedservice", "v2"): registry.TestURLAndError{"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", nil}, } grp := registry.NewTestGithubRegistryProvider("github.com/kubernetes/application-dm-templates", githubUrlMaps) test := resolverTestCase{ config: templateShortGithubTemplate, importOut: finalImports, urlcount: 4, responses: responses, registryProvider: registry.NewRegistryProvider(nil, grp, registry.NewInmemCredentialProvider()), } testDriver(test, t) }
d := instance.Deployment repository.TypeInstances[d] = append(repository.TypeInstances[d], t) } } return nil } func (repository *repositoryStub) Close() {} var testExpander = &expanderStub{} var testRepository = newRepositoryStub() var testDeployer = newDeployerStub() var testRegistryService = registry.NewInmemRegistryService() var testCredentialProvider = registry.NewInmemCredentialProvider() var testProvider = registry.NewRegistryProvider(nil, registry.NewTestGithubRegistryProvider("", nil), registry.NewTestGCSRegistryProvider("", nil), testCredentialProvider) var testManager = NewManager(testExpander, testDeployer, testRepository, testProvider, testRegistryService, 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) {