diff --git a/nucleus/gnmi_transport.go b/nucleus/gnmi_transport.go index 870af9eaeb787c8cbf6cb7de90bf2d9ea40e4870..58ecadda376e4decae176cb8d6f079dc1a57727e 100644 --- a/nucleus/gnmi_transport.go +++ b/nucleus/gnmi_transport.go @@ -113,6 +113,11 @@ func (g *Gnmi) Set(ctx context.Context, args ...interface{}) error { v: o, t: reflect.TypeOf("placeholder"), } + } else if attrs == nil || len(attrs) == 0 { + return &ErrInvalidParameters{ + f: "gnmi.Set()", + r: "no parameters provided", + } } opts = append(opts, &gnmi.Operation{ // Hardcoded TransportUpdate until multiple operations are supported diff --git a/test/integration/cmdIntegration_test.go b/test/integration/cmdIntegration_test.go index 65b3670d45daf1e3389bcdc8ab1787069ae272fa..03048c8eafaebb5127f7a26ed40138e3f3567729 100644 --- a/test/integration/cmdIntegration_test.go +++ b/test/integration/cmdIntegration_test.go @@ -85,7 +85,7 @@ func testSetupIntegration() { } } -func TestCliIntegration(t *testing.T) { +func TestCmdIntegration(t *testing.T) { if testing.Short() { t.Skip("skipping integration test") } diff --git a/test/integration/nucleusIntegration_test.go b/test/integration/nucleusIntegration_test.go index 54f310491d161b597762bc4028e5bbfebd07c8f1..ed6d78fd929ed1d8379ca0cc18bc11d2e65e5f83 100644 --- a/test/integration/nucleusIntegration_test.go +++ b/test/integration/nucleusIntegration_test.go @@ -41,7 +41,7 @@ func TestGnmi_SetIntegration(t *testing.T) { }, args: args{ ctx: context.Background(), - params: []string{}, + params: []string{"/system/config/hostname", "ceos3000"}, }, wantErr: true, }, @@ -54,6 +54,15 @@ func TestGnmi_SetIntegration(t *testing.T) { }, wantErr: false, }, + { + name: "invalid update", + fields: fields{opt: opt}, + args: args{ + ctx: context.Background(), + params: nil, + }, + wantErr: true, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {