-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jira: general client improvements #26564
jira: general client improvements #26564
Conversation
This PR fixes the fakejira `CloneIssue` and `CreateIssue` functions along with adding unit tests for them, adds more extensive issue function errors for the fakeclient, and modifies the `DeleteRemoteLinkViaURL` function to return a `bool` indicating whether a link with the provided URL was found and removed (no remote link with the provided URL is not an error). These improvements will be used in a new openshift external prow plugin called the `jira-lifecycle` plugin, which will replicate the `bugzilla` plugins functionality, but with the Jira service instead of bugzilla.
6e96f94
to
4534311
Compare
f.updateIssueIDAndKey(issueCopy) | ||
// run generic cloning function | ||
return jiraclient.CloneIssue(f, issueCopy) | ||
return jiraclient.CloneIssue(f, issue) | ||
} | ||
|
||
func (f *FakeClient) CreateIssue(issue *jira.Issue) (*jira.Issue, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What, exactly, is this helping? Having to build a fake Jira sounds like testing is happening at the wrong level. See also: how this repo has not built a fake GitHub, Bugzilla, S3, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by this repo not building a fake github or bugzilla? There is a fakegithub and a fake bugzilla client that are used heavily by unit testing in plugins. This fake jira client isn't much different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are simple in-memory maps that we add to / delete from using the methods. They do not encode provider-specific implementation details like ("issue.fields.project must be set to create new issue")
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
prow/jira/fakejira/fake_test.go
Outdated
ptrIssues = append(ptrIssues, &tc.existingIssues[index]) | ||
} | ||
fakeClient := &FakeClient{Issues: ptrIssues} | ||
newIssue, err := fakeClient.CreateIssue(&tc.issue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are unit tests for a fake ... ? This doesn't seem right - in the fake you might inject data, or validate that calls happen to the right endpoints. There's nothing making sure that the fake implementation of the clone here is the same as what Jira actually does, so ensuring it is "correct" here is not helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CreateIssue
function was very poorly implemented before to the point that it was basically useless (that was my fault as I wrote it). I just wanted to make sure it was generally close enough when fixing the implementation. For the CloneIssue
function, we just call a generic function that is shared by the fake and real clients so this tests that, but makes it does make calls to CreateIssueLink
and CreateIssue
of the client provided (in this case fake client), so you could say it's not a truly accurate test.
If you would rather not have unit tests for the fake client, I could remove these tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the unit tests.
7878953
to
7d42023
Compare
This commit removes the unit tests for the fake client and simplifies the `CreateIssue` function by removing checks for unsettable fields.
7d42023
to
0587179
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AlexNPavel, stevekuznetsov The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This PR fixes the fakejira
CloneIssue
andCreateIssue
functionsalong with adding unit tests for them, adds more extensive issue
function errors for the fakeclient, and modifies the
DeleteRemoteLinkViaURL
function to return abool
indicating whethera link with the provided URL was found and removed (no remote link with
the provided URL is not an error).
These improvements will be used in a new openshift external prow plugin
called the
jira-lifecycle
plugin, which will replicate thebugzilla
plugins functionality, but with the Jira service instead of bugzilla.
/cc @stevekuznetsov @alvaroaleman