Skip to content

Commit

Permalink
fix(typedef): fix wrong error condition
Browse files Browse the repository at this point in the history
*fix wrong error condition
*rename validation schema errors
  • Loading branch information
illia-li committed Jun 21, 2023
1 parent 4c07350 commit 4a7f50b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions pkg/typedef/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package typedef
import "github.com/pkg/errors"

var (
ErrSchemaConfigInvalidPK = errors.New("max number of partition keys must be bigger than min number of partition keys")
ErrSchemaConfigInvalidCK = errors.New("max number of clustering keys must be bigger than min number of clustering keys")
ErrSchemaConfigInvalidCols = errors.New("max number of columns must be bigger than min number of columns")
ErrSchemaConfigInvalidRangePK = errors.New("max number of partition keys must be bigger than min number of partition keys")
ErrSchemaConfigInvalidRangeCK = errors.New("max number of clustering keys must be bigger than min number of clustering keys")
ErrSchemaConfigInvalidRangeCols = errors.New("max number of columns must be bigger than min number of columns")
)
12 changes: 6 additions & 6 deletions pkg/typedef/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestSchemaConfigValidate(t *testing.T) {
}{
"empty": {
config: &SchemaConfig{},
want: ErrSchemaConfigInvalidPK,
want: ErrSchemaConfigInvalidRangePK,
},
"valid": {
config: &SchemaConfig{
Expand All @@ -46,14 +46,14 @@ func TestSchemaConfigValidate(t *testing.T) {
MaxPartitionKeys: 2,
MinPartitionKeys: 3,
},
want: ErrSchemaConfigInvalidPK,
want: ErrSchemaConfigInvalidRangePK,
},
"ck_missing": {
config: &SchemaConfig{
MaxPartitionKeys: 3,
MinPartitionKeys: 2,
},
want: ErrSchemaConfigInvalidCK,
want: ErrSchemaConfigInvalidRangeCK,
},
"min_ck_gt_than_max_ck": {
config: &SchemaConfig{
Expand All @@ -62,7 +62,7 @@ func TestSchemaConfigValidate(t *testing.T) {
MaxClusteringKeys: 2,
MinClusteringKeys: 3,
},
want: ErrSchemaConfigInvalidCK,
want: ErrSchemaConfigInvalidRangeCK,
},
"columns_missing": {
config: &SchemaConfig{
Expand All @@ -71,7 +71,7 @@ func TestSchemaConfigValidate(t *testing.T) {
MaxClusteringKeys: 3,
MinClusteringKeys: 2,
},
want: ErrSchemaConfigInvalidCols,
want: ErrSchemaConfigInvalidRangeCols,
},
"min_cols_gt_than_max_cols": {
config: &SchemaConfig{
Expand All @@ -82,7 +82,7 @@ func TestSchemaConfigValidate(t *testing.T) {
MaxColumns: 2,
MinColumns: 3,
},
want: ErrSchemaConfigInvalidCols,
want: ErrSchemaConfigInvalidRangeCols,
},
}
cmp.AllowUnexported()
Expand Down
8 changes: 4 additions & 4 deletions pkg/typedef/schemaconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ type SchemaConfig struct {

func (sc *SchemaConfig) Valid() error {
if sc.MaxPartitionKeys <= sc.MinPartitionKeys {
return ErrSchemaConfigInvalidPK
return ErrSchemaConfigInvalidRangePK
}
if sc.MaxClusteringKeys <= sc.MinClusteringKeys {
return ErrSchemaConfigInvalidCK
return ErrSchemaConfigInvalidRangeCK
}
if sc.MaxColumns <= sc.MinClusteringKeys {
return ErrSchemaConfigInvalidCols
if sc.MaxColumns <= sc.MinColumns {
return ErrSchemaConfigInvalidRangeCols
}
return nil
}
Expand Down

0 comments on commit 4a7f50b

Please sign in to comment.