Skip to content

Commit

Permalink
fix lint failures
Browse files Browse the repository at this point in the history
Signed-off-by: everettraven <[email protected]>
  • Loading branch information
everettraven committed Jan 31, 2024
1 parent d366f83 commit af2ceb1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/pkg/catalogd/fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (c *Fetcher) FetchCatalogs(ctx context.Context, filters ...CatalogFilterFun
for _, catalog := range catalogList.Items {
filteredOut := false
for _, filter := range filters {
if !filter(&catalog) {
if !filter(catalog.DeepCopy()) {
filteredOut = true
}
}
Expand Down
7 changes: 5 additions & 2 deletions internal/pkg/catalogd/fetcher/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,13 @@ func TestFetcher(t *testing.T) {
}

for _, tt := range tests {
fetch := tt.fetcher
filters := tt.filters
expectedCatalogs := tt.expectedCatalogs
t.Run(tt.name, func(t *testing.T) {
catalogs, err := tt.fetcher.FetchCatalogs(context.Background(), tt.filters...)
catalogs, err := fetch.FetchCatalogs(context.Background(), filters...)
require.NoError(t, err)
diff := cmp.Diff(tt.expectedCatalogs, catalogs, cmpopts.IgnoreFields(metav1.ObjectMeta{}, "ResourceVersion"))
diff := cmp.Diff(expectedCatalogs, catalogs, cmpopts.IgnoreFields(metav1.ObjectMeta{}, "ResourceVersion"))
require.Equal(t, diff, "")
})
}
Expand Down
10 changes: 7 additions & 3 deletions internal/pkg/catalogd/streamer/streamer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ func TestStreamer(t *testing.T) {
}

for _, tt := range tests {
stream := tt.streamer
catalog := tt.catalog
expectError := tt.expectError
expectedContent := tt.expectedContent
t.Run(tt.name, func(t *testing.T) {
rc, err := tt.streamer.StreamCatalogContents(context.Background(), tt.catalog)
if tt.expectError {
rc, err := stream.StreamCatalogContents(context.Background(), catalog)
if expectError {
require.Error(t, err)
return
}
Expand All @@ -93,7 +97,7 @@ func TestStreamer(t *testing.T) {
})
content, err := io.ReadAll(rc)
require.NoError(t, err)
require.Equal(t, tt.expectedContent, string(content))
require.Equal(t, expectedContent, string(content))
})
}
}
3 changes: 2 additions & 1 deletion internal/pkg/experimental/action/catalog_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (i *CatalogInspect) Run(ctx context.Context, inspectOpts CatalogInspectOpti
metas := []Meta{}

for _, catalog := range catalogs {
catalogName := catalog.Name
rc, err := stream.StreamCatalogContents(ctx, catalog)
if err != nil {
return nil, fmt.Errorf("streaming FBC for catalog %q: %w", catalog.Name, err)
Expand Down Expand Up @@ -143,7 +144,7 @@ func (i *CatalogInspect) Run(ctx context.Context, inspectOpts CatalogInspectOpti
Name: meta.Name,
Blob: meta.Blob,
},
Catalog: catalog.Name,
Catalog: catalogName,
}
metas = append(metas, metaEntry)

Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/experimental/action/catalog_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (i *CatalogList) Run(ctx context.Context, listOpts CatalogListOptions) ([]M
metas := []Meta{}

for _, catalog := range catalogs {
catalogName := catalog.Name
rc, err := stream.StreamCatalogContents(ctx, catalog)
if err != nil {
return nil, fmt.Errorf("streaming FBC for catalog %q: %w", catalog.Name, err)
Expand Down Expand Up @@ -145,7 +146,7 @@ func (i *CatalogList) Run(ctx context.Context, listOpts CatalogListOptions) ([]M
Name: meta.Name,
Blob: meta.Blob,
},
Catalog: catalog.Name,
Catalog: catalogName,
}
metas = append(metas, metaEntry)

Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/experimental/action/catalog_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (i *CatalogSearch) Run(ctx context.Context, searchOpts CatalogSearchOptions
metas := []Meta{}

for _, catalog := range catalogs {
catalogName := catalog.Name
rc, err := stream.StreamCatalogContents(ctx, catalog)
if err != nil {
return nil, fmt.Errorf("streaming FBC for catalog %q: %w", catalog.Name, err)
Expand Down Expand Up @@ -135,7 +136,7 @@ func (i *CatalogSearch) Run(ctx context.Context, searchOpts CatalogSearchOptions
Name: meta.Name,
Blob: meta.Blob,
},
Catalog: catalog.Name,
Catalog: catalogName,
}
metas = append(metas, metaEntry)

Expand Down

0 comments on commit af2ceb1

Please sign in to comment.