Skip to content

Commit

Permalink
[243] fix error name and msg
Browse files Browse the repository at this point in the history
  • Loading branch information
zipofar committed Jul 24, 2023
1 parent ba2d34f commit fcaf94c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/uffizzi/services/kubeconfig_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
require 'psych'

class KubeconfigService
class Invalid < StandardError
class InvalidKubeconfigError < StandardError
def initialize(file_path)
msg = "Kubeconfig is invalid by path '#{file_path}'"
msg = "Invalid kubeconfig at path '#{file_path}'"

super(msg)
end
Expand Down Expand Up @@ -46,7 +46,7 @@ def save_to_filepath(filepath, kubeconfig)
target_kubeconfig = File.exist?(real_file_path) ? Psych.safe_load(File.read(real_file_path)) : nil

if target_kubeconfig.present? && !valid_kubeconfig?(target_kubeconfig)
raise Invalid.new(filepath)
raise InvalidKubeconfigError.new(filepath)
end

new_kubeconfig = block_given? ? yield(target_kubeconfig) : merge(target_kubeconfig, kubeconfig)
Expand Down
4 changes: 2 additions & 2 deletions test/uffizzi/cli/cluster_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ def test_update_kubeconfig_if_kubeconfig_path_has_invalid_file

File.write(@kubeconfig_path, kubeconfig_from_filesystem)

error = assert_raises(KubeconfigService::Invalid) do
error = assert_raises(KubeconfigService::InvalidKubeconfigError) do
@cluster.update_kubeconfig
end

assert_requested(stubbed_uffizzi_cluster_get_request)
assert_match('is invalid', error.message)
assert_match('Invalid kubeconfig', error.message)
end

def test_describe_cluster
Expand Down

0 comments on commit fcaf94c

Please sign in to comment.