compat_proto_test.go 1012 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package tests
  2. import (
  3. "os"
  4. "path/filepath"
  5. "strings"
  6. "testing"
  7. "hth/internal/testutil"
  8. )
  9. func TestProtoEnumZeroUnspecified(t *testing.T) {
  10. root := testutil.HostRoot(t)
  11. proto := filepath.Join(root, "api", "proto", "hth", "api", "v1", "hth.proto")
  12. raw, err := os.ReadFile(proto)
  13. if err != nil {
  14. t.Fatal(err)
  15. }
  16. text := string(raw)
  17. if !strings.Contains(text, "package hth.api.v1;") {
  18. t.Fatal("package")
  19. }
  20. if !strings.Contains(text, "DEVICE_LIFECYCLE_STATE_UNSPECIFIED = 0") {
  21. t.Fatal("lifecycle 0")
  22. }
  23. if !strings.Contains(text, "DATA_QUALITY_UNSPECIFIED = 0") {
  24. t.Fatal("quality 0")
  25. }
  26. if !strings.Contains(text, "CONFIRMATION_STATUS_UNSPECIFIED = 0") {
  27. t.Fatal("confirmation 0")
  28. }
  29. if strings.Contains(text, "reserved ") {
  30. // reserved tags are optional in v1 as long as we never reuse; presence is fine
  31. }
  32. desc := filepath.Join(root, "api", "proto", "hth", "api", "v1", "hth.desc")
  33. if _, err := os.Stat(desc); err != nil {
  34. t.Fatalf("descriptor baseline missing: %v", err)
  35. }
  36. }