Skip to content

Commit

Permalink
fix golangci-lint errors (#1068)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ying Chun Guo authored Oct 19, 2020
1 parent 40a8403 commit 25b537b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
14 changes: 9 additions & 5 deletions pkg/dynamic/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,21 +343,25 @@ func TestListChannelsUsingGVKs(t *testing.T) {
newChannelUnstructuredObj("i1", "messaging.knative.dev/v1beta1", "InMemoryChannel"),
)
assert.Check(t, client.RawClient() != nil)
gv := schema.GroupVersion{"messaging.knative.dev", "v1beta1"}
gv := schema.GroupVersion{Group: "messaging.knative.dev", Version: "v1beta1"}
gvks := []schema.GroupVersionKind{gv.WithKind("InMemoryChannel")}

s, err := client.ListChannelsUsingGVKs(&gvks)
assert.NilError(t, err)
assert.Check(t, s != nil)
if s == nil {
t.Fatal("s = nil, want not nil")
}
assert.Equal(t, len(s.Items), 1)
assert.DeepEqual(t, s.GroupVersionKind(), schema.GroupVersionKind{messaging.GroupName, channelListVersion, channelListKind})
assert.DeepEqual(t, s.GroupVersionKind(), schema.GroupVersionKind{Group: messaging.GroupName, Version: channelListVersion, Kind: channelListKind})

// withType
s, err = client.ListChannelsUsingGVKs(&gvks, WithTypeFilter("InMemoryChannel"))
assert.NilError(t, err)
assert.Check(t, s != nil)
if s == nil {
t.Fatal("s = nil, want not nil")
}
assert.Equal(t, len(s.Items), 1)
assert.DeepEqual(t, s.GroupVersionKind(), schema.GroupVersionKind{messaging.GroupName, channelListVersion, channelListKind})
assert.DeepEqual(t, s.GroupVersionKind(), schema.GroupVersionKind{Group: messaging.GroupName, Version: channelListVersion, Kind: channelListKind})
})

}
14 changes: 7 additions & 7 deletions pkg/kn/commands/channel/list_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ const (
crdGroup = "apiextensions.k8s.io"
crdVersion = "v1beta1"
crdKind = "CustomResourceDefinition"
crdKinds = "customresourcedefinitions"
testNamespace = "current"
channelLabelValue = "true"
channelListVersion = "v1beta1"
channelListKind = "ChannelList"
inMemoryChannel = "InMemoryChannel"
)

Expand Down Expand Up @@ -107,7 +105,9 @@ func TestListBuiltInChannelTypes(t *testing.T) {
fakeDynamic := dynamicfake.NewSimpleDynamicClient(runtime.NewScheme())
channel, err := listBuiltInChannelTypes(dynamic.NewKnDynamicClient(fakeDynamic, "current"))
assert.NilError(t, err)
assert.Check(t, channel != nil)
if channel == nil {
t.Fatal("channel = nil, want not nil")
}
assert.Equal(t, len(channel.Items), 1)
}

Expand Down Expand Up @@ -153,7 +153,7 @@ func TestChannelListTypeErrors(t *testing.T) {
dynamicClient := dynamicfakeClient.CreateFakeKnDynamicClient(testNamespace, newChannelCRDObj("InMemoryChannel"))
assert.Equal(t, dynamicClient.Namespace(), testNamespace)

output, err := channelFakeCmd([]string{"channel", "list-types"}, dynamicClient)
_, err := channelFakeCmd([]string{"channel", "list-types"}, dynamicClient)
assert.Check(t, err != nil)
assert.Error(t, err, "can't find specs.names.kind for InMemoryChannel")

Expand All @@ -164,7 +164,7 @@ func TestChannelListTypeErrors(t *testing.T) {
"names": map[string]interface{}{},
}
dynamicClient = dynamicfakeClient.CreateFakeKnDynamicClient(testNamespace, obj)
output, err = channelFakeCmd([]string{"channel", "list-types"}, dynamicClient)
_, err = channelFakeCmd([]string{"channel", "list-types"}, dynamicClient)
assert.Check(t, err != nil)
assert.Error(t, err, "can't find specs.names.kind for InMemoryChannel")

Expand All @@ -178,7 +178,7 @@ func TestChannelListTypeErrors(t *testing.T) {
}

dynamicClient = dynamicfakeClient.CreateFakeKnDynamicClient(testNamespace, obj)
output, err = channelFakeCmd([]string{"channel", "list-types"}, dynamicClient)
_, err = channelFakeCmd([]string{"channel", "list-types"}, dynamicClient)
assert.Check(t, err != nil)
assert.Error(t, err, ".spec.names.kind accessor error: true is of the type bool, expected string")

Expand All @@ -189,7 +189,7 @@ func TestChannelListTypeErrors(t *testing.T) {
assert.Check(t, err != nil)
assert.Error(t, err, "unknown flag: --noheader")

output, err = channelFakeCmd([]string{"channel", "list-types"}, dynamicClient)
output, err := channelFakeCmd([]string{"channel", "list-types"}, dynamicClient)
assert.NilError(t, err)
assert.Check(t, util.ContainsAll(output[0], "TYPE", "NAME", "DESCRIPTION"))
assert.Check(t, util.ContainsAll(output[1], "InMemoryChannel", "InMemoryChannel"))
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/subscription/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func printSubscriptionListWithNamespace(subscriptionList *messagingv1beta1.Subsc
rows := make([]metav1beta1.TableRow, 0, len(subscriptionList.Items))

// temporary slice for sorting services in non-default namespace
var others []metav1beta1.TableRow
others := make([]metav1beta1.TableRow, 0, len(rows))

for _, subscription := range subscriptionList.Items {
// Fill in with services in `default` namespace at first
Expand Down
1 change: 0 additions & 1 deletion pkg/kn/flags/channel_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,4 @@ func (i *ChannelRef) Parse() (*corev1.ObjectReference, error) {
default:
return nil, fmt.Errorf("Error: incorrect value '%s' for '--channel', must be in the format 'Group:Version:Kind:Name' or configure an alias in kn config and refer as: '--channel ALIAS:NAME'", i.Cref)
}
return nil, nil
}
5 changes: 3 additions & 2 deletions pkg/messaging/v1beta1/subscriptions_client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ func NewMockKnSubscriptionsClient(t *testing.T, ns ...string) *MockKnSubscriptio
namespace = ns[0]
}
return &MockKnSubscriptionsClient{
t: t,
recorder: &SubscriptionsRecorder{mock.NewRecorder(t, namespace)},
t: t,
recorder: &SubscriptionsRecorder{mock.NewRecorder(t, namespace)},
namespace: namespace,
}
}

Expand Down

0 comments on commit 25b537b

Please sign in to comment.