-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_test.go
48 lines (41 loc) · 930 Bytes
/
file_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
package mset
import (
"testing"
)
func TestFileExist(T *testing.T) {
}
func TestIsValidName(t *testing.T) {
table := []struct {
name string
valid bool
}{
{name: "danta", valid: true},
{name: "myProy", valid: true},
{name: "my-proy", valid: true},
{name: "danta1", valid: true},
{name: "1danta", valid: true},
{name: "danta.xml", valid: false},
{name: "danta*", valid: false},
{name: "danta>", valid: false},
}
for _, row := range table {
got := isValidName(row.name)
if got != row.valid {
t.Errorf("name '%v' got valid: %v instead of valid: %v", row.name, got, row.valid)
}
}
}
func TestSetEntryName(t *testing.T) {
input := "danta"
output := "danta-settings.xml"
got := setEntryName(input)
if got != output {
t.Errorf("got: %v instead of %v", got, output)
}
}
func TestSaveCurrentFile(t *testing.T) {
err := saveCurrentFile("danta")
if err != nil {
t.Error(err.Error())
}
}