Delete unused helpers

This commit is contained in:
Phillip Wittrock
2016-04-18 13:09:57 -07:00
parent 8a8177f99e
commit 1a3b133077
2 changed files with 0 additions and 100 deletions

View File

@@ -20,7 +20,6 @@ import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"reflect"
"strings"
"syscall"
@@ -212,65 +211,6 @@ func (f *fileHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
res.Write(f.data)
}
func TestReadConfigData(t *testing.T) {
httpData := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
// TODO: Close() this server when fix #19254
server := httptest.NewServer(&fileHandler{data: httpData})
fileData := []byte{11, 12, 13, 14, 15, 16, 17, 18, 19}
f, err := ioutil.TempFile("", "config")
if err != nil {
t.Errorf("unexpected error setting up config file")
t.Fail()
}
defer syscall.Unlink(f.Name())
ioutil.WriteFile(f.Name(), fileData, 0644)
// TODO: test TLS here, requires making it possible to inject the HTTP client.
tests := []struct {
config string
data []byte
expectErr bool
}{
{
config: server.URL,
data: httpData,
},
{
config: server.URL + "/error",
expectErr: true,
},
{
config: "http://some.non.existent.foobar",
expectErr: true,
},
{
config: f.Name(),
data: fileData,
},
{
config: "some-non-existent-file",
expectErr: true,
},
{
config: "",
expectErr: true,
},
}
for _, test := range tests {
dataOut, err := ReadConfigData(test.config)
if err != nil && !test.expectErr {
t.Errorf("unexpected err: %v for %s", err, test.config)
}
if err == nil && test.expectErr {
t.Errorf("unexpected non-error for %s", test.config)
}
if !test.expectErr && !reflect.DeepEqual(test.data, dataOut) {
t.Errorf("unexpected data: %v, expected %v", dataOut, test.data)
}
}
}
func TestCheckInvalidErr(t *testing.T) {
tests := []struct {
err error