Skip to content

Commit

Permalink
Correct naming and remove spare comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kaarolch committed May 23, 2024
1 parent 2725886 commit 24f007d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/kennel/models/slo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Slo < Record
thresholds: []
}.freeze

settings :type, :description, :thresholds, :query, :tags, :monitor_ids, :monitor_tags, :name, :groups, :sliSpecification
settings :type, :description, :thresholds, :query, :tags, :monitor_ids, :monitor_tags, :name, :groups, :sli_specification

defaults(
tags: -> { @project.tags },
Expand All @@ -35,8 +35,8 @@ def build_json
type: type
)

if type == 'time_slice' && v = sliSpecification
data[:sliSpecification] = v
if type == 'time_slice'
data[:sliSpecification] = :sli_specification
elsif v = query
data[:query] = v
end
Expand Down
4 changes: 1 addition & 3 deletions test/kennel/models/slo_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ class TestSlo < Kennel::Models::Slo

def slo(options = {})
Kennel::Models::Slo.new(
# Determine the type from options or default to "metric"
type = options[:type] || "metric"
options.delete(:project) || project,
slo_options ={
type: -> { type },
name: -> { "Foo" },
kennel_id: -> { "m1" }
}
# Conditionally include sliSpecification if type is "time_slice"
slo_options[:sliSpecification] = -> { options[:sliSpecification] } if type == "time_slice"
Kennel::Models::Slo.new(project, slo_options.merge(options))
)
Expand Down Expand Up @@ -85,7 +83,7 @@ def slo(options = {})

expected_basic_json[:sliSpecification] = sli_spec
assert_json_equal(
slo(type: "time_slice", sliSpecification: sli_spec).build_json,
slo(type: "time_slice", sli_specification: sli_spec).build_json,
expected_basic_json
)
end
Expand Down

0 comments on commit 24f007d

Please sign in to comment.