|
6 | 6 | { |
7 | 7 | "bool" => true, |
8 | 8 | "str" => "testing", |
9 | | - "num" => 1, |
| 9 | + "int" => 1, |
| 10 | + "float" => 1.0, |
10 | 11 | "struct" => {"more" => "config"} |
11 | 12 | } |
12 | 13 | ) |
|
103 | 104 | describe "#fetch_number_value" do |
104 | 105 | context "when flag is found" do |
105 | 106 | context "when type matches" do |
106 | | - it "returns value as static" do |
107 | | - fetched = provider.fetch_number_value(flag_key: "num", default_value: 0) |
| 107 | + it "returns int as static" do |
| 108 | + fetched = provider.fetch_number_value(flag_key: "int", default_value: 0) |
108 | 109 |
|
109 | 110 | expect(fetched.value).to eq(1) |
110 | 111 | expect(fetched.reason).to eq(OpenFeature::SDK::Provider::Reason::STATIC) |
111 | 112 | end |
| 113 | + it "returns float as static" do |
| 114 | + fetched = provider.fetch_number_value(flag_key: "float", default_value: 0.0) |
| 115 | + |
| 116 | + expect(fetched.value).to eq(1.0) |
| 117 | + expect(fetched.reason).to eq(OpenFeature::SDK::Provider::Reason::STATIC) |
| 118 | + end |
112 | 119 | end |
113 | 120 |
|
114 | 121 | context "when type does not match" do |
|
133 | 140 | end |
134 | 141 | end |
135 | 142 |
|
| 143 | + describe "#fetch_integer_value" do |
| 144 | + context "when flag is found" do |
| 145 | + context "when type matches" do |
| 146 | + it "returns value as static" do |
| 147 | + fetched = provider.fetch_integer_value(flag_key: "int", default_value: 0) |
| 148 | + |
| 149 | + expect(fetched.value).to eq(1) |
| 150 | + expect(fetched.reason).to eq(OpenFeature::SDK::Provider::Reason::STATIC) |
| 151 | + end |
| 152 | + end |
| 153 | + |
| 154 | + context "when type does not match" do |
| 155 | + it "returns default as type mismatch" do |
| 156 | + fetched = provider.fetch_integer_value(flag_key: "float", default_value: 0) |
| 157 | + |
| 158 | + expect(fetched.value).to eq(0) |
| 159 | + expect(fetched.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::TYPE_MISMATCH) |
| 160 | + expect(fetched.reason).to eq(OpenFeature::SDK::Provider::Reason::ERROR) |
| 161 | + end |
| 162 | + end |
| 163 | + end |
| 164 | + |
| 165 | + context "when flag is not found" do |
| 166 | + it "returns default as flag not found" do |
| 167 | + fetched = provider.fetch_number_value(flag_key: "not here", default_value: 0) |
| 168 | + |
| 169 | + expect(fetched.value).to eq(0) |
| 170 | + expect(fetched.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::FLAG_NOT_FOUND) |
| 171 | + expect(fetched.reason).to eq(OpenFeature::SDK::Provider::Reason::ERROR) |
| 172 | + end |
| 173 | + end |
| 174 | + end |
| 175 | + |
| 176 | + describe "#fetch_integer_value" do |
| 177 | + context "when flag is found" do |
| 178 | + context "when type matches" do |
| 179 | + it "returns value as static" do |
| 180 | + fetched = provider.fetch_float_value(flag_key: "float", default_value: 0.0) |
| 181 | + |
| 182 | + expect(fetched.value).to eq(1.0) |
| 183 | + expect(fetched.reason).to eq(OpenFeature::SDK::Provider::Reason::STATIC) |
| 184 | + end |
| 185 | + end |
| 186 | + |
| 187 | + context "when type does not match" do |
| 188 | + it "returns default as type mismatch" do |
| 189 | + fetched = provider.fetch_float_value(flag_key: "int", default_value: 0.0) |
| 190 | + |
| 191 | + expect(fetched.value).to eq(0) |
| 192 | + expect(fetched.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::TYPE_MISMATCH) |
| 193 | + expect(fetched.reason).to eq(OpenFeature::SDK::Provider::Reason::ERROR) |
| 194 | + end |
| 195 | + end |
| 196 | + end |
| 197 | + |
| 198 | + context "when flag is not found" do |
| 199 | + it "returns default as flag not found" do |
| 200 | + fetched = provider.fetch_number_value(flag_key: "not here", default_value: 0) |
| 201 | + |
| 202 | + expect(fetched.value).to eq(0) |
| 203 | + expect(fetched.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::FLAG_NOT_FOUND) |
| 204 | + expect(fetched.reason).to eq(OpenFeature::SDK::Provider::Reason::ERROR) |
| 205 | + end |
| 206 | + end |
| 207 | + end |
| 208 | + |
136 | 209 | describe "#fetch_object_value" do |
137 | 210 | context "when flag is found" do |
138 | 211 | context "when type matches" do |
|
146 | 219 |
|
147 | 220 | context "when type does not match" do |
148 | 221 | it "returns default as type mismatch" do |
149 | | - fetched = provider.fetch_object_value(flag_key: "num", default_value: {}) |
| 222 | + fetched = provider.fetch_object_value(flag_key: "int", default_value: {}) |
150 | 223 |
|
151 | 224 | expect(fetched.value).to eq({}) |
152 | 225 | expect(fetched.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::TYPE_MISMATCH) |
|
0 commit comments