-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09757f4
commit cf9e531
Showing
5 changed files
with
96 additions
and
68 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
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 |
---|---|---|
@@ -1,37 +1,30 @@ | ||
package formats | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"github.com/rushsteve1/mangadex-opds/shared" | ||
"os" | ||
"testing" | ||
|
||
"github.com/google/uuid" | ||
"github.com/rushsteve1/mangadex-opds/models" | ||
) | ||
|
||
func Test_WriteEpub(t *testing.T) { | ||
ctx := context.Background() | ||
c := models.Chapter{ID: uuid.MustParse(ChapterID)} | ||
const EPUBChapterSize = 1_188_189 | ||
|
||
file, err := os.CreateTemp("", "*.epub") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer file.Close() | ||
func Test_WriteEpub(t *testing.T) { | ||
shared.TestOptions() | ||
|
||
t.Log("temp file created at: " + file.Name()) | ||
ctx := context.Background() | ||
|
||
err = WriteEpub(ctx, &c, file) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
c, err := models.FetchChapter(ctx, uuid.MustParse(ChapterID), nil) | ||
shared.AssertEq(t, err, nil) | ||
|
||
stats, err := file.Stat() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
buf := bytes.Buffer{} | ||
|
||
if stats.Size() == 0 { | ||
t.Fatal("size zero") | ||
} | ||
err = os.Chdir("../../") | ||
err = WriteEpub(ctx, &c, &buf) | ||
shared.AssertEq(t, err, nil) | ||
shared.AssertEq(t, buf.Len(), EPUBChapterSize) | ||
} |