store_key_test.go 721 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package store_key
  2. import "testing"
  3. func TestNewAStoreKey_ok(t *testing.T) {
  4. t.Parallel()
  5. cases := []string{
  6. "key",
  7. "key_1",
  8. "ключ",
  9. "topic/partition/offset",
  10. }
  11. for _, tc := range cases {
  12. t.Run(tc, func(t *testing.T) {
  13. t.Parallel()
  14. k := NewAStoreKey(tc)
  15. if k == nil {
  16. t.Fatalf("NewAStoreKey(): nil")
  17. }
  18. if got := k.val.Get(); got != tc {
  19. t.Fatalf("Get(): got=%q want=%q", got, tc)
  20. }
  21. if got := k.val.Get(); got != tc {
  22. t.Fatalf("String(): got=%q want=%q", got, tc)
  23. }
  24. })
  25. }
  26. }
  27. func TestNewAStoreKey_empty_panics(t *testing.T) {
  28. t.Parallel()
  29. defer func() {
  30. if r := recover(); r == nil {
  31. t.Fatalf("expected panic, got nil")
  32. }
  33. }()
  34. _ = NewAStoreKey("")
  35. }