123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- package service
- import (
- "context"
- "testing"
- . "github.com/smartystreets/goconvey/convey"
- )
- func TestService_AddAuthorityUser(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- s.dao.Exec(context.TODO(), "DELETE FROM authority_user WHERE username = 'maru'")
- err := s.AddAuthorityUser("maru", "maru")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_AddAuthorityTaskRoleUser(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- err := s.AddAuthorityTaskRoleUser("maru", "1")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_AddAuthorityTaskGroupUser(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- err := s.AddAuthorityTaskGroupUser("maru", "1")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_AddAuthorityTaskRole(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- s.dao.Exec(context.TODO(), "DELETE FROM authority_task_role WHERE name = 'test'")
- err := s.AddAuthorityTaskRole(1, "test", "test")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_AddAuthorityTaskGroup(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- s.dao.Exec(context.TODO(), "DELETE FROM authority_task_group WHERE name = 'test'")
- err := s.AddAuthorityTaskGroup("test", "test")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_AddPrivilege(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- s.dao.Exec(context.TODO(), "DELETE FROM authority_privilege WHERE name = 'test'")
- err := s.AddPrivilege("test", 1, 1, 1)
- So(err, ShouldBeNil)
- }))
- }
- func TestService_DeleteAuthorityTaskRoleUser(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- err := s.DeleteAuthorityTaskRoleUser(11, 1)
- So(err, ShouldBeNil)
- }))
- }
- func TestService_DeleteAuthorityUser(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- err := s.DeleteAuthorityUser(11)
- So(err, ShouldBeNil)
- }))
- }
- func TestService_DeleteAuthorityTaskRole(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- err := s.DeleteAuthorityTaskRole(1)
- So(err, ShouldBeNil)
- }))
- }
- func TestService_DeleteAuthorityTaskGroupUser(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- err := s.DeleteAuthorityTaskGroupUser(11, 1)
- So(err, ShouldBeNil)
- }))
- }
- func TestService_DeleteAuthorityTaskGroup(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- err := s.DeleteAuthorityTaskGroup(1)
- So(err, ShouldBeNil)
- }))
- }
- func TestService_GetAuthorityUserPrivileges(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- _, err := s.GetAuthorityUserPrivileges("maru")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_ListPrivilege(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- _, err := s.ListPrivilege()
- So(err, ShouldBeNil)
- }))
- }
- func TestService_ListGroupAndRole(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- _, _, err := s.ListGroupAndRole()
- So(err, ShouldBeNil)
- }))
- }
- func TestService_ListAuthorityTaskRoles(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- s.dao.Exec(context.TODO(), "UPDATE authority_user SET task_group = 1 WHERE username = 'test'")
- _, _, err := s.ListAuthorityTaskRoles("test", 0, 10, "id")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_ListAuthorityTaskGroups(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- _, _, err := s.ListAuthorityTaskGroups(0, 10, "id")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_ListAuthorityRolePrivilege(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- s.dao.Exec(context.TODO(), "UPDATE authority_task_group SET is_deleted = 0 WHERE id = 1")
- s.dao.Exec(context.TODO(), "UPDATE authority_task_role SET is_deleted = 0 WHERE id = 1")
- _, err := s.ListAuthorityRolePrivilege(1, 1, 2)
- So(err, ShouldBeNil)
- }))
- }
- func TestService_ListAuthorityGroupPrivilege(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- s.dao.Exec(context.TODO(), "UPDATE authority_task_group SET is_deleted = 0 WHERE id = 1")
- _, err := s.ListAuthorityGroupPrivilege(1, 1)
- So(err, ShouldBeNil)
- }))
- }
- func TestService_ListAuthorityUsers(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- _, _, err := s.ListAuthorityUsers("", 0, 0, "id")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_UpdatePrivilege(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- s.dao.Exec(context.TODO(), "DELETE FROM authority_privilege WHERE name = 'test'")
- err := s.UpdatePrivilege(1, "test", 1, 1, 1)
- So(err, ShouldBeNil)
- }))
- }
- func TestService_UpdateAuthorityUserInfo(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- s.dao.Exec(context.TODO(), "UPDATE authority_user SET nickname = 'abc' WHERE id = 1")
- err := s.UpdateAuthorityUserInfo(1, "test")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_UpdateAuthorityUserAuth(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- err := s.UpdateAuthorityUserAuth(1, "1", "1")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_UpdateAuthorityTaskRoleInfo(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- err := s.UpdateAuthorityTaskRoleInfo(1, "maru", "test")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_UpdateAuthorityRolePrivilege(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- err := s.UpdateAuthorityRolePrivilege(1, "", "")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_UpdateAuthorityTaskGroupInfo(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- s.dao.Exec(context.TODO(), "UPDATE authority_task_group SET desc = 'tt' WHERE id = 1")
- err := s.UpdateAuthorityTaskGroupInfo(1, "", "test")
- So(err, ShouldBeNil)
- }))
- }
- func TestService_UpdateAuthorityGroupPrivilege(t *testing.T) {
- Convey("", t, WithService(func(s *Service) {
- err := s.UpdateAuthorityGroupPrivilege(1, "", "", 0)
- So(err, ShouldBeNil)
- }))
- }
|