properties_test.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package kubecost
  2. import "testing"
  3. // TODO niko/etl
  4. // func TestParseProperty(t *testing.T) {}
  5. // TODO niko/etl
  6. // func TestProperty_String(t *testing.T) {}
  7. func TestProperties_AggregationString(t *testing.T) {
  8. var props *Properties
  9. var aggStrs []string
  10. // nil Properties should produce and empty slice
  11. aggStrs = props.AggregationStrings()
  12. if aggStrs == nil || len(aggStrs) > 0 {
  13. t.Fatalf("expected empty slice; got %v", aggStrs)
  14. }
  15. // empty Properties should product an empty slice
  16. props = &Properties{}
  17. aggStrs = props.AggregationStrings()
  18. if aggStrs == nil || len(aggStrs) > 0 {
  19. t.Fatalf("expected empty slice; got %v", aggStrs)
  20. }
  21. // Properties with single, simple property set
  22. props = &Properties{}
  23. props.SetNamespace("")
  24. aggStrs = props.AggregationStrings()
  25. if len(aggStrs) != 1 || aggStrs[0] != "namespace" {
  26. t.Fatalf("expected [\"namespace\"]; got %v", aggStrs)
  27. }
  28. // Properties with mutiple properties, including labels
  29. // Note: order matters!
  30. props = &Properties{}
  31. props.SetNamespace("")
  32. props.SetLabels(map[string]string{
  33. "env": "",
  34. "app": "",
  35. })
  36. props.SetCluster("")
  37. aggStrs = props.AggregationStrings()
  38. if len(aggStrs) != 4 {
  39. t.Fatalf("expected length %d; got lenfth %d", 4, len(aggStrs))
  40. }
  41. if aggStrs[0] != "cluster" {
  42. t.Fatalf("expected aggStrs[0] == \"%s\"; got \"%s\"", "cluster", aggStrs[0])
  43. }
  44. if aggStrs[1] != "namespace" {
  45. t.Fatalf("expected aggStrs[1] == \"%s\"; got \"%s\"", "namespace", aggStrs[1])
  46. }
  47. if aggStrs[2] != "label:app" {
  48. t.Fatalf("expected aggStrs[2] == \"%s\"; got \"%s\"", "label:app", aggStrs[2])
  49. }
  50. if aggStrs[3] != "label:env" {
  51. t.Fatalf("expected aggStrs[3] == \"%s\"; got \"%s\"", "label:env", aggStrs[3])
  52. }
  53. }
  54. // TODO niko/etl
  55. // func TestProperties_Clone(t *testing.T) {}
  56. // TODO niko/etl
  57. // func TestProperties_Intersection(t *testing.T) {}
  58. // TODO niko/etl
  59. // func TestProperties_GetCluster(t *testing.T) {}
  60. // TODO niko/etl
  61. // func TestProperties_SetCluster(t *testing.T) {}
  62. // TODO niko/etl
  63. // func TestProperties_GetContainer(t *testing.T) {}
  64. // TODO niko/etl
  65. // func TestProperties_SetContainer(t *testing.T) {}
  66. // TODO niko/etl
  67. // func TestProperties_GetController(t *testing.T) {}
  68. // TODO niko/etl
  69. // func TestProperties_SetController(t *testing.T) {}
  70. // TODO niko/etl
  71. // func TestProperties_GetControllerKind(t *testing.T) {}
  72. // TODO niko/etl
  73. // func TestProperties_SetControllerKind(t *testing.T) {}
  74. // TODO niko/etl
  75. // func TestProperties_GetLabels(t *testing.T) {}
  76. // TODO niko/etl
  77. // func TestProperties_SetLabels(t *testing.T) {}
  78. // TODO niko/etl
  79. // func TestProperties_GetNamespace(t *testing.T) {}
  80. // TODO niko/etl
  81. // func TestProperties_SetNamespace(t *testing.T) {}
  82. // TODO niko/etl
  83. // func TestProperties_GetPod(t *testing.T) {}
  84. // TODO niko/etl
  85. // func TestProperties_SetPod(t *testing.T) {}
  86. // TODO niko/etl
  87. // func TestProperties_GetServices(t *testing.T) {}
  88. // TODO niko/etl
  89. // func TestProperties_SetServices(t *testing.T) {}