Ejemplo n.º 1
0
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"},
	}

	downloadResponses := map[string]registry.DownloadResponse{
		"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py":        registry.DownloadResponse{Err: nil, Code: http.StatusOK, Body: "my-content"},
		"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py.schema": registry.DownloadResponse{Err: nil, Code: http.StatusNotFound, Body: ""},
		"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py":        registry.DownloadResponse{Err: nil, Code: http.StatusOK, Body: "my-content-2"},
		"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py.schema": registry.DownloadResponse{Err: nil, Code: http.StatusNotFound, Body: ""},
	}

	githubURLMaps := map[registry.Type]registry.TestURLAndError{
		registry.NewTypeOrDie("common", "replicatedservice", "v1"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Err: nil},
		registry.NewTypeOrDie("common", "replicatedservice", "v2"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Err: nil},
	}

	gcsURLMaps := map[registry.Type]registry.TestURLAndError{
		registry.NewTypeOrDie("common", "replicatedservice", "v1"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Err: nil},
		registry.NewTypeOrDie("common", "replicatedservice", "v2"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Err: nil},
	}

	grp := registry.NewTestGithubRegistryProviderWithDownloads("github.com/kubernetes/application-dm-templates", githubURLMaps, downloadResponses)
	gcsrp := registry.NewTestGCSRegistryProvider("gs://charts", gcsURLMaps)
	test := resolverTestCase{
		config:           templateShortGithubTemplate,
		importOut:        finalImports,
		urlcount:         0,
		responses:        map[string]responseAndError{},
		registryProvider: registry.NewRegistryProvider(nil, grp, gcsrp, registry.NewInmemCredentialProvider()),
	}

	testDriver(test, t)
}
Ejemplo n.º 2
0
			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) {