Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: common/tsmon/config_test.go

Issue 2225933003: tsmon: read hostname and region from config file (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Fixed error in test Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « common/tsmon/config.go ('k') | common/tsmon/iface.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package tsmon 5 package tsmon
6 6
7 import ( 7 import (
8 "io/ioutil" 8 "io/ioutil"
9 "os" 9 "os"
10 "testing" 10 "testing"
(...skipping 14 matching lines...) Expand all
25 if err != nil { 25 if err != nil {
26 t.Fail() 26 t.Fail()
27 } 27 }
28 defer tf.Close() 28 defer tf.Close()
29 defer os.Remove(tf.Name()) 29 defer os.Remove(tf.Name())
30 30
31 c, err := loadConfig(tf.Name()) 31 c, err := loadConfig(tf.Name())
32 So(c.Endpoint, ShouldEqual, "") 32 So(c.Endpoint, ShouldEqual, "")
33 So(c.Credentials, ShouldEqual, "") 33 So(c.Credentials, ShouldEqual, "")
34 So(c.AutoGenHostname, ShouldEqual, false) 34 So(c.AutoGenHostname, ShouldEqual, false)
35 So(c.Hostname, ShouldEqual, "")
36 So(c.Region, ShouldEqual, "")
35 So(err, ShouldNotBeNil) 37 So(err, ShouldNotBeNil)
36 }) 38 })
37 39
38 Convey("Full file", t, func() { 40 Convey("Full file", t, func() {
39 tf, err := ioutil.TempFile("", "config_test") 41 tf, err := ioutil.TempFile("", "config_test")
40 if err != nil { 42 if err != nil {
41 t.Fail() 43 t.Fail()
42 } 44 }
43 defer tf.Close() 45 defer tf.Close()
44 defer os.Remove(tf.Name()) 46 defer os.Remove(tf.Name())
45 47
46 » » tf.WriteString(`{"endpoint": "foo", "credentials": "bar", "autog en_hostname": true}`) 48 » » tf.WriteString(`
49 » » » {"endpoint": "foo",
50 » » » "credentials": "bar",
51 » » » "autogen_hostname": true,
52 » » » "hostname": "test_host",
53 » » » "region": "test_region"
54 » » » }`)
47 tf.Sync() 55 tf.Sync()
48 56
49 c, err := loadConfig(tf.Name()) 57 c, err := loadConfig(tf.Name())
50 So(c.Endpoint, ShouldEqual, "foo") 58 So(c.Endpoint, ShouldEqual, "foo")
51 So(c.Credentials, ShouldEqual, "bar") 59 So(c.Credentials, ShouldEqual, "bar")
52 So(c.AutoGenHostname, ShouldEqual, true) 60 So(c.AutoGenHostname, ShouldEqual, true)
61 So(c.Hostname, ShouldEqual, "test_host")
62 So(c.Region, ShouldEqual, "test_region")
53 So(err, ShouldBeNil) 63 So(err, ShouldBeNil)
54 }) 64 })
55 } 65 }
OLDNEW
« no previous file with comments | « common/tsmon/config.go ('k') | common/tsmon/iface.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698