Skip to content
Snippets Groups Projects
Commit f316d842 authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

more error handling

parent 034077f1
Branches
Tags
9 merge requests!246Develop,!245Develop into Master,!244Master into develop2 into master,!219Draft: Testing,!214Test pipelines,!195DO NOT MERGE 2,!194DO NOT MERGE! just for testing,!147Commit-Confirm Mechanic for PND,!138Develop
Pipeline #68991 passed
This commit is part of merge request !147. Comments created here will be created in the context of that merge request.
...@@ -113,6 +113,11 @@ func (g *Gnmi) Set(ctx context.Context, args ...interface{}) error { ...@@ -113,6 +113,11 @@ func (g *Gnmi) Set(ctx context.Context, args ...interface{}) error {
v: o, v: o,
t: reflect.TypeOf("placeholder"), 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{ opts = append(opts, &gnmi.Operation{
// Hardcoded TransportUpdate until multiple operations are supported // Hardcoded TransportUpdate until multiple operations are supported
......
...@@ -85,7 +85,7 @@ func testSetupIntegration() { ...@@ -85,7 +85,7 @@ func testSetupIntegration() {
} }
} }
func TestCliIntegration(t *testing.T) { func TestCmdIntegration(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skipping integration test") t.Skip("skipping integration test")
} }
......
...@@ -41,7 +41,7 @@ func TestGnmi_SetIntegration(t *testing.T) { ...@@ -41,7 +41,7 @@ func TestGnmi_SetIntegration(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
params: []string{}, params: []string{"/system/config/hostname", "ceos3000"},
}, },
wantErr: true, wantErr: true,
}, },
...@@ -54,6 +54,15 @@ func TestGnmi_SetIntegration(t *testing.T) { ...@@ -54,6 +54,15 @@ func TestGnmi_SetIntegration(t *testing.T) {
}, },
wantErr: false, wantErr: false,
}, },
{
name: "invalid update",
fields: fields{opt: opt},
args: args{
ctx: context.Background(),
params: nil,
},
wantErr: true,
},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment