Repository navigation
Expand file tree
/
Copy pathnames_test.go
More file actions
90 lines (77 loc) · 1.73 KB
/
Copy pathnames_test.go
File metadata and controls
90 lines (77 loc) · 1.73 KB
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
88
89
90
package main
import (
"bytes"
"testing"
)
func TestNamesWriteHeader1(t *testing.T) {
n := names{
writeDescriptions: false,
}
output := bytes.NewBuffer(make([]byte, 0))
expected := "file\tid\n"
err := n.writeHeader(output)
if err != nil {
t.Error(err)
}
if output.String() != expected {
t.Errorf("expected:\n %s, got:\n %s", expected, output.String())
}
}
func TestNamesWriteHeader2(t *testing.T) {
n := names{
writeDescriptions: true,
}
output := bytes.NewBuffer(make([]byte, 0))
expected := "file\tdescription\n"
err := n.writeHeader(output)
if err != nil {
t.Error(err)
}
if output.String() != expected {
t.Errorf("expected:\n %s, got:\n %s", expected, output.String())
}
}
func TestNamesRecords1(t *testing.T) {
n := names{
writeDescriptions: false,
}
fastaFile := []byte(`>Seq1 Homo_sapiens X
ATGATG
>Seq2 Danio_rerio Y
ATTAT-
`)
reader := NewReader(bytes.NewReader(fastaFile))
expected := `file.fasta Seq1
file.fasta Seq2
`
output := bytes.NewBuffer(make([]byte, 0))
err := namesRecords("/path/to/my/file.fasta", reader, n, output)
if err != nil {
t.Error(err)
}
if output.String() != expected {
t.Errorf("expected:\n %s, got:\n %s", expected, output.String())
}
}
func TestNamesRecords2(t *testing.T) {
n := names{
writeDescriptions: true,
}
fastaFile := []byte(`>Seq1 Homo_sapiens X
ATGATG
>Seq2 Danio_rerio Y
ATTAT-
`)
reader := NewReader(bytes.NewReader(fastaFile))
expected := `file.fasta Seq1 Homo_sapiens X
file.fasta Seq2 Danio_rerio Y
`
output := bytes.NewBuffer(make([]byte, 0))
err := namesRecords("/path/to/my/file.fasta", reader, n, output)
if err != nil {
t.Error(err)
}
if output.String() != expected {
t.Errorf("expected:\n %s, got:\n %s", expected, output.String())
}
}