Moved to CUE validation
This commit is contained in:
@@ -38,7 +38,7 @@ func TestMDSWriterValidation(t *testing.T) {
|
||||
|
||||
found := false
|
||||
for _, d := range v.Diagnostics {
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'TreeName'") {
|
||||
if strings.Contains(d.Message, "TreeName: incomplete value") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func TestMathExpressionGAMValidation(t *testing.T) {
|
||||
|
||||
found := false
|
||||
for _, d := range v.Diagnostics {
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'Expression'") {
|
||||
if strings.Contains(d.Message, "Expression: incomplete value") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ func TestPIDGAMValidation(t *testing.T) {
|
||||
foundKd := false
|
||||
|
||||
for _, d := range v.Diagnostics {
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'Ki'") {
|
||||
if strings.Contains(d.Message, "Ki: incomplete value") {
|
||||
foundKi = true
|
||||
}
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'Kd'") {
|
||||
if strings.Contains(d.Message, "Kd: incomplete value") {
|
||||
foundKd = true
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func TestFileDataSourceValidation(t *testing.T) {
|
||||
|
||||
found := false
|
||||
for _, d := range v.Diagnostics {
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'Filename'") {
|
||||
if strings.Contains(d.Message, "Filename: incomplete value") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -35,14 +35,20 @@ func TestRealTimeApplicationValidation(t *testing.T) {
|
||||
missingStates := false
|
||||
|
||||
for _, d := range v.Diagnostics {
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'Data'") {
|
||||
if strings.Contains(d.Message, "Data: field is required") {
|
||||
missingData = true
|
||||
}
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'States'") {
|
||||
if strings.Contains(d.Message, "States: field is required") {
|
||||
missingStates = true
|
||||
}
|
||||
}
|
||||
|
||||
if !missingData || !missingStates {
|
||||
for _, d := range v.Diagnostics {
|
||||
t.Logf("Diagnostic: %s", d.Message)
|
||||
}
|
||||
}
|
||||
|
||||
if !missingData {
|
||||
t.Error("Expected error for missing 'Data' field in RealTimeApplication")
|
||||
}
|
||||
@@ -73,7 +79,7 @@ func TestGAMSchedulerValidation(t *testing.T) {
|
||||
|
||||
found := false
|
||||
for _, d := range v.Diagnostics {
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'TimingDataSource'") {
|
||||
if strings.Contains(d.Message, "TimingDataSource: incomplete value") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestSDNSubscriberValidation(t *testing.T) {
|
||||
|
||||
found := false
|
||||
for _, d := range v.Diagnostics {
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'Port'") {
|
||||
if strings.Contains(d.Message, "Port: incomplete value") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func TestFileWriterValidation(t *testing.T) {
|
||||
|
||||
found := false
|
||||
for _, d := range v.Diagnostics {
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'Filename'") {
|
||||
if strings.Contains(d.Message, "Filename: incomplete value") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestGAMSignalValidation(t *testing.T) {
|
||||
if strings.Contains(d.Message, "DataSource 'OutDS' (Class FileWriter) is Output-only but referenced in InputSignals") {
|
||||
foundBadInput = true
|
||||
}
|
||||
if strings.Contains(d.Message, "Signal 'MissingSig' not found in DataSource 'InDS'") {
|
||||
if strings.Contains(d.Message, "Implicitly Defined Signal: 'MissingSig'") {
|
||||
foundMissing = true
|
||||
}
|
||||
if strings.Contains(d.Message, "DataSource 'InDS' (Class FileReader) is Input-only but referenced in OutputSignals") {
|
||||
|
||||
@@ -21,17 +21,16 @@ func TestProjectSpecificSchema(t *testing.T) {
|
||||
|
||||
// Define project schema
|
||||
schemaContent := `
|
||||
{
|
||||
"classes": {
|
||||
"ProjectClass": {
|
||||
"fields": [
|
||||
{"name": "CustomField", "type": "int", "mandatory": true}
|
||||
]
|
||||
}
|
||||
}
|
||||
package schema
|
||||
|
||||
#Classes: {
|
||||
ProjectClass: {
|
||||
CustomField: int
|
||||
...
|
||||
}
|
||||
}
|
||||
`
|
||||
err = os.WriteFile(filepath.Join(tmpDir, ".marte_schema.json"), []byte(schemaContent), 0644)
|
||||
err = os.WriteFile(filepath.Join(tmpDir, ".marte_schema.cue"), []byte(schemaContent), 0644)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -59,7 +58,7 @@ func TestProjectSpecificSchema(t *testing.T) {
|
||||
|
||||
found := false
|
||||
for _, d := range v.Diagnostics {
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'CustomField'") {
|
||||
if strings.Contains(d.Message, "CustomField: incomplete value") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestSchemaValidationMandatory(t *testing.T) {
|
||||
|
||||
found := false
|
||||
for _, d := range v.Diagnostics {
|
||||
if strings.Contains(d.Message, "Missing mandatory field 'States'") {
|
||||
if strings.Contains(d.Message, "States: field is required") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func TestSchemaValidationType(t *testing.T) {
|
||||
|
||||
found := false
|
||||
for _, d := range v.Diagnostics {
|
||||
if strings.Contains(d.Message, "Field 'First' expects type 'int'") {
|
||||
if strings.Contains(d.Message, "mismatched types") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
@@ -105,8 +105,8 @@ func TestSchemaValidationOrder(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
t.Error("Expected error for out-of-order fields, but found none")
|
||||
if found {
|
||||
t.Error("Unexpected error for out-of-order fields (Order check is disabled in CUE)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,10 @@ $App = {
|
||||
$Data = {
|
||||
+MyDS = {
|
||||
Class = DataSourceClass
|
||||
Sig1 = { Type = uint32 }
|
||||
Sig2 = { Type = uint32 }
|
||||
+Signals = {
|
||||
Sig1 = { Type = uint32 }
|
||||
Sig2 = { Type = uint32 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user