Skip to content

Commit

Permalink
config: add ListValue on the PartitionConfig for the partition list r…
Browse files Browse the repository at this point in the history
…adondb#491

[summary]
add ListValue on the PartitionConfig to the partition list

[test case]
src/config/config_test.go

[patch codecov]
86.5%
  • Loading branch information
andyli029 committed Oct 31, 2019
1 parent 61723d6 commit 5da0520
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ type BackendsConfig struct {

// PartitionConfig tuple.
type PartitionConfig struct {
Table string `json:"table"`
Segment string `json:"segment"`
Backend string `json:"backend"`
Table string `json:"table"`
Segment string `json:"segment"`
Backend string `json:"backend"`
ListValue string `json:"listvalue"`
}

// AutoIncrement tuple.
Expand Down
22 changes: 22 additions & 0 deletions src/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,28 @@ func TestReadTableConfig(t *testing.T) {
assert.Equal(t, want, got)
}

func TestReadTableConfigList(t *testing.T) {
data := `{
"name": "L",
"shardtype": "",
"shardkey": "id",
"partitions": [
{
"table": "L1",
"segment": "",
"backend": "backend2",
"listvalue": "2"
}
]
}`

table, err := ReadTableConfig(data)
assert.Nil(t, err)
want := MockTablesConfig[2]
got := table
assert.Equal(t, want, got)
}

func TestRouterConfigUnmarshalJSON(t *testing.T) {
log := xlog.NewStdLog(xlog.Level(xlog.PANIC))
tmpDir := getTmpDir("", "radon_config_", log)
Expand Down
15 changes: 15 additions & 0 deletions src/config/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ var (
ShardKey: "id",
Partitions: MockPartitionBConfig,
},
&TableConfig{
Name: "L",
ShardKey: "id",
Partitions: MockPartitionLConfig,
},
}

// MockPartitionAConfig config.
Expand Down Expand Up @@ -73,6 +78,16 @@ var (
},
}

// MockPartitionLConfig.
MockPartitionLConfig = []*PartitionConfig{
&PartitionConfig{
Table: "L1",
Segment: "",
Backend: "backend2",
ListValue: "2",
},
}

// MockAutoIncrment.
MockAutoIncrment = &AutoIncrement{
Column: "autoincrement",
Expand Down

0 comments on commit 5da0520

Please sign in to comment.