github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/pkg/chunk/cassandra/table_client_test.go (about) 1 package cassandra 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestTableClient_getCreateTableQuery_default(t *testing.T) { 11 client := &tableClient{ 12 cfg: Config{}, 13 } 14 desc, _, _ := client.DescribeTable(context.Background(), "test_table") 15 query := client.getCreateTableQuery(&desc) 16 assert.Equal( 17 t, 18 ` 19 CREATE TABLE IF NOT EXISTS test_table ( 20 hash text, 21 range blob, 22 value blob, 23 PRIMARY KEY (hash, range) 24 )`, 25 query, 26 ) 27 } 28 29 func TestTableClient_getCreateTableQuery_withOptions(t *testing.T) { 30 client := &tableClient{ 31 cfg: Config{ 32 TableOptions: "CLUSTERING ORDER BY (range DESC) AND compaction = { 'class' : 'LeveledCompactionStrategy' }", 33 }, 34 } 35 desc, _, _ := client.DescribeTable(context.Background(), "test_table") 36 query := client.getCreateTableQuery(&desc) 37 assert.Equal( 38 t, 39 ` 40 CREATE TABLE IF NOT EXISTS test_table ( 41 hash text, 42 range blob, 43 value blob, 44 PRIMARY KEY (hash, range) 45 ) WITH CLUSTERING ORDER BY (range DESC) AND compaction = { 'class' : 'LeveledCompactionStrategy' }`, 46 query, 47 ) 48 }