@@ -735,6 +735,99 @@ func TestGetAclCounterAttribute(t *testing.T) {
735735 }
736736}
737737
738+ func TestRemoveAclTableGroupMember (t * testing.T ) {
739+ tests := []struct {
740+ desc string
741+ req * saipb.RemoveAclTableGroupMemberRequest
742+ wantErr string
743+ setup func (* acl )
744+ wantState map [uint64 ]tableLocation
745+ }{{
746+ desc : "success" ,
747+ req : & saipb.RemoveAclTableGroupMemberRequest {
748+ Oid : 10 ,
749+ },
750+ setup : func (a * acl ) {
751+ a .tableToLocation [5 ] = tableLocation {
752+ groupID : "1" ,
753+ bank : 0 ,
754+ memberID : 10 ,
755+ }
756+ a .mgr .StoreAttributes (10 , & saipb.CreateAclTableGroupMemberRequest {
757+ Priority : proto .Uint32 (100 ),
758+ })
759+ },
760+ wantState : map [uint64 ]tableLocation {},
761+ }, {
762+ desc : "not found" ,
763+ req : & saipb.RemoveAclTableGroupMemberRequest {
764+ Oid : 11 ,
765+ },
766+ setup : func (a * acl ) {
767+ a .tableToLocation [5 ] = tableLocation {
768+ groupID : "1" ,
769+ bank : 0 ,
770+ memberID : 10 ,
771+ }
772+ a .mgr .StoreAttributes (11 , & saipb.CreateAclTableGroupMemberRequest {
773+ Priority : proto .Uint32 (100 ),
774+ })
775+ },
776+ wantState : map [uint64 ]tableLocation {
777+ 5 : {
778+ groupID : "1" ,
779+ bank : 0 ,
780+ memberID : 10 ,
781+ },
782+ },
783+ }}
784+ for _ , tt := range tests {
785+ t .Run (tt .desc , func (t * testing.T ) {
786+ dplane := & fakeSwitchDataplane {}
787+ c , a , stopFn := newTestACL (t , dplane )
788+ defer stopFn ()
789+ if tt .setup != nil {
790+ tt .setup (a )
791+ }
792+ _ , gotErr := c .RemoveAclTableGroupMember (context .TODO (), tt .req )
793+ if diff := errdiff .Check (gotErr , tt .wantErr ); diff != "" {
794+ t .Fatalf ("RemoveAclTableGroupMember() unexpected err: %s" , diff )
795+ }
796+ if gotErr != nil {
797+ return
798+ }
799+ if d := cmp .Diff (a .tableToLocation , tt .wantState , cmp .AllowUnexported (tableLocation {})); d != "" {
800+ t .Errorf ("RemoveAclTableGroupMember() failed: diff(-got,+want)\n :%s" , d )
801+ }
802+ })
803+ }
804+ }
805+
806+ func TestRemoveAclTable (t * testing.T ) {
807+ tests := []struct {
808+ desc string
809+ req * saipb.RemoveAclTableRequest
810+ wantErr string
811+ }{{
812+ desc : "success" ,
813+ req : & saipb.RemoveAclTableRequest {Oid : 1 },
814+ }}
815+ for _ , tt := range tests {
816+ t .Run (tt .desc , func (t * testing.T ) {
817+ dplane := & fakeSwitchDataplane {}
818+ c , a , stopFn := newTestACL (t , dplane )
819+ a .mgr .StoreAttributes (1 , & saipb.CreateAclTableRequest {
820+ AclStage : saipb .AclStage_ACL_STAGE_INGRESS .Enum (),
821+ })
822+ defer stopFn ()
823+ _ , gotErr := c .RemoveAclTable (context .TODO (), tt .req )
824+ if diff := errdiff .Check (gotErr , tt .wantErr ); diff != "" {
825+ t .Fatalf ("RemoveAclTable() unexpected err: %s" , diff )
826+ }
827+ })
828+ }
829+ }
830+
738831func newTestACL (t testing.TB , api switchDataplaneAPI ) (saipb.AclClient , * acl , func ()) {
739832 var a * acl
740833 conn , _ , stopFn := newTestServer (t , func (mgr * attrmgr.AttrMgr , srv * grpc.Server ) {
0 commit comments