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

Merge branch 99-commit-confirm-mechanic-for-ond-changes with...

Merge branch 99-commit-confirm-mechanic-for-ond-changes with refs/heads/develop into refs/merge-requests/147/train
parents 5e53f43f 78e57d25
Branches
Tags
No related merge requests found
Pipeline #69000 passed with warnings
...@@ -28,7 +28,6 @@ func TestMain(m *testing.M) { ...@@ -28,7 +28,6 @@ func TestMain(m *testing.M) {
os.Exit(m.Run()) os.Exit(m.Run())
} }
func testSetupIntegration() { func testSetupIntegration() {
if os.Getenv("GOSDN_LOG") == "nolog" { if os.Getenv("GOSDN_LOG") == "nolog" {
log.SetLevel(log.PanicLevel) log.SetLevel(log.PanicLevel)
...@@ -86,7 +85,7 @@ func testSetupIntegration() { ...@@ -86,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")
} }
...@@ -154,7 +153,7 @@ func TestCliIntegration(t *testing.T) { ...@@ -154,7 +153,7 @@ func TestCliIntegration(t *testing.T) {
hostname := guuid.New().String() hostname := guuid.New().String()
if err := cli.HTTPGet( if err := cli.HTTPGet(
testAPIEndpoint, testAPIEndpoint,
"set", "update",
"address="+testAddress, "address="+testAddress,
"uuid="+did, "uuid="+did,
"sbi="+cliSbi, "sbi="+cliSbi,
......
...@@ -23,13 +23,12 @@ func TestGnmi_SetIntegration(t *testing.T) { ...@@ -23,13 +23,12 @@ func TestGnmi_SetIntegration(t *testing.T) {
} }
type args struct { type args struct {
ctx context.Context ctx context.Context
params []interface{} params []string
} }
tests := []struct { tests := []struct {
name string name string
fields fields fields fields
args args args args
want interface{}
wantErr bool wantErr bool
}{ }{
{ {
...@@ -42,33 +41,28 @@ func TestGnmi_SetIntegration(t *testing.T) { ...@@ -42,33 +41,28 @@ func TestGnmi_SetIntegration(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
params: []interface{}{&gnmi.Operation{}}, params: []string{"/system/config/hostname", "ceos3000"},
}, },
want: nil,
wantErr: true, wantErr: true,
}, },
{ {
name: "valid update", name: "valid update",
fields: fields{opt: opt}, fields: fields{opt: opt},
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
params: []interface{}{ params: []string{"/system/config/hostname", "ceos3000"},
&gnmi.Operation{
Type: "update",
Origin: "",
Target: "",
Path: []string{
"system",
"config",
"hostname",
},
Val: "ceos3000",
},
},
}, },
want: gnmiMessages["../proto/resp-set-system-config-hostname"],
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) {
...@@ -77,21 +71,11 @@ func TestGnmi_SetIntegration(t *testing.T) { ...@@ -77,21 +71,11 @@ func TestGnmi_SetIntegration(t *testing.T) {
t.Errorf("NewGnmiTransport() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("NewGnmiTransport() error = %v, wantErr %v", err, tt.wantErr)
return return
} }
resp, err := g.Set(tt.args.ctx, tt.args.params...) err = g.Set(tt.args.ctx, tt.args.params)
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
t.Errorf("Set() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("Set() error = %v, wantErr %v", err, tt.wantErr)
return return
} }
got, ok := resp.(*gpb.SetResponse)
if !ok {
t.Errorf("want: %v, got %v, error: %v", reflect.TypeOf(&gpb.SetResponse{}), reflect.TypeOf(resp), &nucleus.ErrInvalidTypeAssertion{})
}
if err != nil && tt.wantErr {
return
} else if got.Prefix.Target != testAddress ||
got.Response[0].Op != gpb.UpdateResult_UPDATE {
t.Errorf("Set() got = %v, want %v", got, tt.want)
}
}) })
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment