Ejemplo n.º 1
0
func TestBintrayFileDownloads(t *testing.T) {
	initBintrayTest(t)

	repositoryPath := bintrayConfig.User + "/" + tests.BintrayRepo1
	packagePath := repositoryPath + "/" + tests.BintrayUploadTestPackageName
	versionPath := packagePath + "/" + tests.BintrayUploadTestVersion
	createPackageAndVersion(packagePath, versionPath)
	bintrayCli.Exec("upload", tests.GetTestResourcesPath()+"a/*", versionPath, "--flat=true --recursive=true")
	bintrayCli.Exec("upload", tests.GetTestResourcesPath()+"a/a1.in", versionPath, "--flat=false")

	bintrayCli.Exec("download-file", repositoryPath+"/a1.in", tests.Out+"/bintray/", "--unpublished=true")
	bintrayCli.Exec("download-file", repositoryPath+"/b1.in", tests.Out+"/bintray/x.in", "--unpublished=true")
	bintrayCli.Exec("download-file", repositoryPath+"/(c)1.in", tests.Out+"/bintray/z{1}.in", "--unpublished=true")
	bintrayCli.Exec("download-file", repositoryPath+"/"+tests.GetTestResourcesPath()[1:]+"(a)/a1.in", tests.Out+"/bintray/{1}/fullpatha1.in", "--flat=true --unpublished=true")

	paths, _ := ioutils.ListFilesRecursive(tests.Out + "/bintray/")
	expected := []string{
		tests.Out + ioutils.GetFileSeperator() + "bintray" + ioutils.GetFileSeperator() + "a1.in",
		tests.Out + ioutils.GetFileSeperator() + "bintray" + ioutils.GetFileSeperator() + "x.in",
		tests.Out + ioutils.GetFileSeperator() + "bintray" + ioutils.GetFileSeperator() + "zc.in",
		tests.Out + ioutils.GetFileSeperator() + "bintray" + ioutils.GetFileSeperator() + "a" + ioutils.GetFileSeperator() + "fullpatha1.in",
	}
	tests.IsExistLocally(expected, paths, t)
	bintrayCli.Exec("package-delete", packagePath, "--quiet=true")
	cleanBintrayTest()
}
Ejemplo n.º 2
0
func TestBintrayUploadOverride(t *testing.T) {
	initBintrayTest(t)

	packagePath := bintrayConfig.User + "/" + tests.BintrayRepo1 + "/" + tests.BintrayUploadTestPackageName
	versionPath := packagePath + "/" + tests.BintrayUploadTestVersion
	createPackageAndVersion(packagePath, versionPath)

	bintrayCli.Exec("upload", tests.GetTestResourcesPath()+"a/*", versionPath, "--flat=true --recursive=false --publish=true")
	assertPackageFiles(tests.BintrayExpectedUploadFlatNonRecursive, getPackageFiles(tests.BintrayUploadTestPackageName), t)
	bintrayCli.Exec("upload", tests.GetTestResourcesPath()+"a/b/b1.in", versionPath, "a1.in", "--flat=true --recursive=false --override=true")
	assertPackageFiles(tests.BintrayExpectedUploadFlatNonRecursiveModified, getPackageFiles(tests.BintrayUploadTestPackageName), t)

	bintrayCli.Exec("package-delete", packagePath, "--quiet=true")
	cleanBintrayTest()
}
Ejemplo n.º 3
0
func TestBintrayUploadNoVersion(t *testing.T) {
	initBintrayTest(t)

	packageName := "simpleUploadPackage"
	packagePath := bintrayConfig.User + "/" + tests.BintrayRepo1 + "/" + packageName
	versionName := "1.0"
	versionPath := packagePath + "/" + versionName
	bintrayCli.Exec("package-create", packagePath, "--licenses=Apache-2.0 --vcs-url=vcs.url.com")

	//Upload file
	fileName := "a1.in"
	uploadFilePath := tests.GetTestResourcesPath() + "a/" + fileName
	bintrayCli.Exec("upload", uploadFilePath, versionPath)

	//Check file uploaded
	expected := []tests.PackageSearchResultItem{{
		Repo:    tests.BintrayRepo1,
		Path:    fileName,
		Package: packageName,
		Name:    fileName,
		Version: "1.0",
		Sha1:    "507ac63c6b0f650fb6f36b5621e70ebca3b0965c"}}
	assertPackageFiles(expected, getPackageFiles(packageName), t)

	bintrayCli.Exec("package-delete", packagePath, "--quiet=true")
	cleanBintrayTest()
}
Ejemplo n.º 4
0
func testBintrayUpload(t *testing.T, relPath, flags string, expected []tests.PackageSearchResultItem) {
	packagePath := bintrayConfig.User + "/" + tests.BintrayRepo1 + "/" + tests.BintrayUploadTestPackageName
	versionPath := packagePath + "/" + tests.BintrayUploadTestVersion
	createPackageAndVersion(packagePath, versionPath)

	bintrayCli.Exec("upload", tests.GetTestResourcesPath()+relPath, versionPath, flags)
	assertPackageFiles(expected, getPackageFiles(tests.BintrayUploadTestPackageName), t)
	bintrayCli.Exec("package-delete", packagePath, "--quiet=true")
}
Ejemplo n.º 5
0
func createReposIfNeeded() error {
	var err error
	var repoConfig string
	if !isRepoExist(tests.Repo1) {
		repoConfig = tests.GetTestResourcesPath() + tests.SpecsTestRepositoryConfig
		err = execCreateRepoRest(repoConfig, tests.Repo1)
		if err != nil {
			return err
		}
	}

	if !isRepoExist(tests.Repo2) {
		repoConfig = tests.GetTestResourcesPath() + tests.MoveRepositoryConfig
		err = execCreateRepoRest(repoConfig, tests.Repo2)
		if err != nil {
			return err
		}
	}
	return nil
}
Ejemplo n.º 6
0
func createBintrayRepo() {
	content, err := ioutil.ReadFile(tests.GetTestResourcesPath() + tests.BintrayTestRepositoryConfig)
	if cliutils.CheckError(err) != nil {
		os.Exit(1)
	}

	apiUrl := bintrayConfig.ApiUrl + path.Join("repos", bintrayConfig.User, tests.BintrayRepo1)
	clientDetails := ioutils.HttpClientDetails{
		User:     bintrayConfig.User,
		Password: bintrayConfig.Key,
		Headers:  map[string]string{"Content-Type": "application/json"}}

	resp, body, err := ioutils.SendPost(apiUrl, content, clientDetails)
	if cliutils.CheckError(err) != nil {
		os.Exit(1)
	}

	if resp.StatusCode != 200 && resp.StatusCode != 201 && resp.StatusCode != 409 {
		log.Error(resp.Status)
		log.Error(string(body))
		os.Exit(1)
	}
}
Ejemplo n.º 7
0
func prepUploadFiles() {
	uploadPath := tests.FixWinPath(tests.GetTestResourcesPath()) + "(.*)"
	targetPath := tests.Repo1 + "/downloadTestResources/{1}"
	flags := "--threads=10 --regexp=true --props=searchMe=true --flat=false"
	artifactoryCli.Exec("upload", uploadPath, targetPath, flags)
}