Skip to content

Commit

Permalink
Made BitbucketClout.User accountId and nickname optional
Browse files Browse the repository at this point in the history
  • Loading branch information
abel3cl committed Oct 23, 2020
1 parent 4c22a51 commit 6a05d5c
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/Danger/BitBucketCloud.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ extension BitBucketCloud {
}

/// The acount id of the user
public let accountId: String
public let accountId: String?

/// The display name of user
public let displayName: String

/// The nick name of the user
public let nickname: String
public let nickname: String?

/// The uuid of the user
public let uuid: String
Expand Down
12 changes: 12 additions & 0 deletions Tests/DangerTests/BitBucketCloudTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ final class BitBucketCloudTests: XCTestCase {
}
}

func testCommentUserWithoutAccountId() {
do {
let comment = try JSONDecoder().decode(BitBucketCloud.Comment.self, from: Data(BitBucketCloudCommentUserWithoutAccountIdAndNickname.utf8))
XCTAssertEqual(comment.user.displayName, "Franco Meloni")
XCTAssertNil(comment.user.nickname)
XCTAssertEqual(comment.user.uuid, "{bd1991e4-a3ed-45b2-be38-acea659650f1}")
XCTAssertNil(comment.user.accountId)
} catch {
XCTFail("Couldn't parse JSON commit (BitBucketCloudCommentUserWithoutAccountId) in BitbucketCloudComment. \nError: \(error)")
}
}

func testParsesMetadata() {
let metadata = bitbucketCould.metadata

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
public let BitBucketCloudCommentUserWithoutAccountIdAndNickname = """
{
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/Zagolo/danger-kotlin/pullrequests/1/comments/109197958"
},
"html": {
"href": "https://bitbucket.org/Zagolo/danger-kotlin/pull-requests/1/_/diff#comment-109197958"
}
},
"deleted": false,
"pullrequest": {
"type": "pullrequest",
"id": 1,
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/Zagolo/danger-kotlin/pullrequests/1"
},
"html": {
"href": "https://bitbucket.org/Zagolo/danger-kotlin/pull-requests/1"
}
},
"title": "README.md edited online with Bitbucket"
},
"content": {
"raw": "Test Comment",
"markup": "markdown",
"html": "<p>Test Comment</p>",
"type": "rendered"
},
"created_on": 1603196142,
"user": {
"username": "f-meloni",
"display_name": "Franco Meloni",
"type": "user",
"uuid": "{bd1991e4-a3ed-45b2-be38-acea659650f1}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/%7Bbd1991e4-a3ed-45b2-be38-acea659650f1%7D"
},
"html": {
"href": "https://bitbucket.org/%7Bbd1991e4-a3ed-45b2-be38-acea659650f1%7D/"
},
"avatar": {
"href": "https://secure.gravatar.com/avatar/3d90e967de2beab6d44cfadbb4976b87?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FFM-1.png"
}
}
},
"updated_on": 1603196142,
"type": "pullrequest_comment",
"id": 109197958
}
"""
1 change: 1 addition & 0 deletions Tests/DangerTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__BitBucketCloudTests = [
("testCommentUserWithoutAccountId", testCommentUserWithoutAccountId),
("testCommitWithoutUser", testCommitWithoutUser),
("testParsesActivities", testParsesActivities),
("testParsesComments", testParsesComments),
Expand Down

0 comments on commit 6a05d5c

Please sign in to comment.