aboutsummaryrefslogtreecommitdiff
path: root/server/main.go
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2016-04-23 18:04:09 +0100
committerNiall Sheridan <nsheridan@gmail.com>2016-04-23 18:04:09 +0100
commit19125034df9d17e0eec70fd8be76d785648232b1 (patch)
tree0763fc763058c2d827ba70d946df900e5e81bc13 /server/main.go
parentbbca1c033649c178475671b5be6133a92e0f9bc1 (diff)
Refactor to use an io.Reader for easier testing
Diffstat (limited to 'server/main.go')
-rw-r--r--server/main.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/server/main.go b/server/main.go
index c597b2e..4f1cbd6 100644
--- a/server/main.go
+++ b/server/main.go
@@ -12,6 +12,7 @@ import (
"io/ioutil"
"log"
"net/http"
+ "os"
"time"
"golang.org/x/oauth2"
@@ -203,9 +204,18 @@ func newState() string {
return hex.EncodeToString(k)
}
+func readConfig(filename string) (*config.Config, error) {
+ f, err := os.Open(filename)
+ if err != nil {
+ return nil, err
+ }
+ defer f.Close()
+ return config.ReadConfig(f)
+}
+
func main() {
flag.Parse()
- config, err := config.ReadConfig(*cfg)
+ config, err := readConfig(*cfg)
if err != nil {
log.Fatal(err)
}