-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
87 lines (72 loc) · 2.3 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
// import (
// "github.com/dark-person/comicinfo-parser/internal/archive"
// "github.com/dark-person/comicinfo-parser/internal/comicinfo"
// "encoding/xml"
// "fmt"
// "github.com/dark-person/comicinfo-parser/internal/scanner"
// "os"
// "path/filepath"
// "testing"
// )
// // Test below process:
// // 1. Create ComicInfo.xml for testFolder
// // 2. Zip the testFolder into .zip
// // 3. Rename .zip to .cbz, and wrap it with folder
// //
// // This test is complicated and require manual compare to determine test pass or not.
// func TestZip(t *testing.T) {
// testFolder := `temp\(C102) [そちゃ屋 (にこびぃ)] 高雄さんの性事情 (艦隊これくしょん -艦これ-) [空気系☆漢化]`
// // Create ComicInfo.xml first
// // Load Abs Path
// c := scanner.ScanBooks(testFolder)
// output, err := xml.MarshalIndent(c, " ", " ")
// if err != nil {
// fmt.Printf("error: %v\n", err)
// }
// // Open File for reading
// f, err := os.Create(filepath.Join(testFolder, "ComicInfo.xml"))
// if err != nil {
// panic(err)
// }
// defer f.Close()
// // Write XML Content to file
// f.Write([]byte("<?xml version=\"1.0\"?>\n"))
// f.Write(output)
// f.Sync()
// // Start Archive
// filename, _ := archive.CreateZip(testFolder)
// err = archive.RenameZip(filename)
// if err != nil {
// fmt.Printf("error: %v\n", err)
// }
// }
// // This Test is for checking internal whole process only. This test is passed with any situation
// func TestProduce(t *testing.T) {
// absPath := `D:\Desktop\(C102) [丸杏亭 (マルコ)] ヒミツの××開発 (原神)|秘密的××开发 [黎欧出资汉化]`
// if absPath == "" {
// panic("Missing absolute path")
// }
// // Load Abs Path
// c := scanner.ScanBooks(absPath)
// output, err := xml.MarshalIndent(c, " ", " ")
// if err != nil {
// fmt.Printf("error: %v\n", err)
// }
// // Open File for reading
// f, err := os.Create(filepath.Join(absPath, "ComicInfo.xml"))
// if err != nil {
// panic(err)
// }
// defer f.Close()
// // Write XML Content to file
// f.Write([]byte("<?xml version=\"1.0\"?>\n"))
// f.Write(output)
// f.Sync()
// // Start Archive
// filename, _ := archive.CreateZip(absPath)
// err = archive.RenameZip(filename)
// if err != nil {
// fmt.Printf("error: %v\n", err)
// }
// }