Class: EndpointTest

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/kube/helm/endpoint.rb

Instance Method Summary collapse

Instance Method Details

#test_equalityObject



149
150
151
152
153
# File 'lib/kube/helm/endpoint.rb', line 149

def test_equality
  a = Kube::Helm::Endpoint.new("https://charts.example.com")
  b = Kube::Helm::Endpoint.new("https://charts.example.com")
  assert_equal a, b
end

#test_http_chart_ref_raises_without_repo_nameObject



127
128
129
130
# File 'lib/kube/helm/endpoint.rb', line 127

def test_http_chart_ref_raises_without_repo_name
  endpoint = Kube::Helm::Endpoint.new("https://charts.bitnami.com/bitnami")
  assert_raises(ArgumentError) { endpoint.chart_ref("nginx") }
end

#test_http_chart_ref_with_repo_nameObject



122
123
124
125
# File 'lib/kube/helm/endpoint.rb', line 122

def test_http_chart_ref_with_repo_name
  endpoint = Kube::Helm::Endpoint.new("https://charts.bitnami.com/bitnami")
  assert_equal "bitnami/nginx", endpoint.chart_ref("nginx", repo_name: "bitnami")
end

#test_http_endpoint_not_ociObject



93
94
95
96
# File 'lib/kube/helm/endpoint.rb', line 93

def test_http_endpoint_not_oci
  endpoint = Kube::Helm::Endpoint.new("https://charts.bitnami.com/bitnami")
  refute endpoint.oci?
end

#test_http_requires_addObject



105
106
107
108
# File 'lib/kube/helm/endpoint.rb', line 105

def test_http_requires_add
  endpoint = Kube::Helm::Endpoint.new("https://charts.bitnami.com/bitnami")
  assert endpoint.requires_add?
end

#test_inequalityObject



155
156
157
158
159
# File 'lib/kube/helm/endpoint.rb', line 155

def test_inequality
  a = Kube::Helm::Endpoint.new("https://charts.example.com")
  b = Kube::Helm::Endpoint.new("oci://ghcr.io/my-org/charts")
  refute_equal a, b
end

#test_oci_chart_refObject

── chart_ref ──────────────────────────────────────────────────────────



112
113
114
115
# File 'lib/kube/helm/endpoint.rb', line 112

def test_oci_chart_ref
  endpoint = Kube::Helm::Endpoint.new("oci://ghcr.io/my-org/charts")
  assert_equal "oci://ghcr.io/my-org/charts/nginx", endpoint.chart_ref("nginx")
end

#test_oci_chart_ref_strips_trailing_slashObject



117
118
119
120
# File 'lib/kube/helm/endpoint.rb', line 117

def test_oci_chart_ref_strips_trailing_slash
  endpoint = Kube::Helm::Endpoint.new("oci://ghcr.io/my-org/charts/")
  assert_equal "oci://ghcr.io/my-org/charts/nginx", endpoint.chart_ref("nginx")
end

#test_oci_does_not_require_addObject

── requires_add? ─────────────────────────────────────────────────────



100
101
102
103
# File 'lib/kube/helm/endpoint.rb', line 100

def test_oci_does_not_require_add
  endpoint = Kube::Helm::Endpoint.new("oci://ghcr.io/my-org/charts")
  refute endpoint.requires_add?
end

#test_oci_endpoint_detectedObject

── OCI detection ──────────────────────────────────────────────────────



88
89
90
91
# File 'lib/kube/helm/endpoint.rb', line 88

def test_oci_endpoint_detected
  endpoint = Kube::Helm::Endpoint.new("oci://ghcr.io/my-org/charts")
  assert endpoint.oci?
end

#test_raises_on_empty_urlObject

── validation ─────────────────────────────────────────────────────────



134
135
136
# File 'lib/kube/helm/endpoint.rb', line 134

def test_raises_on_empty_url
  assert_raises(ArgumentError) { Kube::Helm::Endpoint.new("") }
end

#test_raises_on_non_string_urlObject



138
139
140
# File 'lib/kube/helm/endpoint.rb', line 138

def test_raises_on_non_string_url
  assert_raises(ArgumentError) { Kube::Helm::Endpoint.new(nil) }
end

#test_to_s_returns_urlObject

── to_s / equality ───────────────────────────────────────────────────



144
145
146
147
# File 'lib/kube/helm/endpoint.rb', line 144

def test_to_s_returns_url
  endpoint = Kube::Helm::Endpoint.new("https://charts.example.com")
  assert_equal "https://charts.example.com", endpoint.to_s
end