v1_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package tests
  4. import (
  5. "context"
  6. v1 "cp-organization-management/pb/v1"
  7. "testing"
  8. jsoniter "github.com/json-iterator/go"
  9. )
  10. var json = jsoniter.ConfigCompatibleWithStandardLibrary
  11. func Test_CreateUser(t *testing.T) {
  12. req := &v1.CreateUserRequest{
  13. Username: "admin",
  14. Password: "admin",
  15. }
  16. r, err := client.CreateUser(context.Background(), req)
  17. if err == nil {
  18. s, _ := json.MarshalToString(r)
  19. t.Log(s)
  20. } else {
  21. t.Error("failed to call: ", err)
  22. }
  23. }
  24. func Test_Login(t *testing.T) {
  25. req := &v1.LoginRequest{
  26. Username: "admin",
  27. Password: "admin",
  28. }
  29. r, err := client.Login(context.Background(), req)
  30. if err == nil {
  31. s, _ := json.MarshalToString(r)
  32. t.Log(s)
  33. } else {
  34. t.Error("failed to call: ", err)
  35. }
  36. }
  37. func Test_ChangePassword(t *testing.T) {
  38. req := &v1.ChangePasswordRequest{
  39. Uid: 2,
  40. Password: "123456",
  41. }
  42. r, err := client.ChangePassword(context.Background(), req)
  43. if err == nil {
  44. s, _ := json.MarshalToString(r)
  45. t.Log(s)
  46. } else {
  47. t.Error("failed to call: ", err)
  48. }
  49. }
  50. func Test_CreateOrganization(t *testing.T) {
  51. req := &v1.CreateOrganizationRequest{
  52. OrganizationName: "成都市",
  53. Month: 60,
  54. State: 1,
  55. }
  56. r, err := client.CreateOrganization(context.Background(), req)
  57. if err == nil {
  58. s, _ := json.MarshalToString(r)
  59. t.Log(s)
  60. } else {
  61. t.Error("failed to call: ", err)
  62. }
  63. }