test/sandbox: parse full test case
This makes declaring multiple tests much cleaner. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
31
test/sandbox/assert.nix
Normal file
31
test/sandbox/assert.nix
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
writeText,
|
||||
buildGoModule,
|
||||
|
||||
version,
|
||||
name,
|
||||
want,
|
||||
}:
|
||||
let
|
||||
wantFile = writeText "fortify-${name}-want.json" (builtins.toJSON want);
|
||||
mainFile = writeText "main.go" ''
|
||||
package main
|
||||
|
||||
import "os"
|
||||
import "git.gensokyo.uk/security/fortify/test/sandbox"
|
||||
|
||||
func main() { (&sandbox.T{FS: os.DirFS("/"), PMountsPath: "/.fortify/mounts"}).MustCheckFile("${wantFile}") }
|
||||
'';
|
||||
in
|
||||
buildGoModule {
|
||||
pname = "fortify-${name}-check-sandbox";
|
||||
inherit version;
|
||||
|
||||
src = ../.;
|
||||
vendorHash = null;
|
||||
|
||||
preBuild = ''
|
||||
go mod init git.gensokyo.uk/security/fortify/test >& /dev/null
|
||||
cp ${mainFile} main.go
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user