This repository has been archived by the owner on Nov 7, 2020. It is now read-only.
forked from Praqma/helmsman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_test.go
207 lines (198 loc) · 3.67 KB
/
utils_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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
package main
import "testing"
// func Test_printMap(t *testing.T) {
// type args struct {
// m map[string]string
// }
// tests := []struct {
// name string
// args args
// }{
// // TODO: Add test cases.
// }
// for _, tt := range tests {
// t.Run(tt.name, func(t *testing.T) {
// printMap(tt.args.m)
// })
// }
// }
func Test_fromTOML(t *testing.T) {
type args struct {
file string
s *state
}
tests := []struct {
name string
args args
want bool
}{
{
name: "test case 1 -- invalid TOML",
args: args{
file: "test_files/invalid_example.toml",
s: new(state),
},
want: false,
}, {
name: "test case 2 -- valid TOML",
args: args{
file: "example.toml",
s: new(state),
},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got, _ := fromTOML(tt.args.file, tt.args.s); got != tt.want {
t.Errorf("fromToml() = %v, want %v", got, tt.want)
}
})
}
}
// func Test_toTOML(t *testing.T) {
// type args struct {
// file string
// s *state
// }
// tests := []struct {
// name string
// args args
// }{
// // TODO: Add test cases.
// }
// for _, tt := range tests {
// t.Run(tt.name, func(t *testing.T) {
// toTOML(tt.args.file, tt.args.s)
// })
// }
// }
func Test_fromYAML(t *testing.T) {
type args struct {
file string
s *state
}
tests := []struct {
name string
args args
want bool
}{
{
name: "test case 1 -- invalid YAML",
args: args{
file: "test_files/invalid_example.yaml",
s: new(state),
},
want: false,
}, {
name: "test case 2 -- valid TOML",
args: args{
file: "example.yaml",
s: new(state),
},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got, _ := fromYAML(tt.args.file, tt.args.s); got != tt.want {
t.Errorf("fromYaml() = %v, want %v", got, tt.want)
}
})
}
}
// func Test_toYAML(t *testing.T) {
// type args struct {
// file string
// s *state
// }
// tests := []struct {
// name string
// args args
// }{
// // TODO: Add test cases.
// }
// for _, tt := range tests {
// t.Run(tt.name, func(t *testing.T) {
// toYAML(tt.args.file, tt.args.s)
// })
// }
// }
func Test_isOfType(t *testing.T) {
type args struct {
filename string
filetype string
}
tests := []struct {
name string
args args
want bool
}{
{
name: "test case 1 -- valid xml check",
args: args{
filename: "name.xml",
filetype: ".xml",
},
want: true,
}, {
name: "test case 2 -- valid yaml check",
args: args{
filename: "another_name.yaml",
filetype: ".yaml",
},
want: true,
}, {
name: "test case 3 -- invalid yaml check",
args: args{
filename: "name.xml",
filetype: ".yaml",
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := isOfType(tt.args.filename, tt.args.filetype); got != tt.want {
t.Errorf("isOfType() = %v, want %v", got, tt.want)
}
})
}
}
func Test_readFile(t *testing.T) {
type args struct {
filepath string
}
tests := []struct {
name string
args args
want string
}{
{
name: "test case 1 -- successful reading.",
args: args{
filepath: "test_files/values.yaml",
},
want: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := readFile(tt.args.filepath); got != tt.want {
t.Errorf("readFile() = %v, want %v", got, tt.want)
}
})
}
}
// func Test_printHelp(t *testing.T) {
// tests := []struct {
// name string
// }{
// // TODO: Add test cases.
// }
// for range tests {
// t.Run(tt.name, func(t *testing.T) {
// printHelp()
// })
// }
// }