format code for CI

This commit is contained in:
Ali Alrahahleh 2016-05-24 23:33:49 -07:00
parent 3c211a6deb
commit 864177a850
2 changed files with 29 additions and 31 deletions

View File

@ -1,18 +1,18 @@
package graylog package graylog
import ( import (
"bytes"
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"strconv"
"bytes"
"regexp"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"regexp"
"strconv"
"strings" "strings"
"sync" "sync"
"time" "time"
"encoding/json"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/internal"
@ -222,7 +222,7 @@ func (h *GrayLog) gatherServer(
for k, v := range metric.Fields() { for k, v := range metric.Fields() {
re, _ := regexp.Compile(`metrics_([0-9]+)`) re, _ := regexp.Compile(`metrics_([0-9]+)`)
match := re.FindAllStringSubmatch(k, -1) match := re.FindAllStringSubmatch(k, -1)
if(match != nil) { if match != nil {
i, _ := strconv.Atoi(match[0][1]) i, _ := strconv.Atoi(match[0][1])
fields[name_list[i]] = v fields[name_list[i]] = v
} }

View File

@ -1,10 +1,10 @@
package graylog package graylog
import ( import (
// "fmt" // "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
// "net/http/httptest" // "net/http/httptest"
"strings" "strings"
"testing" "testing"
@ -36,7 +36,6 @@ const validJSON = `
] ]
}` }`
var expectedFields = map[string]interface{}{ var expectedFields = map[string]interface{}{
"jvm.memory.pools.Metaspace.committed": float64(108040192), "jvm.memory.pools.Metaspace.committed": float64(108040192),
"jvm.cl.loaded": float64(18910), "jvm.cl.loaded": float64(18910),
@ -102,9 +101,9 @@ func genMockGrayLog(response string, statusCode int) []*GrayLog {
"jvm.cl.loaded", "jvm.cl.loaded",
}, },
Headers: map[string]string{ Headers: map[string]string{
"Content-Type" : "application/json", "Content-Type": "application/json",
"Accept" : "application/json", "Accept": "application/json",
"Authorization" : "Basic DESfdsfffoffo", "Authorization": "Basic DESfdsfffoffo",
}, },
}, },
&GrayLog{ &GrayLog{
@ -117,9 +116,9 @@ func genMockGrayLog(response string, statusCode int) []*GrayLog {
"jvm.memory.pools.Metaspace.committed", "jvm.memory.pools.Metaspace.committed",
}, },
Headers: map[string]string{ Headers: map[string]string{
"Content-Type" : "application/json", "Content-Type": "application/json",
"Accept" : "application/json", "Accept": "application/json",
"Authorization" : "Basic DESfdsfffoffo", "Authorization": "Basic DESfdsfffoffo",
}, },
TagKeys: []string{ TagKeys: []string{
"role", "role",
@ -152,7 +151,6 @@ func TestNormalResponse(t *testing.T) {
} }
} }
// Test response to HTTP 500 // Test response to HTTP 500
func TestHttpJson500(t *testing.T) { func TestHttpJson500(t *testing.T) {
graylog := genMockGrayLog(validJSON, 500) graylog := genMockGrayLog(validJSON, 500)