// Check addNet with valid values, and fail with invalid values
// For Cloud Hypervisor only tap is be required
Check addNet with valid values, and fail with invalid values
For Cloud Hypervisor only tap is be required
// Check addNet with valid values and fail with invalid values // For Cloud Hypervisor only tap is be required
func TestCloudHypervisorAddNetCheckEnpointTypes(t *testing.T) {
	assert := assert.New(t)
	tapPath := "/path/to/tap"
	validVeth := &VethEndpoint{}
	validVeth.NetPair.TapInterface.TAPIface.Name = tapPath
	type args struct {
		e Endpoint
	}
	tests := []struct {
		name    string
		args    args
		wantErr bool
	}{
		{"TapEndpoint", args{e: &TapEndpoint{}}, true},
		{"Empty VethEndpoint", args{e: &VethEndpoint{}}, true},
		{"Valid VethEndpoint", args{e: validVeth}, false},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			clh := &cloudHypervisor{}
			if err := clh.addNet(tt.args.e); (err != nil) != tt.wantErr {
				t.Errorf("cloudHypervisor.addNet() error = %v, wantErr %v", err, tt.wantErr)
			} else if err == nil {
				assert.Equal(clh.vmconfig.Net[0].Tap, tapPath)
			}
		})
	}
}
func TestCloudHypervisorAddNetCheckEnpointTypes ( t * testing . T ) { assert := assert . New ( t ) tapPath := " " validVeth := & VethEndpoint { } validVeth . NetPair . TapInterface . TAPIface . Name = tapPath type args struct { e Endpoint } tests := [ ] struct { name string args args wantErr bool } { { " " , args { e : & TapEndpoint { } } , true } , { " " , args { e : & VethEndpoint { } } , true } , { " " , args { e : validVeth } , false } , } for _ , tt := range tests { t . Run ( tt . name , func ( t * testing . T ) { clh := & cloudHypervisor { } if err := clh . addNet ( tt . args . e ) ; ( err != nil ) != tt . wantErr { t . Errorf ( " " , err , tt . wantErr ) } else if err == nil { assert . Equal ( clh . vmconfig . Net [ 0 ] . Tap , tapPath ) } } ) } }
Check addNet with valid values, and fail with invalid values
For Cloud Hypervisor only tap is be required
Check addNet with valid values and fail with invalid values For Cloud Hypervisor only tap is be required