genpolicy_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package locale
  15. import (
  16. "testing"
  17. "golang.org/x/text/language"
  18. "yunion.io/x/jsonutils"
  19. )
  20. func TestGenerateAllPolicies(t *testing.T) {
  21. policies := GenerateAllPolicies()
  22. for _, p := range policies {
  23. t.Logf("name %s description %s scope %s policy %s", p.Name, p.Description, p.Scope, p.Policy)
  24. }
  25. t.Logf("total: %d", len(policies))
  26. }
  27. func TestPolicyDescriptions(t *testing.T) {
  28. out := jsonutils.NewDict()
  29. policies := GenerateAllPolicies()
  30. for _, p := range policies {
  31. item := jsonutils.NewDict()
  32. item.Add(jsonutils.NewString(p.Description), language.English.String())
  33. item.Add(jsonutils.NewString(p.DescriptionCN), language.Chinese.String())
  34. out.Add(item, p.Name)
  35. }
  36. t.Logf("%s", out.PrettyString())
  37. }
  38. func TestRoleDescriptions(t *testing.T) {
  39. out := jsonutils.NewDict()
  40. for _, r := range RoleDefinitions {
  41. item := jsonutils.NewDict()
  42. item.Add(jsonutils.NewString(r.Description), language.English.String())
  43. item.Add(jsonutils.NewString(r.DescriptionCN), language.Chinese.String())
  44. out.Add(item, r.Name)
  45. }
  46. t.Logf("%s", out.PrettyString())
  47. }