Skip to content

Commit

Permalink
feat(arquillian#145): rework hint to status message that can be updat…
Browse files Browse the repository at this point in the history
…ed when

status is changed
  • Loading branch information
MatousJobanek committed Jun 21, 2018
1 parent e3dacbe commit 2d2e342
Show file tree
Hide file tree
Showing 32 changed files with 723 additions and 769 deletions.
Binary file removed docs/images/arquillian_ui_failure_128px.png
Binary file not shown.
Binary file added docs/images/arquillian_ui_failure_64px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/arquillian_ui_success_64px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 23 additions & 27 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions pkg/assets/config/message-with-hint-file-not-found.txt

This file was deleted.

1 change: 0 additions & 1 deletion pkg/config/config_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type Source func() ([]byte, error)
type PluginConfiguration struct {
PluginName string
LocationURL string
PluginHint string `yaml:"plugin_hint,omitempty"`
}

// Load loads configuration of the plugin based on strategies defined by SourcesProvider
Expand Down
12 changes: 6 additions & 6 deletions pkg/config/config_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ var onlyName = config.Source(func() ([]byte, error) {
return []byte("name: 'awesome-o'"), nil
})

var nameAndHint = config.Source(func() ([]byte, error) {
return []byte("name: 'name-and-hint'\n" +
"plugin_hint: 'I am just a hint'"), nil
var nameAndSkip = config.Source(func() ([]byte, error) {
return []byte("name: 'name-and-skip'\n" +
"skip_validation_for: ['anything']"), nil
})

var faulty = config.Source(func() ([]byte, error) {
Expand Down Expand Up @@ -93,7 +93,7 @@ var _ = Describe("Config loader features", func() {
It("should load config from first working source (precedence)", func() {
// given
testConfigProviders := testConfigProvider(func() []config.Source {
return []config.Source{nameAndHint, onlyName}
return []config.Source{nameAndSkip, onlyName}
})

sampleConfig := sampleConfiguration{Name: "prototype"}
Expand All @@ -103,8 +103,8 @@ var _ = Describe("Config loader features", func() {

// then
Ω(err).ShouldNot(HaveOccurred())
Expect(sampleConfig.Name).To(Equal("name-and-hint"))
Expect(sampleConfig.PluginHint).To(Equal("I am just a hint"))
Expect(sampleConfig.Name).To(Equal("name-and-skip"))
Expect(sampleConfig.Skip).To(ConsistOf("anything"))
})

It("should preserve prototype config name when no sources provided", func() {
Expand Down
14 changes: 14 additions & 0 deletions pkg/github/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Client interface {
GetPullRequestReviews(owner, repo string, prNumber int) ([]*gogh.PullRequestReview, error)
ListIssueComments(issue scm.RepositoryIssue) ([]*gogh.IssueComment, error)
CreateIssueComment(issue scm.RepositoryIssue, commentMsg *string) error
EditIssueComment(issue scm.RepositoryIssue, commentID int64, commentMsg *string) error
CreateStatus(change scm.RepositoryChange, repoStatus *gogh.RepoStatus) error
AddPullRequestLabel(change scm.RepositoryChange, prNumber int, label []string) error
RemovePullRequestLabel(change scm.RepositoryChange, prNumber int, label string) error
Expand Down Expand Up @@ -160,6 +161,19 @@ func (c *client) CreateIssueComment(issue scm.RepositoryIssue, commentMsg *strin
return err
}

// EditIssueComment edits an already existing comment in the given issue.
func (c *client) EditIssueComment(issue scm.RepositoryIssue, commentID int64, commentMsg *string) error {
comment := &gogh.IssueComment{
Body: commentMsg,
}
err := c.do(func(aroundContext aroundContext) (func(), *gogh.Response, error) {
_, response, e := c.gh.Issues.EditComment(context.Background(), issue.Owner, issue.RepoName, commentID, comment)
return func() {}, response, c.checkHTTPCode(response, e)
})

return err
}

// CreateStatus creates a new status for a repository at the specified reference represented by a RepositoryChange
func (c *client) CreateStatus(change scm.RepositoryChange, repoStatus *gogh.RepoStatus) error {
err := c.do(func(aroundContext aroundContext) (func(), *gogh.Response, error) {
Expand Down
15 changes: 10 additions & 5 deletions pkg/github/service/comment_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (

// CommentService is a struct managing issue or pull request comments
type CommentService struct {
client ghclient.Client
issue scm.RepositoryIssue
Client ghclient.Client
Issue scm.RepositoryIssue
}

// NewCommentService creates an instance of GitHub CommentService with information retrieved from the given IssueCommentEvents
func NewCommentService(client ghclient.Client, comment *gogh.IssueCommentEvent) *CommentService {
return &CommentService{
client: client,
issue: scm.RepositoryIssue{
Client: client,
Issue: scm.RepositoryIssue{
Owner: *comment.Repo.Owner.Login,
RepoName: *comment.Repo.Name,
Number: *comment.Issue.Number,
Expand All @@ -26,5 +26,10 @@ func NewCommentService(client ghclient.Client, comment *gogh.IssueCommentEvent)

// AddComment adds a comment message to the issue
func (s *CommentService) AddComment(commentMsg *string) error {
return s.client.CreateIssueComment(s.issue, commentMsg)
return s.Client.CreateIssueComment(s.Issue, commentMsg)
}

// EditComment edits an already existing comment message
func (s *CommentService) EditComment(commentID int64, commentMsg *string) error {
return s.Client.EditIssueComment(s.Issue, commentID, commentMsg)
}
78 changes: 0 additions & 78 deletions pkg/github/service/hinter_service.go

This file was deleted.

Loading

0 comments on commit 2d2e342

Please sign in to comment.