Skip to content

Commit

Permalink
config: fix err check (pingcap#22987)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjianke authored Mar 1, 2021
1 parent 4e44674 commit b336f83
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ func (s *testConfigSuite) TestLogConfig(c *C) {
c.Assert(conf.Log.EnableTimestamp, Equals, expectedEnableTimestamp)
c.Assert(conf.Log.DisableTimestamp, Equals, expectedDisableTimestamp)
c.Assert(conf.Log.ToLogConfig(), DeepEquals, logutil.NewLogConfig("info", "text", "tidb-slow.log", conf.Log.File, resultedDisableTimestamp, func(config *zaplog.Config) { config.DisableErrorVerbose = resultedDisableErrorVerbose }))
f.Truncate(0)
f.Seek(0, 0)
err := f.Truncate(0)
c.Assert(err, IsNil)
_, err = f.Seek(0, 0)
c.Assert(err, IsNil)
}

testLoad(`
Expand Down Expand Up @@ -174,8 +176,10 @@ unrecognized-option-test = true
c.Assert(conf.Load(configFile), ErrorMatches, "(?:.|\n)*invalid configuration option(?:.|\n)*")
c.Assert(conf.MaxServerConnections, Equals, uint32(0))

f.Truncate(0)
f.Seek(0, 0)
err = f.Truncate(0)
c.Assert(err, IsNil)
_, err = f.Seek(0, 0)
c.Assert(err, IsNil)

_, err = f.WriteString(`
token-limit = 0
Expand Down Expand Up @@ -286,8 +290,10 @@ log-rotate = true`)

// Test telemetry config default value and whether it will be overwritten.
conf = NewConfig()
f.Truncate(0)
f.Seek(0, 0)
err = f.Truncate(0)
c.Assert(err, IsNil)
_, err = f.Seek(0, 0)
c.Assert(err, IsNil)
c.Assert(f.Sync(), IsNil)
c.Assert(conf.Load(configFile), IsNil)
c.Assert(conf.EnableTelemetry, Equals, true)
Expand Down

0 comments on commit b336f83

Please sign in to comment.