electron / fiddle-core

Run fiddles from anywhere, on any Electron release
MIT License
13 stars 16 forks source link

using asar fiddle file #106

Open hachimetsu opened 7 months ago

hachimetsu commented 7 months ago

100

image what improvement should i do am i doing right ?

hachimetsu commented 7 months ago

i used my most of the time to just create test case for asar and still not done so i just created a pull request

i only done changes in src/fiddle.ts file added the fromASAR function which unpack asar content to tempDir and then call fromFolder on tempDir

hachimetsu commented 7 months ago

@erickzhao can i also help i would like to learn how to create test case

hachimetsu commented 7 months ago

image what should i do in test case ? image I know how to make a test case pass, but then it doesn't behave like a real test case anymore.

A test case should show an error if there's one, but I'm unsure what conditions would constitute an error in this situation.

hachimetsu commented 7 months ago

i did search about api-extractor i did not created a new pull because i want to compete the test case part too image

marfgold1 commented 6 months ago

A test case should show an error if there's one, but I'm unsure what conditions would constitute an error in this situation.

Do you mean a negative case? You can simply use not before condition, e.g. expect(fiddle!.mainPath).not.toBe(asarPath), but I don't think it's needed anyway? The test case could be structured like reads fiddles from gists test:

You can be more rigorous by making sure the file list and files' content are identical by comparing it with fiddleFixture('642fa8daaebea6044c9079e3f8a46390') just like in the reads fiddles from local folders test.

hachimetsu commented 6 months ago

thanks for suggestion

For Case Running Fiddle from Local Dir

we test if mainPath in fiddle object is same as provided path and there content are same or not

what should be done For ASAR case:-

asarPath: path to asar file (example fiddle-core/tests/fixtures/fiddle.asar) mainPath: path to dir where content from asar get extracted (example fiddle-core-running-temp-path/extract/temp/fiddle) for now what i did for test

NOTE

Should i compare extracted content to the content of dir which is used to create asar because i did use test example to create asar so this can be done

but then testing of asar will depend on content of example fiddle if in future fiddle example get changed then asar file must be create from that example

I m implementing all of this, so let me know if some one get any more idea or suggestion on this

marfgold1 commented 6 months ago

but then testing of asar will depend on content of example fiddle if in future fiddle example get changed then asar file must be create from that example

Yeah that might happen. I have an idea, what about archiving the fiddleFixture('642fa8daaebea6044c9079e3f8a46390') as ASAR on the fly when testing it? Save it in tmpdir and let asarPath points to it. Then you can create fiddle fromASAR with it. Don't worry about cleaning up, afterEach(()=>{fs.removeSync(tmpdir);}) already done the cleaning job for you.