Esempio n. 1
0
func TestShowAndCreateEntitlements(t *testing.T) {
	repo, _ := CreateVersionDetails("my-subject/my-repo")
	pkg, _ := CreateVersionDetails("my-subject/my-repo/my-pkg")
	version, _ := CreateVersionDetails("my-subject/my-repo/my-pkg/ver-1.9.1")

	bintrayDetails := tests.CreateBintrayDetails()

	url := BuildEntitlementsUrl(bintrayDetails, repo)
	expected := "https://api.bintray.com/repos/my-subject/my-repo/entitlements"
	if expected != url {
		t.Error("Got unexpected url from BuildEntitlementsUrl. Expected: " + expected + " Got " + url)
	}

	url = BuildEntitlementsUrl(bintrayDetails, pkg)
	expected = "https://api.bintray.com/packages/my-subject/my-repo/my-pkg/entitlements"
	if expected != url {
		t.Error("Got unexpected url from BuildEntitlementsUrl. Expected: " + expected + " Got " + url)
	}

	url = BuildEntitlementsUrl(bintrayDetails, version)
	expected = "https://api.bintray.com/packages/my-subject/my-repo/my-pkg/versions/ver-1.9.1/entitlements"
	if expected != url {
		t.Error("Got unexpected url from BuildEntitlementsUrl. Expected: " + expected + " Got " + url)
	}
}
func TestDownloadVersion(t *testing.T) {
	versionDetails, err := utils.CreateVersionDetails("test-subject/test-repo/test-package/ver-1.2")
	if err != nil {
		t.Error(err.Error())
	}
	url := BuildDownloadVersionUrl(versionDetails, tests.CreateBintrayDetails(), false)
	expected := "https://api.bintray.com/packages/test-subject/test-repo/test-package/versions/ver-1.2/files"
	if expected != url {
		t.Error("Got unexpected url from BuildDownloadVersionUrl. Expected: " + expected + " Got " + url)
	}
}
Esempio n. 3
0
func TestConfig(t *testing.T) {
	expected := tests.CreateBintrayDetails()
	Config(expected, nil, false)
	details, err := GetConfig()
	if err != nil {
		t.Error(err.Error())
	}
	if configStructToString(expected) != configStructToString(details) {
		t.Error("Unexpected configuration was saved to file. Expected: " + configStructToString(expected) + " Got " + configStructToString(details))
	}
}
Esempio n. 4
0
func createUploadFlags() *UploadFlags {
	return &UploadFlags{
		BintrayDetails: tests.CreateBintrayDetails(),
		Recursive:      true,
		Flat:           true,
		Publish:        false,
		Override:       false,
		Explode:        false,
		UseRegExp:      false,
		Threads:        3,
		Deb:            "",
		DryRun:         true}
}