-
Notifications
You must be signed in to change notification settings - Fork 0
/
gofrompdf_test.go
37 lines (33 loc) · 1016 Bytes
/
gofrompdf_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
package svgpdf
import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCommand(t *testing.T) {
var app App
str, err := app.command("apt | grep apt | head -n 1 -c 3")
assert.Equal(t, err, nil, "Expected not error")
assert.Equal(t, str, "apt")
}
func TestIsValidFile(t *testing.T) {
var app App
err := ioutil.WriteFile("kucing.pdf", []byte("Hello"), 0755)
assert.Equal(t, err, nil, "Expected not error")
result := app.isValidFile("kucing.pdf")
assert.Equal(t, result, true, "expect true")
err = os.Remove("kucing.pdf")
assert.Equal(t, err, nil, "expect true")
result = app.isValidFile("kucing.pdf")
assert.Equal(t, result, false, "expect false")
}
func TestCreateFile(t *testing.T) {
err := Exporter("contoh.pdf", "newSvgLetter")
assert.Equal(t, err, nil, "Expected not error")
var app App
result := app.isValidFile("newSvgLetter.svg")
assert.Equal(t, result, true, "expect false")
err = os.Remove("newSvgLetter.svg")
assert.Equal(t, err, nil, "expect true")
}