Skip to content

Conversation

finestructure
Copy link
Member

@finestructure finestructure commented Sep 15, 2024

As discussed, merges ForkedFromResult into ForkedFrom Info.

@cla-bot cla-bot bot added the cla-signed label Sep 15, 2024
case .fromGitHub:
return nil
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved these two view related properties into an extension in the file under Views/PackageController/GetRoute.Model+ext.swift. That way, view related things don't distract from the basic definition and appear "closer" to where they're actually used.

fundingLinks: result.repository.fundingLinks,
swift6Readiness: swift6Readiness,
forkedFromResult: forkedFromResult
forkedFromInfo: forkedFromInfo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model init now doesn't do any logic with ForkedFromInfo - it just assigns it. That makes the tests simpler, see below.

async let buildInfo = API.PackageController.BuildInfo.query(on: database,
owner: owner,
repository: repository)
async let forkedFromInfo = forkedFromInfo(on: database, fork: packageResult.repository.forkedFrom)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're potentially running another query, using async let makes this concurrent.

case fromSPI(originalOwner: String,
originalOwnerName: String,
originalRepo: String,
originalPackageName: String)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the packageName: String field was actually unused.


// validate
XCTAssertEqual(model.forkedFromInfo, API.PackageController.GetRoute.Model.ForkedFromInfo.fromGitHub(url: "https://github.com/example/repo.git"))
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is now pretty much superfluous - we're passing through the simple ForkedFromInfo enum and there's no point testing the GH case.

XCTAssertEqual(forkedFrom, .fromSPI(originalOwner: "original",
originalOwnerName: "OriginalOwner",
originalRepo: "original",
originalPackageName: "OriginalPkg"))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part that we do want to test is the ForkedFromInfo.query and so I've converted test_init_forked_from_spi into a test for that. It also gets simpler, because we don't need as much set up just to test that query.

@supersonicbyte supersonicbyte merged commit 0ec21b3 into add-forked-from-ui Sep 15, 2024
6 checks passed
@supersonicbyte supersonicbyte deleted the enum-rework branch September 15, 2024 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants