Validation plugin fix
This commit is contained in:
1 parent
4c1739ab02
commit
511bcbffdf
2 files changed
+11
-8
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
import "pkg:/components/Telemetry/Sentry.bs"
|
import "pkg:/components/Telemetry/Sentry.bs"
|
||||||
import "pkg:/source/tests/HttpTestServer.bs"
|
import "pkg:/source/tests/HttpTestServer.bs"
|
||||||
import "pkg:/source/tests/LoggingGlobals.bs"
|
import "pkg:/source/tests/LoggingGlobals.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
|
||||||
namespace Tests
|
namespace Tests
|
||||||
|
|
||||||
@@ -133,9 +134,9 @@ namespace Tests
|
|||||||
m.assertEqual(m.FallbackHits(), 0)
|
m.assertEqual(m.FallbackHits(), 0)
|
||||||
lines = m.LastEnvelopeLines()
|
lines = m.LastEnvelopeLines()
|
||||||
m.assertEqual(lines.Count(), 4)
|
m.assertEqual(lines.Count(), 4)
|
||||||
m.assertEqual(ParseJson(lines[0]).sdk.name, "sentry.roku.playlet")
|
m.assertEqual(StringUtils.ParseJsonSafe(lines[0]).sdk.name, "sentry.roku.playlet")
|
||||||
m.assertEqual(lines[1], `{"type":"event"}`)
|
m.assertEqual(lines[1], `{"type":"event"}`)
|
||||||
event = ParseJson(lines[2])
|
event = StringUtils.ParseJsonSafe(lines[2])
|
||||||
m.assertEqual(event.logentry.formatted, "sent event")
|
m.assertEqual(event.logentry.formatted, "sent event")
|
||||||
m.assertEqual(event.level, "error")
|
m.assertEqual(event.level, "error")
|
||||||
m.assertEqual(event.release, "1.0.0-test")
|
m.assertEqual(event.release, "1.0.0-test")
|
||||||
@@ -165,7 +166,7 @@ namespace Tests
|
|||||||
|
|
||||||
lines = m.LastEnvelopeLines()
|
lines = m.LastEnvelopeLines()
|
||||||
m.assertEqual(lines[1], `{"type":"event"}`)
|
m.assertEqual(lines[1], `{"type":"event"}`)
|
||||||
event = ParseJson(lines[2])
|
event = StringUtils.ParseJsonSafe(lines[2])
|
||||||
m.assertEqual(event.logentry.formatted, `Support server unreachable: ${errorMessage}`)
|
m.assertEqual(event.logentry.formatted, `Support server unreachable: ${errorMessage}`)
|
||||||
m.assertEqual(event.level, "warning")
|
m.assertEqual(event.level, "warning")
|
||||||
m.assertEqual(event.fingerprint, ["support server unreachable"])
|
m.assertEqual(event.fingerprint, ["support server unreachable"])
|
||||||
@@ -174,7 +175,7 @@ namespace Tests
|
|||||||
m.assertEqual(event.user, { id: "user1" })
|
m.assertEqual(event.user, { id: "user1" })
|
||||||
m.assertInvalid(event.extra)
|
m.assertInvalid(event.extra)
|
||||||
|
|
||||||
attachment = ParseJson(lines[3])
|
attachment = StringUtils.ParseJsonSafe(lines[3])
|
||||||
m.assertEqual(attachment.type, "attachment")
|
m.assertEqual(attachment.type, "attachment")
|
||||||
m.assertEqual(attachment.filename, "envelope.txt")
|
m.assertEqual(attachment.filename, "envelope.txt")
|
||||||
m.assertEqual(attachment.content_type, "text/plain")
|
m.assertEqual(attachment.content_type, "text/plain")
|
||||||
@@ -183,7 +184,7 @@ namespace Tests
|
|||||||
m.assertEqual(attachment.length, attached.Len() - 1)
|
m.assertEqual(attachment.length, attached.Len() - 1)
|
||||||
attachedLines = attached.Split(`\n`)
|
attachedLines = attached.Split(`\n`)
|
||||||
m.assertEqual(attachedLines[1], `{"type":"event"}`)
|
m.assertEqual(attachedLines[1], `{"type":"event"}`)
|
||||||
unsentEvent = ParseJson(attachedLines[2])
|
unsentEvent = StringUtils.ParseJsonSafe(attachedLines[2])
|
||||||
m.assertEqual(unsentEvent.logentry.formatted, "unsent event")
|
m.assertEqual(unsentEvent.logentry.formatted, "unsent event")
|
||||||
m.assertEqual(unsentEvent.event_id, result.events[0].event_id)
|
m.assertEqual(unsentEvent.event_id, result.events[0].event_id)
|
||||||
end function
|
end function
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import {
|
import {
|
||||||
BscFile,
|
BscFile,
|
||||||
CompilerPlugin,
|
CompilerPlugin,
|
||||||
|
DiagnosticSeverity,
|
||||||
OnFileValidateEvent,
|
OnFileValidateEvent,
|
||||||
Program,
|
Program,
|
||||||
Range,
|
Range,
|
||||||
@@ -65,12 +66,13 @@ export class ValidationPlugin implements CompilerPlugin {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.diagnostics.push({
|
file.addDiagnostics([{
|
||||||
code: validation.code,
|
code: validation.code,
|
||||||
message: validation.message,
|
message: validation.message,
|
||||||
file: file,
|
file: file,
|
||||||
range: Range.create(line, column, line, column + match[0].length)
|
range: Range.create(line, column, line, column + match[0].length),
|
||||||
});
|
severity: DiagnosticSeverity.Error
|
||||||
|
}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user