Adding upstream version 1.0.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
f0ce5b079b
commit
b1c5a31457
136 changed files with 2310 additions and 0 deletions
62
api_test.go
Normal file
62
api_test.go
Normal file
|
@ -0,0 +1,62 @@
|
|||
package reply_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"code.forgejo.org/forgejo/reply"
|
||||
)
|
||||
|
||||
func TestText(t *testing.T) {
|
||||
// Add files to be skipped.
|
||||
var skipped []string
|
||||
|
||||
err := filepath.Walk("testdata/emails", func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if filepath.Ext(path) == ".txt" {
|
||||
t.Run(path, func(t *testing.T) {
|
||||
for _, filename := range skipped {
|
||||
if filename == filepath.Base(path) {
|
||||
t.Skipf("%s is not implemented", filename)
|
||||
}
|
||||
}
|
||||
|
||||
in, err := os.Open(path)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
|
||||
expected, err := ioutil.ReadFile(fmt.Sprintf("testdata/reply/%s", filepath.Base(path)))
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
|
||||
replyText, err := reply.FromReader(in)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
|
||||
if strings.TrimSpace(replyText) != strings.TrimSpace(string(expected)) {
|
||||
t.Errorf("\nexpected:\n%s\n\ngot:\n%s", string(expected), replyText)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %s", err)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue