diff options
author | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2018-03-19 11:58:59 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-03-19 11:58:59 +0000 |
commit | b8a5e52193b7d02de4802b589e098bbbfa0ec425 (patch) | |
tree | 30833503feb797f8610b21f2475c04e959b0ebac /go/internal/config/config_test.go | |
parent | 355e70e08b9180456ef57fb79a2c3b5654f85479 (diff) | |
download | gitlab-shell-b8a5e52193b7d02de4802b589e098bbbfa0ec425.tar.gz |
Switch to structured logging
Diffstat (limited to 'go/internal/config/config_test.go')
-rw-r--r-- | go/internal/config/config_test.go | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/go/internal/config/config_test.go b/go/internal/config/config_test.go index 0ca2dab..0a5c842 100644 --- a/go/internal/config/config_test.go +++ b/go/internal/config/config_test.go @@ -1,28 +1,37 @@ package config import ( + "fmt" "testing" ) func TestConfigLogFile(t *testing.T) { testRoot := "/foo/bar" testCases := []struct { - yaml string - path string + yaml string + path string + format string }{ - {path: "/foo/bar/gitlab-shell.log"}, - {yaml: "log_file: my-log.log", path: "/foo/bar/my-log.log"}, - {yaml: "log_file: /qux/my-log.log", path: "/qux/my-log.log"}, + {path: "/foo/bar/gitlab-shell.log", format: "text"}, + {yaml: "log_file: my-log.log", path: "/foo/bar/my-log.log", format: "text"}, + {yaml: "log_file: /qux/my-log.log", path: "/qux/my-log.log", format: "text"}, + {yaml: "log_format: json", path: "/foo/bar/gitlab-shell.log", format: "json"}, } for _, tc := range testCases { - cfg := Config{RootDir: testRoot} - if err := parseConfig([]byte(tc.yaml), &cfg); err != nil { - t.Fatalf("%q: %v", tc.yaml, err) - } + t.Run(fmt.Sprintf("yaml input: %q", tc.yaml), func(t *testing.T) { + cfg := Config{RootDir: testRoot} + if err := parseConfig([]byte(tc.yaml), &cfg); err != nil { + t.Fatal(err) + } - if cfg.LogFile != tc.path { - t.Fatalf("%q: expected %q, got %q", tc.yaml, tc.path, cfg.LogFile) - } + if cfg.LogFile != tc.path { + t.Fatalf("expected %q, got %q", tc.path, cfg.LogFile) + } + + if cfg.LogFormat != tc.format { + t.Fatalf("expected %q, got %q", tc.format, cfg.LogFormat) + } + }) } } |