Class: AnnotationsMiddlewareTest
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- AnnotationsMiddlewareTest
- Defined in:
- lib/kube/cluster/middleware/annotations.rb
Constant Summary collapse
- Middleware =
Kube::Cluster::Middleware
Instance Method Summary collapse
- #test_adds_annotations ⇒ Object
- #test_converts_values_to_strings ⇒ Object
- #test_preserves_existing_annotations ⇒ Object
- #test_resource_annotations_override_middleware_defaults ⇒ Object
Instance Method Details
#test_adds_annotations ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/kube/cluster/middleware/annotations.rb', line 45 def test_adds_annotations m = manifest(Kube::Cluster["ConfigMap"].new { .name = "test" }) Middleware::Annotations.new( "prometheus.io/scrape": "true", "prometheus.io/port": "9090", ).call(m) annotations = m.resources.first.to_h.dig(:metadata, :annotations) assert_equal "true", annotations[:"prometheus.io/scrape"] assert_equal "9090", annotations[:"prometheus.io/port"] end |
#test_converts_values_to_strings ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/kube/cluster/middleware/annotations.rb', line 84 def test_converts_values_to_strings m = manifest(Kube::Cluster["ConfigMap"].new { .name = "test" }) Middleware::Annotations.new("prometheus.io/port": 9090).call(m) annotations = m.resources.first.to_h.dig(:metadata, :annotations) assert_equal "9090", annotations[:"prometheus.io/port"] end |
#test_preserves_existing_annotations ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/kube/cluster/middleware/annotations.rb', line 71 def test_preserves_existing_annotations m = manifest(Kube::Cluster["ConfigMap"].new { .name = "test" .annotations = { "custom/annotation": "keep" } }) Middleware::Annotations.new("prometheus.io/scrape": "true").call(m) annotations = m.resources.first.to_h.dig(:metadata, :annotations) assert_equal "keep", annotations[:"custom/annotation"] assert_equal "true", annotations[:"prometheus.io/scrape"] end |
#test_resource_annotations_override_middleware_defaults ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/kube/cluster/middleware/annotations.rb', line 59 def test_resource_annotations_override_middleware_defaults m = manifest(Kube::Cluster["ConfigMap"].new { .name = "test" .annotations = { "prometheus.io/port": "8080" } }) Middleware::Annotations.new("prometheus.io/port": "9090").call(m) annotations = m.resources.first.to_h.dig(:metadata, :annotations) assert_equal "8080", annotations[:"prometheus.io/port"] end |