-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RD-10005 flag a warning when environment secret not set (#359)
- Added support for compilation messages
- Loading branch information
1 parent
c9c5e61
commit b39c7c3
Showing
41 changed files
with
533 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
snapi-client/src/test/scala/raw/compiler/rql2/tests/lsp/LspCompilationMessagesTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2023 RAW Labs S.A. | ||
* | ||
* Use of this software is governed by the Business Source License | ||
* included in the file licenses/BSL.txt. | ||
* | ||
* As of the Change Date specified in that file, in accordance with | ||
* the Business Source License, use of this software will be governed | ||
* by the Apache License, Version 2.0, included in the file | ||
* licenses/APL.txt. | ||
*/ | ||
|
||
package raw.compiler.rql2.tests.lsp | ||
|
||
import raw.client.api.{ErrorMessage, WarningMessage} | ||
import raw.compiler.base.errors.{MissingSecretWarning, UnknownDecl} | ||
import raw.compiler.rql2.tests.CompilerTestContext | ||
|
||
trait LspCompilationMessagesTest extends CompilerTestContext { | ||
|
||
test("should return a waning") { _ => | ||
val code = """let a = Environment.Secret("a") in a""".stripMargin | ||
val res = validate(code) | ||
res.messages.size should be(1) | ||
res.messages.foreach { | ||
case WarningMessage(message, _, code, _) => | ||
assert(message == MissingSecretWarning.message) | ||
assert(code == MissingSecretWarning.code) | ||
case _ => fail("Expected a warning message") | ||
} | ||
} | ||
|
||
test("should fail to evaluate silently without a warning") { _ => | ||
val code = """secret(key: string) = Environment.Secret(key)""".stripMargin | ||
val res = validate(code) | ||
res.messages.size should be(0) | ||
} | ||
|
||
test("should not output warning if there is a semantic error") { _ => | ||
val code = """let a = Environment.Secret(asdf) in a""".stripMargin | ||
val res = validate(code) | ||
res.messages.size should be(1) | ||
res.messages.foreach { | ||
case ErrorMessage(message, _, code, _) => | ||
assert(message == "asdf is not declared") | ||
assert(code == UnknownDecl.code) | ||
case _ => fail("Expected a warning message") | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.