您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

47 行
1.4 KiB

  1. /*
  2. Copyright 2017 Google LLC
  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. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package bigtable
  14. import (
  15. "testing"
  16. "time"
  17. bttdpb "google.golang.org/genproto/googleapis/bigtable/admin/v2"
  18. )
  19. func TestGcRuleToString(t *testing.T) {
  20. intersection := IntersectionPolicy(MaxVersionsPolicy(5), MaxVersionsPolicy(10), MaxAgePolicy(16*time.Hour))
  21. var tests = []struct {
  22. proto *bttdpb.GcRule
  23. want string
  24. }{
  25. {MaxAgePolicy(72 * time.Hour).proto(), "age() > 3d"},
  26. {MaxVersionsPolicy(5).proto(), "versions() > 5"},
  27. {intersection.proto(), "(versions() > 5 && versions() > 10 && age() > 16h)"},
  28. {UnionPolicy(intersection, MaxAgePolicy(72*time.Hour)).proto(),
  29. "((versions() > 5 && versions() > 10 && age() > 16h) || age() > 3d)"},
  30. }
  31. for _, test := range tests {
  32. got := GCRuleToString(test.proto)
  33. if got != test.want {
  34. t.Errorf("got gc rule string: %v, wanted: %v", got, test.want)
  35. }
  36. }
  37. }