lint: convert snake to camel case
This commit is contained in:
@@ -114,8 +114,8 @@ var Checks = []Check{
|
||||
}
|
||||
|
||||
// Check if target column is a primary key
|
||||
for _, target_col := range s.Tables[column.ForeignKeyTargetTable].Columns {
|
||||
if target_col.Name == column.ForeignKeyTargetColumn && target_col.IsPrimaryKey {
|
||||
for _, targetCol := range s.Tables[column.ForeignKeyTargetTable].Columns {
|
||||
if targetCol.Name == column.ForeignKeyTargetColumn && targetCol.IsPrimaryKey {
|
||||
continue fk_loop
|
||||
}
|
||||
}
|
||||
@@ -125,8 +125,8 @@ var Checks = []Check{
|
||||
if idx.TableName != column.ForeignKeyTargetTable {
|
||||
continue
|
||||
}
|
||||
for _, idx_col_name := range idx.Columns {
|
||||
if column.ForeignKeyTargetColumn == idx_col_name {
|
||||
for _, idxColName := range idx.Columns {
|
||||
if column.ForeignKeyTargetColumn == idxColName {
|
||||
continue fk_loop
|
||||
}
|
||||
break // Only look at 1st column
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestFailureCases(t *testing.T) {
|
||||
test_cases := []struct {
|
||||
testCases := []struct {
|
||||
sqlFile string
|
||||
expectedFailures []string
|
||||
}{
|
||||
@@ -34,24 +34,24 @@ func TestFailureCases(t *testing.T) {
|
||||
}},
|
||||
}
|
||||
|
||||
for _, test_case := range test_cases {
|
||||
t.Run(test_case.sqlFile, func(t *testing.T) {
|
||||
schema, err := schema.SchemaFromSQLFile(test_case.sqlFile)
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.sqlFile, func(t *testing.T) {
|
||||
schema, err := schema.SchemaFromSQLFile(testCase.sqlFile)
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, check := range lint.Checks {
|
||||
results := check.Execute(schema)
|
||||
|
||||
is_failure := len(results) > 0
|
||||
is_failure_expected := slices.Contains(test_case.expectedFailures, check.Name)
|
||||
isFailure := len(results) > 0
|
||||
isFailureExpected := slices.Contains(testCase.expectedFailures, check.Name)
|
||||
|
||||
if is_failure != is_failure_expected {
|
||||
if is_failure_expected {
|
||||
t.Errorf("Expected check '%s' to fail, but it passed: %s", check.Name, test_case.sqlFile)
|
||||
if isFailure != isFailureExpected {
|
||||
if isFailureExpected {
|
||||
t.Errorf("Expected check '%s' to fail, but it passed: %s", check.Name, testCase.sqlFile)
|
||||
} else {
|
||||
t.Errorf("Expected check '%s' to pass, but it failed: %s (%q.%q)",
|
||||
check.Name,
|
||||
test_case.sqlFile,
|
||||
testCase.sqlFile,
|
||||
results[0].TableName, results[0].ColumnName,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user