Skip to content

Commit

Permalink
fixup! Add feature support via @service
Browse files Browse the repository at this point in the history
  • Loading branch information
omus committed Sep 24, 2021
1 parent 44c7bf6 commit 9e6283d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utilities/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ function _process_service_features(args, defaults)
end
end

# Turn the feature dictionary into a `NamedTuple` expression
return Expr(:tuple, Expr(:parameters, [Expr(:kw, p...) for p in feature_dict]...))
# Turn the feature dictionary into a `NamedTuple` expression. Note: Julia 1.4 and below
# do not support `:((;))`.
nt = if !isempty(feature_dict)
Expr(:tuple, Expr(:parameters, [Expr(:kw, p...) for p in feature_dict]...))
else
:(NamedTuple())
end

return nt
end
6 changes: 6 additions & 0 deletions test/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@ end
default_feats = [:a => false]
@test_throws ArgumentError AWS._process_service_features(user_feats, default_feats)
end

@testset "no defaults" begin
user_feats = []
default_feats = []
@test AWS._process_service_features(user_feats, default_feats) == :(NamedTuple())
end
end

0 comments on commit 9e6283d

Please sign in to comment.