package rbac

import (
	"context"
	"testing"

	"github.com/smartystreets/goconvey/convey"
)

func TestCreateRbacRolePrivilege(t *testing.T) {
	dao := &RbacDao{}
	ctx := context.TODO()

	convey.Convey("CreateRbacRolePrivilege", t, func() {
		err := dao.CreateRbacRolePrivilege(ctx, db, ddbClient, 100, []uint64{100})
		convey.So(err, convey.ShouldBeNil)
	})

}

func TestDeleteRbacRolePrivilege(t *testing.T) {
	d := &RbacDao{}
	ctx := context.TODO()

	convey.Convey("DeleteRbacRolePrivilege", t, func() {
		err := d.DeleteRbacRolePrivilege(ctx, db, ddbClient, 100, 100)
		// can not delete the rolePrivilege which does not exist
		convey.So(err, convey.ShouldNotBeNil)
	})

}
func TestListRbacPrivilegeIDsByRoleID(t *testing.T) {
	dao := &RbacDao{}
	ctx := context.TODO()

	convey.Convey("ListRbacPrivilegeIDsByRoleID", t, func() {
		ids := []uint64{2}
		_, err := dao.ListRbacPrivilegesIDsByRoleID(ctx, db, ids)
		convey.So(err, convey.ShouldBeNil)
	})

}
