Exemple #1
0
func (a *ABF) makeBuildList(list map[string]interface{}) (*models.List, error) {
	pkg := a.makePkgList(list)

	changelog := ""

	var logs []interface{}
	dig.Get(&list, &logs, "logs")

	for _, v := range logs {
		asserted := v.(map[string]interface{})
		if dig.String(&asserted, "file_name") == "changelog.log" {
			changelog = dig.String(&asserted, "url")
			break
		}
	}

	handleID := to.String(dig.Uint64(&list, "id"))
	handleProject := dig.String(&list, "project", "fullname")
	platform := dig.String(&list, "save_to_repository", "platform", "name")

	bl := models.List{
		Name:     dig.String(&list, "project", "name"),
		Platform: platform,
		Channel:  dig.String(&list, "save_to_repository", "name"),
		Variants: dig.String(&list, "arch", "name"),

		Artifacts: pkg,
		Links: []models.ListLink{
			{
				Name: models.LinkMain,
				URL:  fmt.Sprintf("%s/build_lists/%v", abfURL, handleID),
			},
			{
				Name: models.LinkChangelog,
				URL:  changelog,
			},
			{
				Name: models.LinkSCM,
				URL:  fmt.Sprintf("%s/%v/commits/%v", abfURL, handleProject, platform),
			},
		},
		Changes:   changelog,
		BuildDate: time.Unix(dig.Int64(&list, "updated_at"), 0),

		StageCurrent: models.ListStageNotStarted,
		StageResult:  models.ListRunning,
		Activity: []models.ListActivity{
			{
				UserID:   models.FindUser(models.UserSystem).ID,
				Activity: "Imported this build list from ABF.",
			},
		},

		IntegrationName: "abf",
		IntegrationOne:  "[" + handleID + "]",
		IntegrationTwo:  dig.String(&list, "commit_hash"),
	}

	return &bl, nil
}
Exemple #2
0
func (a *ABF) makePkgList(json map[string]interface{}) []models.ListArtifact {
	var pkgs []interface{}
	dig.Get(&json, &pkgs, "packages")

	var pkg []models.ListArtifact

	pkgrep := func(m map[string]interface{}) models.ListArtifact {
		pkgType := dig.String(&m, "type")
		if strings.HasSuffix(dig.String(&m, "name"), "-debuginfo") {
			pkgType = "debuginfo"
		}

		return models.ListArtifact{
			Name:    dig.String(&m, "name"),
			Type:    pkgType,
			Epoch:   dig.Int64(&m, "epoch"),
			Version: dig.String(&m, "version"),
			Release: dig.String(&m, "release"),
			Variant: dig.String(&json, "arch", "name"),
			URL:     dig.String(&m, "url"),
		}
	}

	for _, v := range pkgs {
		asserted := v.(map[string]interface{})
		pkg = append(pkg, pkgrep(asserted))
	}

	return pkg
}
Exemple #3
0
func TestApi(t *testing.T) {

	var err error

	client := New(&oauth.Credentials{
		to.String(conf.Get("twitter", "app", "key")),
		to.String(conf.Get("twitter", "app", "secret")),
	})

	client.SetAuth(&oauth.Credentials{
		to.String(conf.Get("twitter", "user", "token")),
		to.String(conf.Get("twitter", "user", "secret")),
	})

	_, err = client.VerifyCredentials(nil)

	if err != nil {
		t.Errorf("Test failed: %s\n", err.Error())
	}

	_, err = client.HomeTimeline(nil)

	if err != nil {
		t.Errorf("Test failed: %s\n", err.Error())
	}

	_, err = client.MentionsTimeline(nil)

	if err != nil {
		t.Errorf("Test failed: %s\n", err.Error())
	}

	_, err = client.UserTimeline(nil)

	if err != nil {
		t.Errorf("Test failed: %s\n", err.Error())
	}

	_, err = client.RetweetsOfMe(nil)

	if err != nil {
		t.Errorf("Test failed: %s\n", err.Error())
	}

	_, err = client.Retweets(int64(21947795900469248), nil)

	if err != nil {
		t.Errorf("Test failed: %s\n", err.Error())
	}

	var status *map[string]interface{}
	status, err = client.Update(fmt.Sprintf("Test message @ %s", time.Now()), nil)

	if err != nil {
		t.Errorf("Test failed: %s\n", err.Error())
	}

	tweetId := dig.Int64(status, "id_str")

	_, err = client.Destroy(tweetId, nil)

	if err != nil {
		t.Errorf("Test failed: %s\n", err.Error())
	}

	tweetId = dig.Int64(status, "id_str")

	files := []string{
		"_resources/test.jpg",
	}

	_, err = client.UpdateWithMedia("Hello", nil, files)

	if err != nil {
		t.Errorf("Test failed: %s\n", err.Error())
	}

	_, err = client.Retweet(int64(21947795900469248), nil)

	if err != nil {
		t.Errorf("Test failed: %s\n", err.Error())
	}

}