Ejemplo n.º 1
0
// TODO Make this work.
func testGitHubStatusesRepository(t *testing.T) {
	repo := "ejholmes/docker-statsd"

	g := github.NewClient(nil)
	r := &GitHubStatusesRepository{RepositoriesService: g.Repositories}

	s := &Status{Repo: repo, Ref: "6607c19", State: "pending", Context: "test"}

	if err := r.Create(s); err != nil {
		t.Fatal(err)
	}
}
Ejemplo n.º 2
0
// New returns a new Quayd instance backed by GitHub implementations.
func New(token, registryAuth string) *Quayd {
	t := &oauth.Transport{
		Token: &oauth.Token{AccessToken: token},
	}

	gh := github.NewClient(t.Client())
	auth := strings.Split(registryAuth, ":")
	return &Quayd{
		StatusesRepository: &GitHubStatusesRepository{gh.Repositories},
		CommitResolver:     &GitHubCommitResolver{gh.Repositories},
		TagResolver:        &DockerRegistryTagResolver{registry: "quay.io"},
		Tagger: &DockerRegistryTagger{registry: "quay.io",
			username: auth[0],
			password: auth[1]},
	}
}
Ejemplo n.º 3
0
// TODO Don't make network requests.
func TestGitHubCommitResolver(t *testing.T) {
	repo := "ejholmes/docker-statsd"

	tests := []struct {
		in  string
		out string
	}{
		{"6607c19", "6607c19d3fd492ec53439f4104b39e4c62ece179"},
	}

	for _, tt := range tests {
		g := github.NewClient(nil)
		r := &GitHubCommitResolver{RepositoriesService: g.Repositories}

		sha, err := r.Resolve(repo, tt.in)
		if err != nil {
			t.Fatal(err)
		}

		if got, want := sha, tt.out; got != want {
			t.Fatalf("Sha => %s; want %s", got, want)
		}
	}
}