Skip to content

Commit

Permalink
Rename model structs, move them to model files
Browse files Browse the repository at this point in the history
  • Loading branch information
stefannegele committed Nov 21, 2023
1 parent cea08af commit b16bc0e
Show file tree
Hide file tree
Showing 8 changed files with 958 additions and 928 deletions.
6 changes: 3 additions & 3 deletions breaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ func Breaking(
return nil
}

func breakingDifferences(allDifferences []DatasetDifference) []DatasetDifference {
var breakingDifferences []DatasetDifference
func breakingDifferences(allDifferences []ModelDifference) []ModelDifference {
var breakingDifferences []ModelDifference
for _, difference := range allDifferences {
if difference.Severity == DatasetDifferenceSeverityBreaking {
if difference.Severity == ModelDifferenceSeverityBreaking {
breakingDifferences = append(breakingDifferences, difference)
}
}
Expand Down
4 changes: 2 additions & 2 deletions breaking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Description: field 'my_table.my_column' was removed
Type: field-removed
Severity: breaking
Level: field
Model: my_table
Field: my_column
InternalModel: my_table
InternalField: my_column
`,
},
{
Expand Down
14 changes: 7 additions & 7 deletions diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func GetDifferences(
stableDataContractLocation string,
pathToType []string,
pathToSpecification []string,
) ([]DatasetDifference, error) {
) ([]ModelDifference, error) {
localDataContract, err := GetDataContract(dataContractLocation)
if err != nil {
return nil, fmt.Errorf("failed reading local data contract: %w", err)
Expand All @@ -46,7 +46,7 @@ func GetDifferences(
return differences, nil
}

func PrintDifferences(differences []DatasetDifference) {
func PrintDifferences(differences []ModelDifference) {
log.Printf("Found %v differences between the data contracts!\n", len(differences))

for i, difference := range differences {
Expand All @@ -57,19 +57,19 @@ func PrintDifferences(differences []DatasetDifference) {
log.Printf("Severity: %v\n", difference.Severity)
log.Printf("Level: %v\n", difference.Level)
if difference.ModelName != nil {
log.Printf("Model: %v\n", *difference.ModelName)
log.Printf("InternalModel: %v\n", *difference.ModelName)
}
if difference.FieldName != nil {
log.Printf("Field: %v\n", *difference.FieldName)
log.Printf("InternalField: %v\n", *difference.FieldName)
}
}
}

func severityIcon(difference DatasetDifference) string {
func severityIcon(difference ModelDifference) string {
switch difference.Severity {
case DatasetDifferenceSeverityInfo:
case ModelDifferenceSeverityInfo:
return "🟡"
case DatasetDifferenceSeverityBreaking:
case ModelDifferenceSeverityBreaking:
return "🔴"
}

Expand Down
16 changes: 8 additions & 8 deletions diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ Description: field 'my_table.my_column' was removed
Type: field-removed
Severity: breaking
Level: field
Model: my_table
Field: my_column
InternalModel: my_table
InternalField: my_column
🟡 Difference 2:
Description: field 'my_table.my_column_2' was added
Type: field-added
Severity: info
Level: field
Model: my_table
Field: my_column_2
InternalModel: my_table
InternalField: my_column_2
`,
},
{
Expand All @@ -54,8 +54,8 @@ Description: field 'my_table.my_column_2' was added
Type: field-added
Severity: info
Level: field
Model: my_table
Field: my_column_2
InternalModel: my_table
InternalField: my_column_2
`,
},
{
Expand All @@ -74,8 +74,8 @@ Description: type of field 'awesome_feature_usage_history.my_column' was change
Type: field-type-changed
Severity: breaking
Level: field
Model: awesome_feature_usage_history
Field: my_column
InternalModel: awesome_feature_usage_history
InternalField: my_column
`,
},
}
Expand Down
Loading

0 comments on commit b16bc0e

Please sign in to comment.