Extract a default_svc_member function for tests
@@ -748,6 +748,37 @@ two = 2
////////////////////////////////////////////////////////////////////////
+ /// Create a basic SvcMember struct for use in tests
+ fn default_svc_member<'a>() -> SvcMember<'a> {
+ let ident = PackageIdent::new("core", "test_pkg", Some("1.0.0"), Some("20180321150416"));
+ SvcMember {
+ member_id: Cow::Owned("MEMBER_ID".into()),
+ pkg: Cow::Owned(Some(ident)),
+ application: Cow::Owned(None),
+ environment: Cow::Owned(None),
+ service: Cow::Owned("foo".into()),
+ group: Cow::Owned("default".into()),
+ org: Cow::Owned(None),
+ persistent: Cow::Owned(true),
+ leader: Cow::Owned(false),
+ follower: Cow::Owned(false),
+ update_leader: Cow::Owned(false),
+ update_follower: Cow::Owned(false),
+ election_is_running: Cow::Owned(false),
+ election_is_no_quorum: Cow::Owned(false),
+ election_is_finished: Cow::Owned(false),
+ update_election_is_running: Cow::Owned(false),
+ update_election_is_no_quorum: Cow::Owned(false),
+ update_election_is_finished: Cow::Owned(false),
+ sys: Cow::Owned(SysInfo::new()),
+ alive: Cow::Owned(true),
+ suspect: Cow::Owned(false),
+ confirmed: Cow::Owned(false),
+ departed: Cow::Owned(false),
+ cfg: Cow::Owned(BTreeMap::new() as toml::value::Table),
+ }
+ }
+
/// Just create a basic RenderContext that could be used in tests.
///
/// If you want to modify parts of it, it's easier to change
@@ -817,38 +848,13 @@ two = 2
let (_tmp_dir, test_pkg) = new_test_pkg();
let cfg = Cfg::new(&test_pkg, None).expect("create config");
- let sys_info = SysInfo::new();
-
// TODO (CM): just create a toml table directly
let mut svc_member_cfg = BTreeMap::new();
svc_member_cfg.insert("foo".into(), "bar".into());
- let me = SvcMember {
- member_id: Cow::Owned("MEMBER_ID".into()),
- pkg: Cow::Owned(Some(ident.clone())),
- application: Cow::Owned(None),
- environment: Cow::Owned(None),
- service: Cow::Owned("foo".into()),
- group: Cow::Owned("default".into()),
- org: Cow::Owned(None),
- persistent: Cow::Owned(true),
- leader: Cow::Owned(false),
- follower: Cow::Owned(false),
- update_leader: Cow::Owned(false),
- update_follower: Cow::Owned(false),
- election_is_running: Cow::Owned(false),
- election_is_no_quorum: Cow::Owned(false),
- election_is_finished: Cow::Owned(false),
- update_election_is_running: Cow::Owned(false),
- update_election_is_no_quorum: Cow::Owned(false),
- update_election_is_finished: Cow::Owned(false),
- sys: Cow::Owned(sys_info),
- alive: Cow::Owned(true),
- suspect: Cow::Owned(false),
- confirmed: Cow::Owned(false),
- departed: Cow::Owned(false),
- cfg: Cow::Owned(svc_member_cfg as toml::value::Table),
- };
+ let mut me = default_svc_member();
+ me.pkg = Cow::Owned(Some(ident.clone()));
+ me.cfg = Cow::Owned(svc_member_cfg as toml::value::Table);
let svc = Svc {
service_group: Cow::Owned(group),
