spec/runners/crud/requirement.rb in mongo-2.15.0.alpha vs spec/runners/crud/requirement.rb in mongo-2.15.0
- old
+ new
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+# encoding: utf-8
+
module Mongo
module CRUD
class Requirement
- YAML_KEYS = %w(minServerVersion maxServerVersion topology topologies serverParameters).freeze
+ YAML_KEYS = %w(auth minServerVersion maxServerVersion topology topologies serverParameters serverless).freeze
def initialize(spec)
spec = spec.dup
# Legacy tests have the requirements mixed with other test fields
spec.delete('data')
@@ -32,15 +35,27 @@
end
else
nil
end
@server_parameters = spec['serverParameters']
+ @serverless = if serverless = spec['serverless']
+ case spec['serverless']
+ when 'require' then :require
+ when 'forbid' then :forbid
+ when 'allow' then :allow
+ else raise "Unknown serverless requirement: #{serverless}"
+ end
+ else
+ nil
+ end
+ @auth = spec['auth']
end
attr_reader :min_server_version
attr_reader :max_server_version
attr_reader :topologies
+ attr_reader :serverless
def short_min_server_version
if min_server_version
min_server_version.split('.')[0..1].join('.')
else
@@ -81,9 +96,21 @@
else
ok = false
end
end
end
+ end
+ if @serverless
+ if SpecConfig.instance.serverless?
+ ok = ok && [:allow, :require].include?(serverless)
+ else
+ ok = ok && [:allow, :forbid].include?(serverless)
+ end
+ end
+ if @auth == true
+ ok &&= cc.auth_enabled?
+ elsif @auth == false
+ ok &&= !cc.auth_enabled?
end
ok
end
def description