Skip to content
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

test(gateway): migrate Go tests from Kubo #156

Merged
merged 3 commits into from
Feb 14, 2023
Merged

Conversation

hacdias
Copy link
Member

@hacdias hacdias commented Feb 7, 2023

Part of #146. Migrates remaining gateway Go tests from Kubo (see removal in Kubo: ipfs/kubo#9627). Since we don't have a UnixFS API here, I created a fixtures.car file. This file has a single root. Under that root, there is a directory for each test (that requires data) with the name of the test.

@codecov
Copy link

codecov bot commented Feb 7, 2023

Codecov Report

Merging #156 (8ccb02a) into main (2902465) will increase coverage by 6.36%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
+ Coverage   19.62%   25.98%   +6.36%     
==========================================
  Files         100      100              
  Lines       11053    11053              
==========================================
+ Hits         2169     2872     +703     
+ Misses       8597     7839     -758     
- Partials      287      342      +55     
Impacted Files Coverage Δ
gateway/hostname.go 61.31% <0.00%> (+8.15%) ⬆️
gateway/handler_unixfs__redirects.go 39.34% <0.00%> (+39.34%) ⬆️
gateway/assets/assets.go 75.75% <0.00%> (+46.46%) ⬆️
gateway/handler.go 61.73% <0.00%> (+56.59%) ⬆️
gateway/handler_unixfs_file.go 63.76% <0.00%> (+63.76%) ⬆️
gateway/handler_unixfs_dir.go 66.20% <0.00%> (+66.20%) ⬆️
gateway/handler_unixfs.go 69.23% <0.00%> (+69.23%) ⬆️
gateway/gateway.go 100.00% <0.00%> (+100.00%) ⬆️

@hacdias hacdias changed the title feat(gateway): bring some initial tests from Kubo test(gateway): migrate Go tests from kubo Feb 7, 2023
@hacdias hacdias changed the title test(gateway): migrate Go tests from kubo test(gateway): migrate Go tests from Kubo Feb 7, 2023
@hacdias hacdias marked this pull request as ready for review February 7, 2023 12:04
@hacdias hacdias requested a review from lidel as a code owner February 7, 2023 12:04
@hacdias hacdias self-assigned this Feb 7, 2023
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Thank you for cleaning this up ❤️

return &mockApi{
ns: mockNamesys{},
func newMockAPI(t *testing.T) (*mockAPI, cid.Cid) {
r, err := os.Open("./testdata/fixtures.car")
Copy link
Member

Choose a reason for hiding this comment

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

@hacdias fysa I've moved fixtures to testdata/ subdir, it seems to be a good convention to follow in future:

The go tool will ignore a directory named "testdata", making it available to hold ancillary data needed by the tests.
go help test

@lidel lidel merged commit 189666b into main Feb 14, 2023
@lidel lidel deleted the gateway/bring-some-tests branch February 14, 2023 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants