init
This commit is contained in:
1
tests/mymod/assets/example.json
Normal file
1
tests/mymod/assets/example.json
Normal file
@ -0,0 +1 @@
|
||||
{"some": "JSON data"}
|
7
tests/mymod/main.v
Normal file
7
tests/mymod/main.v
Normal file
@ -0,0 +1,7 @@
|
||||
module main
|
||||
|
||||
fn main() {
|
||||
println(embedfs)
|
||||
json_file := embedfs.files['assets/example.json'] or { EmbedFile{} }
|
||||
println(json_file.data.to_string().trim_space())
|
||||
}
|
12
tests/mymod_test.out
Normal file
12
tests/mymod_test.out
Normal file
@ -0,0 +1,12 @@
|
||||
EmbedFileSystem{
|
||||
files: {'assets/example.json': EmbedFile{
|
||||
data: embed_file.EmbedFileData{ len: 22, path: "assets/example.json", apath: "", uncompressed: 8462c4 }
|
||||
meta: EmbedFileMetadata{
|
||||
key: 'assets/example.json'
|
||||
name: 'example.json'
|
||||
ext: 'json'
|
||||
mimetype: 'application/json'
|
||||
}
|
||||
}}
|
||||
}
|
||||
{"some": "JSON data"}
|
18
tests/mymod_test.v
Normal file
18
tests/mymod_test.v
Normal file
@ -0,0 +1,18 @@
|
||||
module main
|
||||
|
||||
import os
|
||||
import v.util.diff
|
||||
import embedfs
|
||||
|
||||
fn test_mymod() {
|
||||
expected_out := os.read_file('tests/mymod_test.out')!
|
||||
os.chdir('tests/mymod')!
|
||||
gen := embedfs.CodeGenerator{
|
||||
path: 'assets'
|
||||
make_pub: false
|
||||
}
|
||||
os.write_file('assets_generated.v', gen.generate())!
|
||||
ret := os.execute('sh -c "v run ."')
|
||||
dump(diff.compare_text(ret.output, expected_out)!)
|
||||
assert ret.output == expected_out
|
||||
}
|
Reference in New Issue
Block a user