costmodelenv_test.go 889 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package env
  2. import (
  3. "os"
  4. "testing"
  5. )
  6. func TestIsCacheDisabled(t *testing.T) {
  7. tests := []struct {
  8. name string
  9. want bool
  10. pre func()
  11. }{
  12. {
  13. name: "Ensure the default value is false",
  14. want: false,
  15. },
  16. {
  17. name: "Ensure the value is false when DISABLE_AGGREGATE_COST_MODEL_CACHE is set to false",
  18. want: false,
  19. pre: func() {
  20. os.Setenv("DISABLE_AGGREGATE_COST_MODEL_CACHE", "false")
  21. },
  22. },
  23. {
  24. name: "Ensure the value is true when DISABLE_AGGREGATE_COST_MODEL_CACHE is set to true",
  25. want: true,
  26. pre: func() {
  27. os.Setenv("DISABLE_AGGREGATE_COST_MODEL_CACHE", "true")
  28. },
  29. },
  30. }
  31. for _, tt := range tests {
  32. if tt.pre != nil {
  33. tt.pre()
  34. }
  35. t.Run(tt.name, func(t *testing.T) {
  36. if got := IsAggregateCostModelCacheDisabled(); got != tt.want {
  37. t.Errorf("IsAggregateCostModelCacheDisabled() = %v, want %v", got, tt.want)
  38. }
  39. })
  40. }
  41. }