@@ -18,6 +18,7 @@ import (
18
18
"testing"
19
19
20
20
"github.com/google/go-cmp/cmp"
21
+ "github.com/scylladb/gemini/tableopts"
21
22
)
22
23
23
24
func TestSchemaConfigValidate (t * testing.T ) {
@@ -96,6 +97,11 @@ func TestSchemaConfigValidate(t *testing.T) {
96
97
}
97
98
}
98
99
100
+ func options (cql string ) []string {
101
+ opt , _ := tableopts .FromCQL (cql )
102
+ return []string {opt .ToCQL ()}
103
+ }
104
+
99
105
func TestGetCreateSchema (t * testing.T ) {
100
106
ks := Keyspace {Name : "ks1" }
101
107
tests := map [string ]struct {
@@ -111,11 +117,11 @@ func TestGetCreateSchema(t *testing.T) {
111
117
},
112
118
"single_partition_key_compact" : {
113
119
table : & Table {
114
- Name : "tbl0" ,
115
- PartitionKeys : createColumns (1 , "pk" ),
116
- CompactionStrategy : NewLeveledCompactionStrategy ( ),
120
+ Name : "tbl0" ,
121
+ PartitionKeys : createColumns (1 , "pk" ),
122
+ TableOptions : options ( "compaction = {'class':'LeveledCompactionStrategy','enabled':true,'tombstone_threshold':0.2,'tombstone_compaction_interval':86400,'sstable_size_in_mb':160}" ),
117
123
},
118
- want : "CREATE TABLE IF NOT EXISTS ks1.tbl0 (pk0 text, PRIMARY KEY ((pk0))) WITH compaction = {'class':'LeveledCompactionStrategy','enabled':true,'tombstone_threshold':0.2 ,'tombstone_compaction_interval':86400,'sstable_size_in_mb':160 };" ,
124
+ want : "CREATE TABLE IF NOT EXISTS ks1.tbl0 (pk0 text, PRIMARY KEY ((pk0))) WITH compaction = {'class':'LeveledCompactionStrategy','enabled':true,'sstable_size_in_mb':160 ,'tombstone_compaction_interval':86400,'tombstone_threshold':0.2 };" ,
119
125
},
120
126
"single_partition_key_single_column" : {
121
127
table : & Table {
@@ -151,12 +157,12 @@ func TestGetCreateSchema(t *testing.T) {
151
157
},
152
158
"single_partition_key_single_clustering_key_compact" : {
153
159
table : & Table {
154
- Name : "tbl0" ,
155
- PartitionKeys : createColumns (1 , "pk" ),
156
- ClusteringKeys : createColumns (1 , "ck" ),
157
- CompactionStrategy : NewLeveledCompactionStrategy ( ),
160
+ Name : "tbl0" ,
161
+ PartitionKeys : createColumns (1 , "pk" ),
162
+ ClusteringKeys : createColumns (1 , "ck" ),
163
+ TableOptions : options ( "compaction = {'class':'LeveledCompactionStrategy','enabled':true,'tombstone_threshold':0.2,'tombstone_compaction_interval':86400,'sstable_size_in_mb':160}" ),
158
164
},
159
- want : "CREATE TABLE IF NOT EXISTS ks1.tbl0 (pk0 text,ck0 text, PRIMARY KEY ((pk0), ck0)) WITH compaction = {'class':'LeveledCompactionStrategy','enabled':true,'tombstone_threshold':0.2 ,'tombstone_compaction_interval':86400,'sstable_size_in_mb':160 };" ,
165
+ want : "CREATE TABLE IF NOT EXISTS ks1.tbl0 (pk0 text,ck0 text, PRIMARY KEY ((pk0), ck0)) WITH compaction = {'class':'LeveledCompactionStrategy','enabled':true,'sstable_size_in_mb':160 ,'tombstone_compaction_interval':86400,'tombstone_threshold':0.2 };" ,
160
166
},
161
167
"single_partition_key_single_clustering_key_single_column" : {
162
168
table : & Table {
0 commit comments