-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gemini: invalid strategy unmarshaling fixed
- Loading branch information
Henrik Johansson
committed
Feb 12, 2020
1 parent
cf3e043
commit 2ff1a4c
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/scylladb/gemini/replication" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
|
||
"go.uber.org/zap" | ||
) | ||
|
||
func TestGetReplicationStrategy(t *testing.T) { | ||
var tests = map[string]struct { | ||
strategy string | ||
expected string | ||
}{ | ||
"simple strategy": { | ||
strategy: "{\"class\": \"SimpleStrategy\", \"replication_factor\": \"1\"}", | ||
expected: "{'class':'SimpleStrategy','replication_factor':'1'}", | ||
}, | ||
"simple strategy single quotes": { | ||
strategy: "{'class': 'SimpleStrategy', 'replication_factor': '1'}", | ||
expected: "{'class':'SimpleStrategy','replication_factor':'1'}", | ||
}, | ||
"network topology strategy": { | ||
strategy: "{\"class\": \"NetworkTopologyStrategy\", \"dc1\": 3, \"dc2\": 3}", | ||
expected: "{'class':'NetworkTopologyStrategy','dc1':3,'dc2':3}", | ||
}, | ||
"network topology strategy single quotes": { | ||
strategy: "{'class': 'NetworkTopologyStrategy', 'dc1': 3, 'dc2': 3}", | ||
expected: "{'class':'NetworkTopologyStrategy','dc1':3,'dc2':3}", | ||
}, | ||
} | ||
logger := zap.NewNop() | ||
fallback := replication.NewSimpleStrategy() | ||
for name, tc := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
got := getReplicationStrategy(tc.strategy, fallback, logger) | ||
if diff := cmp.Diff(got.ToCQL(), tc.expected); diff != "" { | ||
t.Errorf("expected=%s, got=%s,diff=%s", tc.strategy, got.ToCQL(), diff) | ||
} | ||
}) | ||
} | ||
} |