-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_webserver_file_test.go
40 lines (32 loc) · 1002 Bytes
/
get_webserver_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
package main
import (
"fmt"
"testing"
)
func TestGetServerFile(t *testing.T) {
// The tests to run
var tests = []struct {
name string
input string
expectedResult bool
}{
{"NoParameterData", "", false},
{"InvalidURL", "http://invalid", false},
}
// Write name of function being tested to test results file
LogResult("GetServerFile")
// Run the tests
for _, currentTest := range tests {
testname := fmt.Sprintf("%s", currentTest.name)
t.Run(testname, func(t *testing.T) {
result := GetServerFile(currentTest.input)
if result != currentTest.expectedResult {
LogResult(currentTest.name + " - " + fmt.Sprintf("Input: %s Got: %t Expected: %t", currentTest.input, result, currentTest.expectedResult) + " - FAIL")
} else {
LogResult(currentTest.name + " - " + fmt.Sprintf("Input: %s Got: %t Expected: %t", currentTest.input, result, currentTest.expectedResult) + " - PASS")
}
})
}
// Clean up test data
DeleteFile("ServerFile.tmp")
}