* Updated `FeatureFlagResolverConfigurationProtocol`’s requirements to make `stores` mutable * Updated `FeatureFlagResolverConfiguration` to conform to the updated `FeatureFlagResolverConfigurationProtocol` * Removed `MutableFeatureFlagResolverConfiguration` * Updated `FeatureFlagResolverConfigurationTests`
This commit is contained in:
parent
1dc68457e2
commit
15312f5273
|
@ -12,10 +12,10 @@ import YMFFProtocols
|
||||||
|
|
||||||
// MARK: - FeatureFlagResolverConfiguration
|
// MARK: - FeatureFlagResolverConfiguration
|
||||||
|
|
||||||
/// A YMFF-supplied object used to provide the feature flag resolver with its configuration.
|
/// An object used to configure the resolver.
|
||||||
public struct FeatureFlagResolverConfiguration {
|
final public class FeatureFlagResolverConfiguration {
|
||||||
|
|
||||||
public let stores: [FeatureFlagStore]
|
public var stores: [FeatureFlagStore]
|
||||||
|
|
||||||
public init(stores: [FeatureFlagStore]) {
|
public init(stores: [FeatureFlagStore]) {
|
||||||
self.stores = stores
|
self.stores = stores
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
//
|
|
||||||
// MutableFeatureFlagResolverConfiguration.swift
|
|
||||||
// YMFF
|
|
||||||
//
|
|
||||||
// Created by Yakov Manshin on 5/17/21.
|
|
||||||
// Copyright © 2021 Yakov Manshin. See the LICENSE file for license info.
|
|
||||||
//
|
|
||||||
|
|
||||||
#if !COCOAPODS
|
|
||||||
import YMFFProtocols
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// MARK: - MutableFeatureFlagResolverConfiguration
|
|
||||||
|
|
||||||
/// An object used to configure the resolver, which holds feature flag stores that can be changed.
|
|
||||||
final public class MutableFeatureFlagResolverConfiguration {
|
|
||||||
|
|
||||||
public var stores: [FeatureFlagStore]
|
|
||||||
|
|
||||||
public init(stores: [FeatureFlagStore]) {
|
|
||||||
self.stores = stores
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - FeatureFlagResolverConfigurationProtocol
|
|
||||||
|
|
||||||
extension MutableFeatureFlagResolverConfiguration: FeatureFlagResolverConfigurationProtocol { }
|
|
|
@ -7,12 +7,12 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
/// An object that provides the resources critical to functioning of the resolver.
|
/// An object that provides the resources critical to functioning of the resolver.
|
||||||
public protocol FeatureFlagResolverConfigurationProtocol {
|
public protocol FeatureFlagResolverConfigurationProtocol: AnyObject {
|
||||||
|
|
||||||
/// An array of stores which may contain feature flag values.
|
/// An array of stores which may contain feature flag values.
|
||||||
///
|
///
|
||||||
/// + The array may include both mutable and immutable stores.
|
/// + The array may include both mutable and immutable stores.
|
||||||
/// + The stores are examined in order. The first value found for a key will be used.
|
/// + The stores are examined in order. The first value found for a key will be used.
|
||||||
var stores: [FeatureFlagStore] { get }
|
var stores: [FeatureFlagStore] { get set }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ import XCTest
|
||||||
|
|
||||||
final class FeatureFlagResolverConfigurationTests: XCTestCase {
|
final class FeatureFlagResolverConfigurationTests: XCTestCase {
|
||||||
|
|
||||||
func testStoreAdditionToMutableConfiguration() {
|
func testStoreAdditionToConfiguration() {
|
||||||
let configuration = MutableFeatureFlagResolverConfiguration(stores: [])
|
let configuration = FeatureFlagResolverConfiguration(stores: [])
|
||||||
|
|
||||||
XCTAssertEqual(configuration.stores.count, 0)
|
XCTAssertEqual(configuration.stores.count, 0)
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ final class FeatureFlagResolverConfigurationTests: XCTestCase {
|
||||||
XCTAssertEqual(configuration.stores.count, 1)
|
XCTAssertEqual(configuration.stores.count, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testStoreRemovalFromMutableConfiguration() {
|
func testStoreRemovalFromConfiguration() {
|
||||||
let configuration = MutableFeatureFlagResolverConfiguration(stores: [.immutable(TransparentFeatureFlagStore())])
|
let configuration = FeatureFlagResolverConfiguration(stores: [.immutable(TransparentFeatureFlagStore())])
|
||||||
|
|
||||||
XCTAssertEqual(configuration.stores.count, 1)
|
XCTAssertEqual(configuration.stores.count, 1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue