Skip to content

Commit f419d6a

Browse files
committed
Simplify tests by removing conditional logic, making use of the exptected value
1 parent c4e8578 commit f419d6a

File tree

1 file changed

+3
-44
lines changed

1 file changed

+3
-44
lines changed

apps/internal/local/server_test.go

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -233,51 +233,10 @@ func TestServer(t *testing.T) {
233233
}
234234

235235
if test.testTemplate {
236-
if test.testErrCodeXSS || test.testErrDescriptionXSS {
237-
if !strings.Contains(string(content), test.expected) {
238-
t.Errorf("TestServer(%s): want escaped html entities", test.desc)
239-
}
240-
continue
241-
}
242-
243-
if len(test.errorPage) > 0 && (test.testErrCodeXSS || test.testErrDescriptionXSS) {
244-
if !strings.Contains(string(content), test.expected) {
245-
t.Errorf("TestServer(%s): want escaped html entities", test.desc)
246-
}
247-
continue
248-
}
249-
250-
if len(test.errorPage) > 0 {
251-
errCode := bytes.Contains(test.errorPage, []byte("{{.Code}}"))
252-
errDescription := bytes.Contains(test.errorPage, []byte("{{.Err}}"))
253-
254-
if !errCode && !errDescription {
255-
if !strings.Contains(string(content), test.expected) {
256-
t.Errorf("TestServer(%s): -want/+got:\ntest option error page", test.desc)
257-
}
258-
}
259-
if errCode && errDescription {
260-
if !strings.Contains(string(content), test.expected) {
261-
t.Errorf("TestServer(%s): -want/+got:\ntest option error page error_code error_description", test.desc)
262-
}
263-
}
264-
if errCode && !errDescription {
265-
if !strings.Contains(string(content), test.expected) {
266-
t.Errorf("TestServer(%s): -want/+got:\ntest option error page error_code", test.desc)
267-
}
268-
}
269-
if !errCode && errDescription {
270-
if !strings.Contains(string(content), test.expected) {
271-
t.Errorf("TestServer(%s): -want/+got:\ntest option error page error_description", test.desc)
272-
}
273-
}
274-
continue
275-
} else {
276-
if !strings.Contains(string(content), test.expected) {
277-
t.Errorf("TestServer(%s): -want/+got:\ntest option error page error_code error_description", test.desc)
278-
}
279-
continue
236+
if !strings.Contains(string(content), test.expected) {
237+
t.Errorf("TestServer(%s): -want:%s got:%s ", test.desc, test.expected, string(content))
280238
}
239+
continue
281240
}
282241

283242
if !strings.Contains(string(content), "Authentication Complete") {

0 commit comments

Comments
 (0)