Convert test to inline expectation test

This commit is contained in:
Ed Minnix
2024-08-19 17:46:22 -04:00
parent 47974914a5
commit 257436a49d
3 changed files with 27 additions and 17 deletions

View File

@@ -1,7 +1,3 @@
| test.go:12:10:12:26 | call to Getenv |
| test.go:14:2:14:33 | ... := ...[0] |
| test.go:19:20:19:31 | call to Environ |
| test.go:34:29:34:32 | &... |
| test.go:41:2:41:40 | ... := ...[0] |
| test.go:48:2:48:52 | ... := ...[0] |
| test.go:61:2:61:33 | ... := ...[0] |
testFailures
invalidModelRow
failures

View File

@@ -9,14 +9,14 @@ import (
)
func osEnvironmentVariables() {
home := os.Getenv("HOME")
home := os.Getenv("HOME") // $ source
port, ok := os.LookupEnv("PORT")
port, ok := os.LookupEnv("PORT") // $ source
if !ok {
port = "3000"
}
for _, e := range os.Environ() {
for _, e := range os.Environ() { // $ source
_ = e
}
@@ -31,21 +31,21 @@ type ServerConfig struct {
func envconfigEnvironmentVariables() {
var cfg ServerConfig
envconfig.Process("myapp", &cfg)
envconfig.Process("myapp", &cfg) // $ source
}
func godotenvEnvironmentVariables() {
var err error
var username, greeting string
users, err := godotenv.Read("user.env")
users, err := godotenv.Read("user.env") // $ source
if err != nil {
return
}
username = users["USERNAME"]
greetings, err := godotenv.Unmarshal("HELLO=hello")
greetings, err := godotenv.Unmarshal("HELLO=hello") // $ source
if err != nil {
return
}
@@ -61,7 +61,7 @@ func envparseEnvironmentVariables() {
return
}
defer f.Close()
envVars, err := envparse.Parse(f)
envVars, err := envparse.Parse(f) // $ source
if err != nil {
return

View File

@@ -1,5 +1,19 @@
import go
import ModelValidation
import TestUtilities.InlineExpectationsTest
from DataFlow::Node source
where source instanceof ThreatModelFlowSource
select source
module SourceTest implements TestSig {
string getARelevantTag() { result = "source" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(ThreatModelFlowSource s |
s.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
element = s.toString() and
value = "" and
tag = "source"
)
}
}
import MakeTest<SourceTest>