Skip to content

Commit

Permalink
Fix reconcile logic
Browse files Browse the repository at this point in the history
  • Loading branch information
drichelson committed May 26, 2024
1 parent 00100b4 commit eebd11e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion internal/dorkly/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,12 @@ func reconcile(old, new RelayArchive) (RelayArchive, error) {
newFlag.Version++
logger.With("env", envKey).With("flag", flagKey).
Infof("Found modified flag. Version %d->%d", oldFlag.Version, newFlag.Version)
newEnv.data.Flags[flagKey] = newFlag
shouldChangeDataId = true
} else {
logger.With("env", envKey).With("flag", flagKey).With("version", newFlag.Version).
Infof("Found existing unchanged flag")
}
newEnv.data.Flags[flagKey] = newFlag
}

if shouldChangeDataId {
Expand Down
16 changes: 8 additions & 8 deletions internal/dorkly/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func Test_Reconcile(t *testing.T) {
env(env("staging").version(1).dataId(1).
flag(booleanFlag("flag1").variation(false).version(1))),
new: relayArchive().
env(env("staging").version(1).dataId(1).
flag(booleanFlag("flag1").variation(false).version(1))),
env(env("staging").
flag(booleanFlag("flag1").variation(false))),
expected: relayArchive().
env(env("staging").version(1).dataId(1).
flag(booleanFlag("flag1").variation(false).version(1))),
Expand All @@ -34,8 +34,8 @@ func Test_Reconcile(t *testing.T) {
env(env("staging").version(1).dataId(1).
flag(booleanFlag("flag1").variation(false).version(1))),
new: relayArchive().
env(env("staging").version(1).dataId(1).
flag(booleanFlag("flag1").variation(true).version(1))),
env(env("staging").
flag(booleanFlag("flag1").variation(true))),
expected: relayArchive().
env(env("staging").version(1).dataId(2).
flag(booleanFlag("flag1").variation(true).version(2))),
Expand All @@ -47,9 +47,9 @@ func Test_Reconcile(t *testing.T) {
env(env("staging").version(1).dataId(1).
flag(booleanFlag("flag1").variation(false).version(1))),
new: relayArchive().
env(env("staging").version(1).dataId(1).
flag(booleanFlag("flag1").variation(false).version(1)).
flag(booleanFlag("flag2").variation(true).version(1)),
env(env("staging").
flag(booleanFlag("flag1").variation(false)).
flag(booleanFlag("flag2").variation(true)),
),
expected: relayArchive().
env(env("staging").version(1).dataId(2).
Expand All @@ -64,7 +64,7 @@ func Test_Reconcile(t *testing.T) {
env(env("staging").version(1).dataId(1).
flag(booleanFlag("flag1").variation(false).version(1))),
new: relayArchive().
env(env("staging").version(1).dataId(1)),
env(env("staging").version(1)),
expected: relayArchive().
env(env("staging").version(1).dataId(2).
flag(booleanFlag("flag1").variation(false).version(2).deleted(true))),
Expand Down

0 comments on commit eebd11e

Please sign in to comment.