Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
yurishkuro committed Nov 30, 2024
1 parent a238455 commit cc9db9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions plugin/storage/cassandra/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ type templateParams struct {
DependenciesTTLInSeconds int64
}

type SchemaCreator struct {
type Creator struct {
session cassandra.Session
schema config.Schema
}

// NewSchemaCreator returns a new SchemaCreator
func NewSchemaCreator(session cassandra.Session, schema config.Schema) *SchemaCreator {
return &SchemaCreator{
func NewSchemaCreator(session cassandra.Session, schema config.Schema) *Creator {
return &Creator{
session: session,
schema: schema,
}

Check warning on line 44 in plugin/storage/cassandra/schema/schema.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/cassandra/schema/schema.go#L40-L44

Added lines #L40 - L44 were not covered by tests
}

func (sc *SchemaCreator) constructTemplateParams() templateParams {
func (sc *Creator) constructTemplateParams() templateParams {
return templateParams{
Keyspace: sc.schema.Keyspace,
Replication: fmt.Sprintf("{'class': 'NetworkTopologyStrategy', 'replication_factor': '%v' }", sc.schema.ReplicationFactor),
Expand All @@ -54,7 +54,7 @@ func (sc *SchemaCreator) constructTemplateParams() templateParams {
}

Check warning on line 54 in plugin/storage/cassandra/schema/schema.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/cassandra/schema/schema.go#L47-L54

Added lines #L47 - L54 were not covered by tests
}

func (*SchemaCreator) getQueryFileAsBytes(fileName string, params templateParams) ([]byte, error) {
func (*Creator) getQueryFileAsBytes(fileName string, params templateParams) ([]byte, error) {
tmpl, err := template.ParseFS(schemaFile, fileName)
if err != nil {
return nil, err
Expand All @@ -69,7 +69,7 @@ func (*SchemaCreator) getQueryFileAsBytes(fileName string, params templateParams
return result.Bytes(), nil

Check warning on line 69 in plugin/storage/cassandra/schema/schema.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/cassandra/schema/schema.go#L69

Added line #L69 was not covered by tests
}

func (*SchemaCreator) getQueriesFromBytes(queryFile []byte) ([]string, error) {
func (*Creator) getQueriesFromBytes(queryFile []byte) ([]string, error) {
lines := bytes.Split(queryFile, []byte("\n"))

var extractedLines [][]byte
Expand Down Expand Up @@ -110,7 +110,7 @@ func (*SchemaCreator) getQueriesFromBytes(queryFile []byte) ([]string, error) {
return queries, nil
}

func (sc *SchemaCreator) getCassandraQueriesFromQueryStrings(queries []string) []cassandra.Query {
func (sc *Creator) getCassandraQueriesFromQueryStrings(queries []string) []cassandra.Query {
var casQueries []cassandra.Query

for _, query := range queries {
Expand All @@ -120,7 +120,7 @@ func (sc *SchemaCreator) getCassandraQueriesFromQueryStrings(queries []string) [
return casQueries

Check warning on line 120 in plugin/storage/cassandra/schema/schema.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/cassandra/schema/schema.go#L120

Added line #L120 was not covered by tests
}

func (sc *SchemaCreator) contructSchemaQueries() ([]cassandra.Query, error) {
func (sc *Creator) contructSchemaQueries() ([]cassandra.Query, error) {
params := sc.constructTemplateParams()

queryFile, err := sc.getQueryFileAsBytes(`v004-go-tmpl.cql.tmpl`, params)
Expand All @@ -138,7 +138,7 @@ func (sc *SchemaCreator) contructSchemaQueries() ([]cassandra.Query, error) {
return casQueries, nil

Check warning on line 138 in plugin/storage/cassandra/schema/schema.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/cassandra/schema/schema.go#L136-L138

Added lines #L136 - L138 were not covered by tests
}

func (sc *SchemaCreator) CreateSchemaIfNotPresent() error {
func (sc *Creator) CreateSchemaIfNotPresent() error {
casQueries, err := sc.contructSchemaQueries()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions plugin/storage/cassandra/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ query1-finished;
`,
}

sc := SchemaCreator{}
sc := Creator{}
queriesAsBytes := []byte(queriesAsString)
queries, err := sc.getQueriesFromBytes(queriesAsBytes)
require.NoError(t, err)
Expand All @@ -52,7 +52,7 @@ func TestInvalidQueryTemplate(t *testing.T) {
query2;
query-3 query-3-continue query-3-finished -- missing semicolon
`
sc := SchemaCreator{}
sc := Creator{}
queriesAsBytes := []byte(queriesAsString)
_, err := sc.getQueriesFromBytes(queriesAsBytes)
require.Error(t, err)
Expand Down

0 comments on commit cc9db9c

Please sign in to comment.